Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix L2 block gas limit to 2**50 (1125899906842624) #3219

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func Test_Defaults(t *testing.T) {
},
{
path: "State.Batch.Constraints.MaxCumulativeGasUsed",
expectedValue: uint64(9223372036854775807),
expectedValue: uint64(1125899906842624),
},
{
path: "State.Batch.Constraints.MaxKeccakHashes",
Expand Down
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
2 changes: 1 addition & 1 deletion config/environments/cardona/node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
2 changes: 1 addition & 1 deletion config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
2 changes: 1 addition & 1 deletion config/environments/mainnet/node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
2 changes: 1 addition & 1 deletion config/environments/testnet/node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3736,12 +3736,12 @@ MaxBatchBytesSize=120000

**Type:** : `integer`

**Default:** `9223372036854775807`
**Default:** `1125899906842624`

**Example setting the default value** (9223372036854775807):
**Example setting the default value** (1125899906842624):
```
[State.Batch.Constraints]
MaxCumulativeGasUsed=9223372036854775807
MaxCumulativeGasUsed=1125899906842624
```

##### <a name="State_Batch_Constraints_MaxKeccakHashes"></a>20.9.1.4. `State.Batch.Constraints.MaxKeccakHashes`
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@
},
"MaxCumulativeGasUsed": {
"type": "integer",
"default": 9223372036854775807
"default": 1125899906842624
},
"MaxKeccakHashes": {
"type": "integer",
Expand Down
5 changes: 5 additions & 0 deletions state/convertersV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)

const (
// MaxL2BlockGasLimit is the gas limit allowed per L2 block in a batch
MaxL2BlockGasLimit = uint64(1125899906842624)
)

var (
errL2BlockInvalid = errors.New("A L2 block fails, that invalidate totally the batch")
)
Expand Down
9 changes: 7 additions & 2 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,18 @@ func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *P
return err
}

gasLimit := l2Block.GasLimit
if gasLimit > MaxL2BlockGasLimit {
gasLimit = MaxL2BlockGasLimit
}

header := &types.Header{
Number: new(big.Int).SetUint64(l2Block.BlockNumber),
ParentHash: prevL2BlockHash,
Coinbase: l2Block.Coinbase,
Root: l2Block.BlockHash, //BlockHash returned by the executor is the StateRoot in Etrog
GasUsed: l2Block.GasUsed,
GasLimit: l2Block.GasLimit,
GasLimit: gasLimit,
Time: l2Block.Timestamp,
}

Expand Down Expand Up @@ -630,7 +635,7 @@ func (s *State) StoreTransaction(ctx context.Context, batchNumber uint64, proces
Coinbase: coinbase,
Root: processedTx.StateRoot,
GasUsed: processedTx.GasUsed,
GasLimit: s.cfg.MaxCumulativeGasUsed,
GasLimit: MaxTxGasLimit,
Time: timestamp,
})
header.GlobalExitRoot = globalExitRoot
Expand Down
3 changes: 1 addition & 2 deletions test/benchmarks/sequencer/common/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package setup
import (
"context"
"fmt"
"math"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -32,7 +31,7 @@ var (
bc = state.BatchConstraintsCfg{
MaxTxsPerBatch: 300,
MaxBatchBytesSize: 120000,
MaxCumulativeGasUsed: uint64(math.MaxInt64),
MaxCumulativeGasUsed: uint64(1125899906842624),
MaxKeccakHashes: 2145,
MaxPoseidonHashes: 252357,
MaxPoseidonPaddings: 135191,
Expand Down
2 changes: 1 addition & 1 deletion test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Outputs = ["stderr"]
[State.Batch.Constraints]
MaxTxsPerBatch = 300
MaxBatchBytesSize = 120000
MaxCumulativeGasUsed = 9223372036854775807
MaxCumulativeGasUsed = 1125899906842624
MaxKeccakHashes = 2145
MaxPoseidonHashes = 252357
MaxPoseidonPaddings = 135191
Expand Down
Loading