Skip to content

Commit

Permalink
support 0 gasprice (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: chengzhinei <[email protected]>
  • Loading branch information
giskook and chengzhinei authored Oct 12, 2023
1 parent faeefd7 commit de7d107
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions claimtxman/claimtxman.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,13 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
}

// GasPrice is set here to use always the proper and most accurate value right before sending it to L2
gasPrice, err := tm.l2Node.SuggestGasPrice(ctx)
if err != nil {
mTxLog.Errorf("failed to get suggested gasPrice. Error: %v", err)
continue
gasPrice := big.NewInt(0)
if !tm.cfg.FreeGas {
gasPrice, err = tm.l2Node.SuggestGasPrice(ctx)
if err != nil {
mTxLog.Errorf("failed to get suggested gasPrice. Error: %v", err)
continue
}
}
//Multiply gasPrice by 10 to increase the efficiency of the tx in the sequence
mTx.GasPrice = big.NewInt(0).Mul(gasPrice, big.NewInt(10)) //nolint:gomnd
Expand Down
2 changes: 2 additions & 0 deletions claimtxman/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ type Config struct {
RetryInterval types.Duration `mapstructure:"RetryInterval"`
// RetryNumber is the number of retries before giving up
RetryNumber int `mapstructure:"RetryNumber"`
// FreeGas enabled whether gas price is 0
FreeGas bool `mapstructure:"FreeGas"`
}
1 change: 1 addition & 0 deletions config/config.debug.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ FrequencyToMonitorTxs = "1s"
PrivateKey = {Path = "../test/test.keystore.sequencer", Password = "testonly"}
RetryInterval = "1s"
RetryNumber = 10
FreeGas = true

[Etherman]
L1URL = "http://localhost:8545"
Expand Down
1 change: 1 addition & 0 deletions config/config.local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ FrequencyToMonitorTxs = "1s"
PrivateKey = {Path = "/pk/keystore.claimtxmanager", Password = "testonly"}
RetryInterval = "1s"
RetryNumber = 10
FreeGas = true

[Etherman]
L1URL = "http://zkevm-mock-l1-network:8545"
Expand Down

0 comments on commit de7d107

Please sign in to comment.