Skip to content
This repository was archived by the owner on Apr 11, 2021. It is now read-only.

Commit 6c7971a

Browse files
committed
feat: allow configuring the L1GasPrice over a new private namespace
1 parent 735df0e commit 6c7971a

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

eth/api_backend.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ func (b *EthAPIBackend) SuggestDataPrice(ctx context.Context) (*big.Int, error)
376376
return b.l1gpo.SuggestDataPrice(ctx)
377377
}
378378

379+
func (b *EthAPIBackend) SetL1GasPrice(ctx context.Context, gasPrice *big.Int) {
380+
b.l1gpo.SetL1GasPrice(gasPrice)
381+
}
382+
379383
func (b *EthAPIBackend) ChainDb() ethdb.Database {
380384
return b.eth.ChainDb()
381385
}

eth/gasprice/l1_gasprice.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ func NewL1Oracle(gasPrice *big.Int) *L1Oracle {
1818
func (gpo *L1Oracle) SuggestDataPrice(ctx context.Context) (*big.Int, error) {
1919
return gpo.gasPrice, nil
2020
}
21+
22+
func (gpo *L1Oracle) SetL1GasPrice(gasPrice *big.Int) {
23+
gpo.gasPrice = gasPrice
24+
}

internal/ethapi/api.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,24 @@ func (api *PublicRollupAPI) GetInfo(ctx context.Context) rollupInfo {
19571957
}
19581958
}
19591959

1960+
// PrivatelRollupAPI provides private RPC methods to control the sequencer.
1961+
// These methods can be abused by external users and must be considered insecure for use by untrusted users.
1962+
type PrivateRollupAPI struct {
1963+
b Backend
1964+
}
1965+
1966+
// NewPrivateRollupAPI creates a new API definition for the rollup methods of the
1967+
// Ethereum service.
1968+
func NewPrivateRollupAPI(b Backend) *PrivateRollupAPI {
1969+
return &PrivateRollupAPI{b: b}
1970+
}
1971+
1972+
// SetGasPrice sets the gas price to be used when quoting calldata publishing costs
1973+
// to users
1974+
func (api *PrivateRollupAPI) SetL1GasPrice(ctx context.Context, gasPrice hexutil.Big) {
1975+
api.b.SetL1GasPrice(ctx, (*big.Int)(&gasPrice))
1976+
}
1977+
19601978
// PublicDebugAPI is the collection of Ethereum APIs exposed over the public
19611979
// debugging endpoint.
19621980
type PublicDebugAPI struct {

internal/ethapi/backend.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type Backend interface {
9595
GasLimit() uint64
9696
GetDiff(*big.Int) (diffdb.Diff, error)
9797
SuggestDataPrice(ctx context.Context) (*big.Int, error)
98+
SetL1GasPrice(context.Context, *big.Int)
9899
}
99100

100101
func GetAPIs(apiBackend Backend) []rpc.API {
@@ -120,6 +121,10 @@ func GetAPIs(apiBackend Backend) []rpc.API {
120121
Version: "1.0",
121122
Service: NewPublicRollupAPI(apiBackend),
122123
Public: true,
124+
}, {
125+
Namespace: "rollup_personal",
126+
Version: "1.0",
127+
Service: NewPrivateRollupAPI(apiBackend),
123128
}, {
124129
Namespace: "txpool",
125130
Version: "1.0",

les/api_backend.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ func (b *LesApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
283283

284284
// NB: Non sequencer nodes cannot suggest L1 gas prices.
285285
func (b *LesApiBackend) SuggestDataPrice(ctx context.Context) (*big.Int, error) {
286-
panic("not implemented")
286+
panic("SuggestDataPrice not implemented")
287+
}
288+
289+
// NB: Non sequencer nodes cannot set L1 gas prices.
290+
func (b *LesApiBackend) SetL1GasPrice(ctx context.Context, gasPrice *big.Int) {
291+
panic("SetL1GasPrice is not implemented")
287292
}
288293

289294
func (b *LesApiBackend) ChainDb() ethdb.Database {

0 commit comments

Comments
 (0)