Skip to content

Commit

Permalink
config: configurable gas limit (ethereum#160)
Browse files Browse the repository at this point in the history
* config: configurable gas limit

* cfg: gas limit

* fix failing test - add gas limit

Co-authored-by: Kevin Ho <[email protected]>
  • Loading branch information
tynes and K-Ho authored Dec 15, 2020
1 parent 0ca48c8 commit a38e127
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,10 @@ var (
Usage: "Comma separated HTTP URL list to notify of new work packages",
}
MinerGasTargetFlag = cli.Uint64Flag{
Name: "miner.gastarget",
Usage: "Target gas floor for mined blocks",
Value: eth.DefaultConfig.Miner.GasFloor,
Name: "miner.gastarget",
Usage: "Target gas floor for mined blocks",
Value: eth.DefaultConfig.Miner.GasFloor,
EnvVar: "TARGET_GAS_LIMIT",
}
MinerLegacyGasTargetFlag = cli.Uint64Flag{
Name: "targetgaslimit",
Expand Down Expand Up @@ -1123,11 +1124,6 @@ func setEth1(ctx *cli.Context, cfg *rollup.Config) {
if ctx.GlobalIsSet(Eth1SyncServiceEnable.Name) {
cfg.Eth1SyncServiceEnable = ctx.GlobalBool(Eth1SyncServiceEnable.Name)
}
// Check for both the legacy and standard gas target flags, if both are
// set then use the standard flag.
if ctx.GlobalIsSet(MinerLegacyGasTargetFlag.Name) {
cfg.GasLimit = ctx.GlobalUint64(MinerGasTargetFlag.Name)
}
if ctx.GlobalIsSet(MinerGasTargetFlag.Name) {
cfg.GasLimit = ctx.GlobalUint64(MinerGasTargetFlag.Name)
}
Expand Down Expand Up @@ -1725,10 +1721,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
chainID = new(big.Int).SetUint64(id)
}

gasLimit := cfg.Rollup.GasLimit
if gasLimit == 0 {
gasLimit = params.GenesisGasLimit
}
xdomainAddress := cfg.Rollup.L1CrossDomainMessengerAddress
addrManagerOwnerAddress := cfg.Rollup.AddressManagerOwnerAddress
stateDumpPath := cfg.Rollup.StateDumpPath
cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address, xdomainAddress, addrManagerOwnerAddress, stateDumpPath, chainID)
cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address, xdomainAddress, addrManagerOwnerAddress, stateDumpPath, chainID, gasLimit)
if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) {
cfg.Miner.GasPrice = big.NewInt(1)
}
Expand Down
2 changes: 1 addition & 1 deletion console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
t.Fatalf("failed to create node: %v", err)
}
ethConf := &eth.Config{
Genesis: core.DeveloperGenesisBlock(15, common.Address{}, common.Address{}, common.Address{}, "", nil),
Genesis: core.DeveloperGenesisBlock(15, common.Address{}, common.Address{}, common.Address{}, "", nil, 12000000),
Miner: miner.Config{
Etherbase: common.HexToAddress(testAddress),
},
Expand Down
4 changes: 2 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func DefaultGoerliGenesisBlock() *Genesis {
}

// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
func DeveloperGenesisBlock(period uint64, faucet, xDomainMessengerAddress, addrManagerOwnerAddress common.Address, stateDumpPath string, chainID *big.Int) *Genesis {
func DeveloperGenesisBlock(period uint64, faucet, xDomainMessengerAddress, addrManagerOwnerAddress common.Address, stateDumpPath string, chainID *big.Int, gasLimit uint64) *Genesis {
// Override the default period to the user requested one
config := *params.AllCliqueProtocolChanges
config.Clique.Period = period
Expand Down Expand Up @@ -479,7 +479,7 @@ func DeveloperGenesisBlock(period uint64, faucet, xDomainMessengerAddress, addrM
return &Genesis{
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 12000000,
GasLimit: gasLimit,
Difficulty: big.NewInt(1),
Alloc: map[common.Address]GenesisAccount{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
Expand Down

0 comments on commit a38e127

Please sign in to comment.