Commit 929d1f9c authored by Adrian Sutton's avatar Adrian Sutton

Manually estimate gas when sending deposit transactions in e2e tests.

parent 3891726b
......@@ -3,6 +3,7 @@ package actions
import (
"crypto/ecdsa"
"errors"
"fmt"
"math/big"
"math/rand"
......@@ -327,9 +328,21 @@ func (s *CrossLayerUser) ActDeposit(t Testing) {
depositGas = gas
}
// Finally send TX
s.L1.txOpts.GasLimit = 0
tx, err := s.L1.env.Bindings.OptimismPortal.DepositTransaction(&s.L1.txOpts, toAddr, depositTransferValue, depositGas, isCreation, s.L2.txCallData)
require.Nil(t, err, "with deposit tx")
// Add 10% padding for the L1 gas limit because the estimation process can be affected by the 1559 style cost scale
// for buying L2 gas in the portal contracts.
s.L1.txOpts.GasLimit = tx.Gas() + (tx.Gas() / 10)
tx, err = s.L1.env.Bindings.OptimismPortal.DepositTransaction(&s.L1.txOpts, toAddr, depositTransferValue, depositGas, isCreation, s.L2.txCallData)
require.NoError(t, err, "failed to create deposit tx")
s.L1.txOpts.GasLimit = 0
fmt.Printf("Gas limit: %v\n", tx.Gas())
// Send the actual tx (since tx opts don't send by default)
err = s.L1.env.EthCl.SendTransaction(t.Ctx(), tx)
require.NoError(t, err, "must send tx")
......
......@@ -29,9 +29,20 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l
require.Nil(t, err)
// Finally send TX
l1Opts.NoSend = true
tx, err := depositContract.DepositTransaction(l1Opts, l2Opts.ToAddr, l2Opts.Value, l2Opts.GasLimit, l2Opts.IsCreation, l2Opts.Data)
require.Nil(t, err, "with deposit tx")
l1Opts.NoSend = false
// Add 10% padding for the L1 gas limit because the estimation process can be affected by the 1559 style cost scale
// for buying L2 gas in the portal contracts.
l1Opts.GasLimit = tx.Gas() + (tx.Gas() / 10)
// Now resend with gas specified
tx, err = depositContract.DepositTransaction(l1Opts, l2Opts.ToAddr, l2Opts.Value, l2Opts.GasLimit, l2Opts.IsCreation, l2Opts.Data)
require.Nil(t, err, "with deposit tx")
l1Opts.GasLimit = 0
// Wait for transaction on L1
receipt, err := waitForTransaction(tx.Hash(), l1Client, 10*time.Duration(cfg.DeployConfig.L1BlockTime)*time.Second)
require.Nil(t, err, "Waiting for deposit tx on L1")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment