Skip to content

Commit

Permalink
allow forcing gas in eth tx manager (#1706)
Browse files Browse the repository at this point in the history
* allow forcing gas in eth tx manager

* fix test

* fix test

* undo prover image

* undo prover image

* undo prover image
  • Loading branch information
ToniRamirezM authored Feb 27, 2023
1 parent 7ea3e76 commit 5d53d92
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ func Test_Defaults(t *testing.T) {
path: "EthTxManager.WaitTxToBeMined",
expectedValue: types.NewDuration(2 * time.Minute),
},
{
path: "EthTxManager.WaitTxToBeMined",
expectedValue: types.NewDuration(2 * time.Minute),
},
{
path: "EthTxManager.ForcedGas",
expectedValue: uint64(0),
},
{
path: "PriceGetter.Type",
expectedValue: pricegetter.DefaultType,
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ MultiGasProvider = true
[EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
ForcedGas = 0
[RPC]
Host = "0.0.0.0"
Expand Down
1 change: 1 addition & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"

[EthTxManager]
ForcedGas = 0
PrivateKeys = [
{Path = "/pk/sequencer.keystore", Password = "testonly"},
{Path = "/pk/aggregator.keystore", Password = "testonly"}
Expand Down
2 changes: 0 additions & 2 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,10 @@ func (etherMan *Client) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVe
var newStateRoot [32]byte
copy(newStateRoot[:], inputs.NewStateRoot)

log.Info("Proof before trim: ", inputs.FinalProof.Proof)
proof, err := encoding.DecodeBytes(&inputs.FinalProof.Proof)
if err != nil {
return nil, nil, fmt.Errorf("failed to decode proof, err: %w", err)
}
log.Info("Proof after trim: %v", common.Bytes2Hex(proof))

const pendStateNum = 0 // TODO hardcoded for now until we implement the pending state feature

Expand Down
3 changes: 3 additions & 0 deletions ethtxmanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ type Config struct {
// PrivateKeys defines all the key store files that are going
// to be read in order to provide the private keys to sign the L1 txs
PrivateKeys []types.KeystoreFileConfig `mapstructure:"PrivateKeys"`

// ForcedGas is the amount of gas to be forced in case of gas estimation error
ForcedGas uint64 `mapstructure:"ForcedGas"`
}
12 changes: 7 additions & 5 deletions ethtxmanager/ethtxmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ func (c *Client) Add(ctx context.Context, owner, id string, from common.Address,
// get gas
gas, err := c.etherman.EstimateGas(ctx, from, to, value, data)
if err != nil {
cad := common.Bytes2Hex(data)
err := fmt.Errorf("failed to estimate gas: %w, data: %v", err, cad)
log.Errorf(err.Error())
gas = 1000000
// return err
err := fmt.Errorf("failed to estimate gas: %w, data: %v", err, common.Bytes2Hex(data))
log.Error(err.Error())
if c.cfg.ForcedGas > 0 {
gas = c.cfg.ForcedGas
} else {
return err
}
}
// get gas price
gasPrice, err := c.etherman.SuggestedGasPrice(ctx)
Expand Down
1 change: 1 addition & 0 deletions test/config/debug.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"

[EthTxManager]
ForcedGas = 0
PrivateKeys = [
{Path = "../test/sequencer.keystore", Password = "testonly"},
{Path = "../test/aggregator.keystore", Password = "testonly"}
Expand Down
1 change: 1 addition & 0 deletions test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"

[EthTxManager]
ForcedGas = 0
PrivateKeys = [
{Path = "/pk/sequencer.keystore", Password = "testonly"},
{Path = "/pk/aggregator.keystore", Password = "testonly"}
Expand Down

0 comments on commit 5d53d92

Please sign in to comment.