Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions encoding/codecv0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCodecV0BlockEncode(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions encoding/codecv1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"testing"

"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/hexutil"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCodecV1BlockEncode(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions encoding/codecv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"testing"

"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/hexutil"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCodecV2BlockEncode(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions encoding/codecv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/params"
)

type DACodecV3 struct {
Expand Down Expand Up @@ -115,7 +114,7 @@ func (d *DACodecV3) EstimateChunkL1CommitGas(c *Chunk) (uint64, error) {
if err != nil {
return 0, fmt.Errorf("failed to estimate L1 commit gas for chunk: %w", err)
}
totalL1CommitGas += params.BlobTxPointEvaluationPrecompileGas // plus gas cost for the point-evaluation precompile call.
totalL1CommitGas += blobTxPointEvaluationPrecompileGas // plus gas cost for the point-evaluation precompile call.
return totalL1CommitGas, nil
}

Expand All @@ -127,7 +126,7 @@ func (d *DACodecV3) EstimateBatchL1CommitGas(b *Batch) (uint64, error) {
if err != nil {
return 0, fmt.Errorf("failed to estimate L1 commit gas for batch: %w", err)
}
totalL1CommitGas += params.BlobTxPointEvaluationPrecompileGas // plus gas cost for the point-evaluation precompile call.
totalL1CommitGas += blobTxPointEvaluationPrecompileGas // plus gas cost for the point-evaluation precompile call.
return totalL1CommitGas, nil
}

Expand Down
5 changes: 3 additions & 2 deletions encoding/codecv3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"testing"

"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/hexutil"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCodecV3BlockEncode(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions encoding/codecv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
"testing"

"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/hexutil"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCodecV4BlockEncode(t *testing.T) {
Expand Down
33 changes: 17 additions & 16 deletions encoding/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ const (
)

const (
payloadLengthBytes = 4
calldataNonZeroByteGas = 16
coldSloadGas = 2100
coldAddressAccessGas = 2600
warmAddressAccessGas = 100
warmSloadGas = 100
baseTxGas = 21000
sstoreGas = 20000
extraGasCost = 100000 // over-estimate the gas cost for ops like _getAdmin, _implementation, _requireNotPaused, etc
skippedL1MessageBitmapByteSize = 32
functionSignatureBytes = 4
defaultParameterBytes = 32
payloadLengthBytes = 4
calldataNonZeroByteGas = 16
coldSloadGas = 2100
coldAddressAccessGas = 2600
warmAddressAccessGas = 100
warmSloadGas = 100
baseTxGas = 21000
sstoreGas = 20000
extraGasCost = 100000 // over-estimate the gas cost for ops like _getAdmin, _implementation, _requireNotPaused, etc
blobTxPointEvaluationPrecompileGas = 50000
skippedL1MessageBitmapByteSize = 32
functionSignatureBytes = 4
defaultParameterBytes = 32
)

// Block represents an L2 block.
Expand Down Expand Up @@ -628,9 +629,9 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin
return "homestead"
} else if !config.IsCurie(blockHeightBigInt) {
return "bernoulli"
} else if !config.IsDarwin(blockHeightBigInt, blockTimestamp) {
} else if !config.IsDarwin(blockTimestamp) {
return "curie"
} else if !config.IsDarwinV2(blockHeightBigInt, blockTimestamp) {
} else if !config.IsDarwinV2(blockTimestamp) {
return "darwin"
} else {
return "darwinV2"
Expand All @@ -644,9 +645,9 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin
return CodecV0
} else if !config.IsCurie(blockHeightBigInt) {
return CodecV1
} else if !config.IsDarwin(blockHeightBigInt, blockTimestamp) {
} else if !config.IsDarwin(blockTimestamp) {
return CodecV2
} else if !config.IsDarwinV2(blockHeightBigInt, blockTimestamp) {
} else if !config.IsDarwinV2(blockTimestamp) {
return CodecV3
} else {
return CodecV4
Expand Down
4 changes: 2 additions & 2 deletions encoding/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func CodecFromVersion(version CodecVersion) (Codec, error) {

// CodecFromConfig determines and returns the appropriate codec based on chain configuration, block number, and timestamp.
func CodecFromConfig(chainCfg *params.ChainConfig, startBlockNumber *big.Int, startBlockTimestamp uint64) Codec {
if chainCfg.IsDarwinV2(startBlockNumber, startBlockTimestamp) {
if chainCfg.IsDarwinV2(startBlockTimestamp) {
return &DACodecV4{}
} else if chainCfg.IsDarwin(startBlockNumber, startBlockTimestamp) {
} else if chainCfg.IsDarwin(startBlockTimestamp) {
return &DACodecV3{}
} else if chainCfg.IsCurie(startBlockNumber) {
return &DACodecV2{}
Expand Down
3 changes: 2 additions & 1 deletion encoding/interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"math/big"
"testing"

"github.com/scroll-tech/go-ethereum/params"
"github.com/stretchr/testify/assert"

"github.com/scroll-tech/go-ethereum/params"
)

func TestCodecFromVersion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/agiledragon/gomonkey/v2 v2.12.0
github.com/scroll-tech/go-ethereum v1.10.14-0.20241010064814-3d88e870ae22
github.com/scroll-tech/go-ethereum v1.10.14-0.20241206090635-a5ecce2dc333
github.com/stretchr/testify v1.9.0
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241010064814-3d88e870ae22 h1:s1/8G2HP1z9jd0FBbUVs7viv/lQZA/8QoQppXYTX1CU=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241010064814-3d88e870ae22/go.mod h1:r9FwtxCtybMkTbWYCyBuevT9TW3zHmOTHqD082Uh+Oo=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241206090635-a5ecce2dc333 h1:qJXViC4vPMcYNVImHnSWIL4IMXtiyolaN687+qVwc0Y=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241206090635-a5ecce2dc333/go.mod h1:xRDJvaNUe7lCU2fB+AqyS7gahar+dfJPrUJplfXF4dw=
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
Expand Down