Skip to content

Commit 146b5d2

Browse files
eljoberauljordan
andauthored
Reject Estimates for BoLD Txs that Exceed Fusaka's Max Tx Gas Cap (#3814) (#3815)
* cap bold tx estimates to max cap for Fusaka * rem default base Co-authored-by: Raul Jordan <[email protected]>
1 parent 9b87eda commit 146b5d2

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

bold/chain-abstraction/sol-implementation/assertion_chain.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
"github.com/ethereum/go-ethereum/log"
2626
"github.com/ethereum/go-ethereum/rpc"
2727

28-
"github.com/offchainlabs/nitro/bold/chain-abstraction"
28+
protocol "github.com/offchainlabs/nitro/bold/chain-abstraction"
2929
"github.com/offchainlabs/nitro/bold/containers"
3030
"github.com/offchainlabs/nitro/bold/containers/option"
3131
"github.com/offchainlabs/nitro/bold/containers/threadsafe"
32-
"github.com/offchainlabs/nitro/bold/runtime"
32+
retry "github.com/offchainlabs/nitro/bold/runtime"
3333
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
3434
"github.com/offchainlabs/nitro/solgen/go/mocksgen"
3535
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
@@ -46,8 +46,6 @@ var (
4646

4747
var assertionCreatedId common.Hash
4848

49-
var defaultBaseGas = int64(500000)
50-
5149
func init() {
5250
rollupAbi, err := rollupgen.RollupCoreMetaData.GetAbi()
5351
if err != nil {

bold/chain-abstraction/sol-implementation/transact.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818
"github.com/ethereum/go-ethereum/core/types"
1919
"github.com/ethereum/go-ethereum/rpc"
2020

21-
"github.com/offchainlabs/nitro/bold/chain-abstraction"
21+
protocol "github.com/offchainlabs/nitro/bold/chain-abstraction"
2222
"github.com/offchainlabs/nitro/bold/containers"
2323
)
2424

25+
const FUSAKA_MAX_GAS = 1 << 24 // Fusaka hard fork adds a max cap for transactions of 2**24 gas.
26+
2527
// ChainCommitter defines a type of chain backend that supports
2628
// committing changes via a direct method, such as a simulated backend
2729
// for testing purposes.
@@ -86,12 +88,10 @@ func (a *AssertionChain) transact(
8688
return nil, errors.Wrapf(err, "gas estimation errored for tx with hash %s", containers.Trunc(tx.Hash().Bytes()))
8789
}
8890

89-
// Now, we send the tx with the estimated gas.
90-
defaultGasUint64, err := safecast.ToUint64(defaultBaseGas)
91-
if err != nil {
92-
return nil, errors.Wrap(err, "could not convert default base gas to uint64")
91+
if gas >= FUSAKA_MAX_GAS {
92+
return nil, errors.Errorf("gas estimation received from ethclient too high: %d >= %d", gas, FUSAKA_MAX_GAS)
9393
}
94-
opts.GasLimit = gas + defaultGasUint64
94+
opts.GasLimit = gas
9595
tx, err = a.transactor.SendTransaction(ctx, fn, opts, gas)
9696
if err != nil {
9797
return nil, err

0 commit comments

Comments
 (0)