mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
update rollup verifier (#930)
* update l2geth verifier * update verifier * update * remove old structures * decrease diff * decrease diff * fix image build error * update dependency * update c-kzg-4844 dependency * clean up * clean up --------- Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
This commit is contained in:
parent
4d3f98403a
commit
3d964d6e9b
23 changed files with 1233 additions and 625 deletions
|
|
@ -260,7 +260,7 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
|
|||
if runtime.GOOS == "linux" {
|
||||
// Enforce the stacksize to 8M, which is the case on most platforms apart from
|
||||
// alpine Linux.
|
||||
extld := []string{"-Wl,-z,stack-size=0x800000"}
|
||||
extld := []string{"-Wl,-z,stack-size=0x800000", "-ldl"}
|
||||
if staticLinking {
|
||||
extld = append(extld, "-static")
|
||||
// Under static linking, use of certain glibc features must be
|
||||
|
|
|
|||
|
|
@ -144,3 +144,30 @@ func ReadFinalizedL2BlockNumber(db ethdb.Reader) *uint64 {
|
|||
finalizedL2BlockNumber := number.Uint64()
|
||||
return &finalizedL2BlockNumber
|
||||
}
|
||||
|
||||
// WriteLastFinalizedBatchIndex stores the last finalized batch index in the database.
|
||||
func WriteLastFinalizedBatchIndex(db ethdb.KeyValueWriter, lastFinalizedBatchIndex uint64) {
|
||||
value := big.NewInt(0).SetUint64(lastFinalizedBatchIndex).Bytes()
|
||||
if err := db.Put(lastFinalizedBatchIndexKey, value); err != nil {
|
||||
log.Crit("failed to store last finalized batch index for rollup event", "batch index", lastFinalizedBatchIndex, "value", value, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ReadLastFinalizedBatchIndex fetches the last finalized batch index from the database.
|
||||
func ReadLastFinalizedBatchIndex(db ethdb.Reader) *uint64 {
|
||||
data, err := db.Get(lastFinalizedBatchIndexKey)
|
||||
if err != nil && isNotFoundErr(err) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
log.Crit("failed to read last finalized batch index from database", "key", lastFinalizedBatchIndexKey, "err", err)
|
||||
}
|
||||
|
||||
number := new(big.Int).SetBytes(data)
|
||||
if !number.IsUint64() {
|
||||
log.Crit("unexpected finalized batch index in database", "data", data, "number", number)
|
||||
}
|
||||
|
||||
lastFinalizedBatchIndex := number.Uint64()
|
||||
return &lastFinalizedBatchIndex
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,32 @@ func TestFinalizedL2BlockNumber(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLastFinalizedBatchIndex(t *testing.T) {
|
||||
batchIndxes := []uint64{
|
||||
1,
|
||||
1 << 2,
|
||||
1 << 8,
|
||||
1 << 16,
|
||||
1 << 32,
|
||||
}
|
||||
|
||||
db := NewMemoryDatabase()
|
||||
|
||||
// read non-existing value
|
||||
if got := ReadLastFinalizedBatchIndex(db); got != nil {
|
||||
t.Fatal("Expected nil for non-existing value", "got", *got)
|
||||
}
|
||||
|
||||
for _, num := range batchIndxes {
|
||||
WriteLastFinalizedBatchIndex(db, num)
|
||||
got := ReadLastFinalizedBatchIndex(db)
|
||||
|
||||
if *got != num {
|
||||
t.Fatal("Batch index mismatch", "expected", num, "got", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalizedBatchMeta(t *testing.T) {
|
||||
batches := []*FinalizedBatchMeta{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ var (
|
|||
batchChunkRangesPrefix = []byte("R-bcr")
|
||||
batchMetaPrefix = []byte("R-bm")
|
||||
finalizedL2BlockNumberKey = []byte("R-finalized")
|
||||
lastFinalizedBatchIndexKey = []byte("R-finalizedBatchIndex")
|
||||
|
||||
// Row consumption
|
||||
rowConsumptionPrefix = []byte("rc") // rowConsumptionPrefix + hash -> row consumption by block
|
||||
|
|
|
|||
28
go.mod
28
go.mod
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/scroll-tech/go-ethereum
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
|
||||
|
|
@ -40,9 +40,9 @@ require (
|
|||
github.com/hashicorp/go-bexpr v0.1.10
|
||||
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3
|
||||
github.com/holiman/uint256 v1.2.3
|
||||
github.com/holiman/uint256 v1.2.4
|
||||
github.com/huin/goupnp v1.3.0
|
||||
github.com/iden3/go-iden3-crypto v0.0.12
|
||||
github.com/iden3/go-iden3-crypto v0.0.15
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.4.0
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
|
||||
github.com/jackpal/go-nat-pmp v1.0.2
|
||||
|
|
@ -57,20 +57,21 @@ require (
|
|||
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
|
||||
github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7
|
||||
github.com/rs/cors v1.7.0
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240727174557-66c0e75af163
|
||||
github.com/scroll-tech/zktrie v0.8.4
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||
github.com/status-im/keycard-go v0.2.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/supranational/blst v0.3.11
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
||||
github.com/tyler-smith/go-bip39 v1.1.0
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
go.uber.org/automaxprocs v1.5.2
|
||||
golang.org/x/crypto v0.14.0
|
||||
golang.org/x/crypto v0.17.0
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
|
||||
golang.org/x/sync v0.3.0
|
||||
golang.org/x/sys v0.13.0
|
||||
golang.org/x/text v0.13.0
|
||||
golang.org/x/sync v0.6.0
|
||||
golang.org/x/sys v0.17.0
|
||||
golang.org/x/text v0.14.0
|
||||
golang.org/x/time v0.3.0
|
||||
golang.org/x/tools v0.13.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
|
|
@ -81,7 +82,6 @@ require (
|
|||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
||||
github.com/DataDog/zstd v1.4.5 // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect
|
||||
|
|
@ -92,7 +92,8 @@ require (
|
|||
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect
|
||||
github.com/aws/smithy-go v1.15.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.7.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.12.0 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
|
||||
github.com/cockroachdb/redact v1.0.8 // indirect
|
||||
|
|
@ -105,7 +106,7 @@ require (
|
|||
github.com/deepmap/oapi-codegen v1.6.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
|
||||
github.com/go-ole/go-ole v1.2.5 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
|
|
@ -134,11 +135,12 @@ require (
|
|||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.10.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
|
|
|
|||
67
go.sum
67
go.sum
|
|
@ -35,14 +35,18 @@ github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOv
|
|||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 h1:8q4SaHjFsClSvuVne0ID/5Ka8u3fcIHyqkLjcFpNRHQ=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
|
||||
github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
|
||||
|
|
@ -53,8 +57,6 @@ github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4K
|
|||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
|
||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
|
|
@ -97,11 +99,12 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
|
||||
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||
github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
|
||||
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
||||
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
|
||||
|
|
@ -121,6 +124,7 @@ github.com/cloudflare/cloudflare-go v0.79.0/go.mod h1:gkHQf9xEubaQPEuerBuoinR9P8
|
|||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4=
|
||||
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
|
||||
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
|
||||
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
|
||||
github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y=
|
||||
github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac=
|
||||
|
|
@ -154,7 +158,6 @@ github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI=
|
||||
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
|
||||
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
|
|
@ -170,6 +173,7 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwu
|
|||
github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo=
|
||||
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
|
||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||
github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
|
||||
github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||
|
|
@ -224,8 +228,9 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
|
|||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
|
||||
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
|
||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||
|
|
@ -334,6 +339,7 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
|
|||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM=
|
||||
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
|
|
@ -344,16 +350,16 @@ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZ
|
|||
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
|
||||
github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o=
|
||||
github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw=
|
||||
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
|
||||
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
|
||||
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
|
||||
github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||
github.com/iden3/go-iden3-crypto v0.0.12 h1:dXZF+R9iI07DK49LHX/EKC3jTa0O2z+TUyvxjGK7V38=
|
||||
github.com/iden3/go-iden3-crypto v0.0.12/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
|
||||
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k=
|
||||
|
|
@ -497,6 +503,7 @@ github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssy
|
|||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
@ -505,6 +512,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
|
|
@ -534,8 +542,9 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
|||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
|
|
@ -543,11 +552,13 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
|
|||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240727174557-66c0e75af163 h1:Cz0YXihFVms8pdtNNkV2PBVacZxE24yyAFSalNf8xtg=
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240727174557-66c0e75af163/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs=
|
||||
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/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
|
|
@ -569,8 +580,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
|
||||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
|
|
@ -606,6 +617,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
||||
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
|
|
@ -624,9 +637,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
|||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
|
|
@ -700,7 +712,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
|
|
@ -723,8 +734,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
|
@ -779,18 +790,18 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
|
|
@ -803,8 +814,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,123 +0,0 @@
|
|||
package rollup_sync_service
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/core/types"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
const batchHeaderVersion = 0
|
||||
|
||||
// BatchHeader contains batch header info to be committed.
|
||||
type BatchHeader struct {
|
||||
// Encoded in BatchHeaderV0Codec
|
||||
version uint8
|
||||
batchIndex uint64
|
||||
l1MessagePopped uint64
|
||||
totalL1MessagePopped uint64
|
||||
dataHash common.Hash
|
||||
parentBatchHash common.Hash
|
||||
skippedL1MessageBitmap []byte
|
||||
}
|
||||
|
||||
// NewBatchHeader creates a new BatchHeader
|
||||
func NewBatchHeader(version uint8, batchIndex, totalL1MessagePoppedBefore uint64, parentBatchHash common.Hash, chunks []*Chunk) (*BatchHeader, error) {
|
||||
// buffer for storing chunk hashes in order to compute the batch data hash
|
||||
var dataBytes []byte
|
||||
|
||||
// skipped L1 message bitmap, an array of 256-bit bitmaps
|
||||
var skippedBitmap []*big.Int
|
||||
|
||||
// the first queue index that belongs to this batch
|
||||
baseIndex := totalL1MessagePoppedBefore
|
||||
|
||||
// the next queue index that we need to process
|
||||
nextIndex := totalL1MessagePoppedBefore
|
||||
|
||||
for chunkID, chunk := range chunks {
|
||||
// build data hash
|
||||
totalL1MessagePoppedBeforeChunk := nextIndex
|
||||
chunkHash, err := chunk.Hash(totalL1MessagePoppedBeforeChunk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dataBytes = append(dataBytes, chunkHash.Bytes()...)
|
||||
|
||||
// build skip bitmap
|
||||
for blockID, block := range chunk.Blocks {
|
||||
for _, tx := range block.Transactions {
|
||||
if tx.Type != types.L1MessageTxType {
|
||||
continue
|
||||
}
|
||||
currentIndex := tx.Nonce
|
||||
|
||||
if currentIndex < nextIndex {
|
||||
return nil, fmt.Errorf("unexpected batch payload, expected queue index: %d, got: %d. Batch index: %d, chunk index in batch: %d, block index in chunk: %d, block hash: %v, transaction hash: %v", nextIndex, currentIndex, batchIndex, chunkID, blockID, block.Header.Hash(), tx.TxHash)
|
||||
}
|
||||
|
||||
// mark skipped messages
|
||||
for skippedIndex := nextIndex; skippedIndex < currentIndex; skippedIndex++ {
|
||||
quo := int((skippedIndex - baseIndex) / 256)
|
||||
rem := int((skippedIndex - baseIndex) % 256)
|
||||
for len(skippedBitmap) <= quo {
|
||||
bitmap := big.NewInt(0)
|
||||
skippedBitmap = append(skippedBitmap, bitmap)
|
||||
}
|
||||
skippedBitmap[quo].SetBit(skippedBitmap[quo], rem, 1)
|
||||
}
|
||||
|
||||
// process included message
|
||||
quo := int((currentIndex - baseIndex) / 256)
|
||||
for len(skippedBitmap) <= quo {
|
||||
bitmap := big.NewInt(0)
|
||||
skippedBitmap = append(skippedBitmap, bitmap)
|
||||
}
|
||||
|
||||
nextIndex = currentIndex + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compute data hash
|
||||
dataHash := crypto.Keccak256Hash(dataBytes)
|
||||
|
||||
// compute skipped bitmap
|
||||
bitmapBytes := make([]byte, len(skippedBitmap)*32)
|
||||
for ii, num := range skippedBitmap {
|
||||
bytes := num.Bytes()
|
||||
padding := 32 - len(bytes)
|
||||
copy(bitmapBytes[32*ii+padding:], bytes)
|
||||
}
|
||||
|
||||
return &BatchHeader{
|
||||
version: version,
|
||||
batchIndex: batchIndex,
|
||||
l1MessagePopped: nextIndex - totalL1MessagePoppedBefore,
|
||||
totalL1MessagePopped: nextIndex,
|
||||
dataHash: dataHash,
|
||||
parentBatchHash: parentBatchHash,
|
||||
skippedL1MessageBitmap: bitmapBytes,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Encode encodes the BatchHeader into RollupV2 BatchHeaderV0Codec Encoding.
|
||||
func (b *BatchHeader) Encode() []byte {
|
||||
batchBytes := make([]byte, 89+len(b.skippedL1MessageBitmap))
|
||||
batchBytes[0] = b.version
|
||||
binary.BigEndian.PutUint64(batchBytes[1:], b.batchIndex)
|
||||
binary.BigEndian.PutUint64(batchBytes[9:], b.l1MessagePopped)
|
||||
binary.BigEndian.PutUint64(batchBytes[17:], b.totalL1MessagePopped)
|
||||
copy(batchBytes[25:], b.dataHash[:])
|
||||
copy(batchBytes[57:], b.parentBatchHash[:])
|
||||
copy(batchBytes[89:], b.skippedL1MessageBitmap[:])
|
||||
return batchBytes
|
||||
}
|
||||
|
||||
// Hash calculates the hash of the batch header.
|
||||
func (b *BatchHeader) Hash() common.Hash {
|
||||
return crypto.Keccak256Hash(b.Encode())
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
package rollup_sync_service
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
"github.com/scroll-tech/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
const blockContextByteSize = 60
|
||||
|
||||
// WrappedBlock contains the block's Header, Transactions and WithdrawTrieRoot hash.
|
||||
type WrappedBlock struct {
|
||||
Header *types.Header `json:"header"`
|
||||
// Transactions is only used for recover types.Transactions, the from of types.TransactionData field is missing.
|
||||
Transactions []*types.TransactionData `json:"transactions"`
|
||||
WithdrawRoot common.Hash `json:"withdraw_trie_root,omitempty"`
|
||||
}
|
||||
|
||||
// BlockContext represents the essential data of a block in the ScrollChain.
|
||||
// It provides an overview of block attributes including hash values, block numbers, gas details, and transaction counts.
|
||||
type BlockContext struct {
|
||||
BlockHash common.Hash
|
||||
ParentHash common.Hash
|
||||
BlockNumber uint64
|
||||
Timestamp uint64
|
||||
BaseFee *big.Int
|
||||
GasLimit uint64
|
||||
NumTransactions uint16
|
||||
NumL1Messages uint16
|
||||
}
|
||||
|
||||
// numL1Messages returns the number of L1 messages in this block.
|
||||
// This number is the sum of included and skipped L1 messages.
|
||||
func (w *WrappedBlock) numL1Messages(totalL1MessagePoppedBefore uint64) uint64 {
|
||||
var lastQueueIndex *uint64
|
||||
for _, txData := range w.Transactions {
|
||||
if txData.Type == types.L1MessageTxType {
|
||||
lastQueueIndex = &txData.Nonce
|
||||
}
|
||||
}
|
||||
if lastQueueIndex == nil {
|
||||
return 0
|
||||
}
|
||||
// note: last queue index included before this block is totalL1MessagePoppedBefore - 1
|
||||
// TODO: cache results
|
||||
return *lastQueueIndex - totalL1MessagePoppedBefore + 1
|
||||
}
|
||||
|
||||
// Encode encodes the WrappedBlock into RollupV2 BlockContext Encoding.
|
||||
func (w *WrappedBlock) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error) {
|
||||
bytes := make([]byte, 60)
|
||||
|
||||
if !w.Header.Number.IsUint64() {
|
||||
return nil, errors.New("block number is not uint64")
|
||||
}
|
||||
|
||||
// note: numL1Messages includes skipped messages
|
||||
numL1Messages := w.numL1Messages(totalL1MessagePoppedBefore)
|
||||
if numL1Messages > math.MaxUint16 {
|
||||
return nil, errors.New("number of L1 messages exceeds max uint16")
|
||||
}
|
||||
|
||||
// note: numTransactions includes skipped messages
|
||||
numL2Transactions := w.numL2Transactions()
|
||||
numTransactions := numL1Messages + numL2Transactions
|
||||
if numTransactions > math.MaxUint16 {
|
||||
return nil, errors.New("number of transactions exceeds max uint16")
|
||||
}
|
||||
|
||||
binary.BigEndian.PutUint64(bytes[0:], w.Header.Number.Uint64())
|
||||
binary.BigEndian.PutUint64(bytes[8:], w.Header.Time)
|
||||
// TODO: [16:47] Currently, baseFee is 0, because we disable EIP-1559.
|
||||
binary.BigEndian.PutUint64(bytes[48:], w.Header.GasLimit)
|
||||
binary.BigEndian.PutUint16(bytes[56:], uint16(numTransactions))
|
||||
binary.BigEndian.PutUint16(bytes[58:], uint16(numL1Messages))
|
||||
|
||||
return bytes, nil
|
||||
}
|
||||
|
||||
func txsToTxsData(txs types.Transactions) []*types.TransactionData {
|
||||
txsData := make([]*types.TransactionData, len(txs))
|
||||
for i, tx := range txs {
|
||||
v, r, s := tx.RawSignatureValues()
|
||||
|
||||
nonce := tx.Nonce()
|
||||
|
||||
// We need QueueIndex in `NewBatchHeader`. However, `TransactionData`
|
||||
// does not have this field. Since `L1MessageTx` do not have a nonce,
|
||||
// we reuse this field for storing the queue index.
|
||||
if msg := tx.AsL1MessageTx(); msg != nil {
|
||||
nonce = msg.QueueIndex
|
||||
}
|
||||
|
||||
txsData[i] = &types.TransactionData{
|
||||
Type: tx.Type(),
|
||||
TxHash: tx.Hash().String(),
|
||||
Nonce: nonce,
|
||||
ChainId: (*hexutil.Big)(tx.ChainId()),
|
||||
Gas: tx.Gas(),
|
||||
GasPrice: (*hexutil.Big)(tx.GasPrice()),
|
||||
To: tx.To(),
|
||||
Value: (*hexutil.Big)(tx.Value()),
|
||||
Data: hexutil.Encode(tx.Data()),
|
||||
IsCreate: tx.To() == nil,
|
||||
V: (*hexutil.Big)(v),
|
||||
R: (*hexutil.Big)(r),
|
||||
S: (*hexutil.Big)(s),
|
||||
}
|
||||
}
|
||||
return txsData
|
||||
}
|
||||
|
||||
func convertTxDataToRLPEncoding(txData *types.TransactionData) ([]byte, error) {
|
||||
data, err := hexutil.Decode(txData.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode txData.Data: %s, err: %w", txData.Data, err)
|
||||
}
|
||||
|
||||
tx := types.NewTx(&types.LegacyTx{
|
||||
Nonce: txData.Nonce,
|
||||
To: txData.To,
|
||||
Value: txData.Value.ToInt(),
|
||||
Gas: txData.Gas,
|
||||
GasPrice: txData.GasPrice.ToInt(),
|
||||
Data: data,
|
||||
V: txData.V.ToInt(),
|
||||
R: txData.R.ToInt(),
|
||||
S: txData.S.ToInt(),
|
||||
})
|
||||
|
||||
rlpTxData, err := tx.MarshalBinary()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal binary of the tx: %+v, err: %w", tx, err)
|
||||
}
|
||||
|
||||
return rlpTxData, nil
|
||||
}
|
||||
|
||||
func (w *WrappedBlock) numL2Transactions() uint64 {
|
||||
var count uint64
|
||||
for _, txData := range w.Transactions {
|
||||
if txData.Type != types.L1MessageTxType {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func decodeBlockContext(encodedBlockContext []byte) (*BlockContext, error) {
|
||||
if len(encodedBlockContext) != blockContextByteSize {
|
||||
return nil, errors.New("block encoding is not 60 bytes long")
|
||||
}
|
||||
|
||||
return &BlockContext{
|
||||
BlockNumber: binary.BigEndian.Uint64(encodedBlockContext[0:8]),
|
||||
Timestamp: binary.BigEndian.Uint64(encodedBlockContext[8:16]),
|
||||
GasLimit: binary.BigEndian.Uint64(encodedBlockContext[48:56]),
|
||||
NumTransactions: binary.BigEndian.Uint16(encodedBlockContext[56:58]),
|
||||
NumL1Messages: binary.BigEndian.Uint16(encodedBlockContext[58:60]),
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
package rollup_sync_service
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/core/rawdb"
|
||||
"github.com/scroll-tech/go-ethereum/core/types"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
// Chunk contains blocks to be encoded
|
||||
type Chunk struct {
|
||||
Blocks []*WrappedBlock `json:"blocks"`
|
||||
}
|
||||
|
||||
// NumL1Messages returns the number of L1 messages in this chunk.
|
||||
// This number is the sum of included and skipped L1 messages.
|
||||
func (c *Chunk) NumL1Messages(totalL1MessagePoppedBefore uint64) uint64 {
|
||||
var numL1Messages uint64
|
||||
for _, block := range c.Blocks {
|
||||
numL1MessagesInBlock := block.numL1Messages(totalL1MessagePoppedBefore)
|
||||
numL1Messages += numL1MessagesInBlock
|
||||
totalL1MessagePoppedBefore += numL1MessagesInBlock
|
||||
}
|
||||
// TODO: cache results
|
||||
return numL1Messages
|
||||
}
|
||||
|
||||
// Encode encodes the Chunk into RollupV2 Chunk Encoding.
|
||||
func (c *Chunk) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error) {
|
||||
numBlocks := len(c.Blocks)
|
||||
|
||||
if numBlocks > 255 {
|
||||
return nil, errors.New("number of blocks exceeds 1 byte")
|
||||
}
|
||||
if numBlocks == 0 {
|
||||
return nil, errors.New("number of blocks is 0")
|
||||
}
|
||||
|
||||
var chunkBytes []byte
|
||||
chunkBytes = append(chunkBytes, byte(numBlocks))
|
||||
|
||||
var l2TxDataBytes []byte
|
||||
|
||||
for _, block := range c.Blocks {
|
||||
blockBytes, err := block.Encode(totalL1MessagePoppedBefore)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to encode block: %v", err)
|
||||
}
|
||||
totalL1MessagePoppedBefore += block.numL1Messages(totalL1MessagePoppedBefore)
|
||||
|
||||
if len(blockBytes) != 60 {
|
||||
return nil, fmt.Errorf("block encoding is not 60 bytes long %x", len(blockBytes))
|
||||
}
|
||||
|
||||
chunkBytes = append(chunkBytes, blockBytes...)
|
||||
|
||||
// Append rlp-encoded l2Txs
|
||||
for _, txData := range block.Transactions {
|
||||
if txData.Type == types.L1MessageTxType {
|
||||
continue
|
||||
}
|
||||
rlpTxData, err := convertTxDataToRLPEncoding(txData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var txLen [4]byte
|
||||
binary.BigEndian.PutUint32(txLen[:], uint32(len(rlpTxData)))
|
||||
l2TxDataBytes = append(l2TxDataBytes, txLen[:]...)
|
||||
l2TxDataBytes = append(l2TxDataBytes, rlpTxData...)
|
||||
}
|
||||
}
|
||||
|
||||
chunkBytes = append(chunkBytes, l2TxDataBytes...)
|
||||
|
||||
return chunkBytes, nil
|
||||
}
|
||||
|
||||
// Hash hashes the Chunk into RollupV2 Chunk Hash
|
||||
func (c *Chunk) Hash(totalL1MessagePoppedBefore uint64) (common.Hash, error) {
|
||||
chunkBytes, err := c.Encode(totalL1MessagePoppedBefore)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
numBlocks := chunkBytes[0]
|
||||
|
||||
// concatenate block contexts
|
||||
var dataBytes []byte
|
||||
for i := 0; i < int(numBlocks); i++ {
|
||||
// only the first 58 bytes of each BlockContext are needed for the hashing process
|
||||
dataBytes = append(dataBytes, chunkBytes[1+60*i:60*i+59]...)
|
||||
}
|
||||
|
||||
// concatenate l1 and l2 tx hashes
|
||||
for _, block := range c.Blocks {
|
||||
var l1TxHashes []byte
|
||||
var l2TxHashes []byte
|
||||
for _, txData := range block.Transactions {
|
||||
txHash := strings.TrimPrefix(txData.TxHash, "0x")
|
||||
hashBytes, err := hex.DecodeString(txHash)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
if txData.Type == types.L1MessageTxType {
|
||||
l1TxHashes = append(l1TxHashes, hashBytes...)
|
||||
} else {
|
||||
l2TxHashes = append(l2TxHashes, hashBytes...)
|
||||
}
|
||||
}
|
||||
dataBytes = append(dataBytes, l1TxHashes...)
|
||||
dataBytes = append(dataBytes, l2TxHashes...)
|
||||
}
|
||||
|
||||
hash := crypto.Keccak256Hash(dataBytes)
|
||||
return hash, nil
|
||||
}
|
||||
|
||||
// DecodeChunkBlockRanges decodes the provided chunks into a list of block ranges. Each chunk
|
||||
// contains information about multiple blocks, which are decoded and their ranges (from the
|
||||
// start block to the end block) are returned.
|
||||
func DecodeChunkBlockRanges(chunks [][]byte) ([]*rawdb.ChunkBlockRange, error) {
|
||||
var chunkBlockRanges []*rawdb.ChunkBlockRange
|
||||
for _, chunk := range chunks {
|
||||
if len(chunk) < 1 {
|
||||
return nil, fmt.Errorf("invalid chunk, length is less than 1")
|
||||
}
|
||||
|
||||
numBlocks := int(chunk[0])
|
||||
if len(chunk) < 1+numBlocks*blockContextByteSize {
|
||||
return nil, fmt.Errorf("chunk size doesn't match with numBlocks, byte length of chunk: %v, expected length: %v", len(chunk), 1+numBlocks*blockContextByteSize)
|
||||
}
|
||||
|
||||
blockContexts := make([]*BlockContext, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*blockContextByteSize // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + blockContextByteSize
|
||||
blockContext, err := decodeBlockContext(chunk[startIdx:endIdx])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blockContexts[i] = blockContext
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: blockContexts[0].BlockNumber,
|
||||
EndBlockNumber: blockContexts[len(blockContexts)-1].BlockNumber,
|
||||
})
|
||||
}
|
||||
return chunkBlockRanges, nil
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ func newL1Client(ctx context.Context, l1Client sync_service.EthClient, l1ChainId
|
|||
}
|
||||
|
||||
// fetcRollupEventsInRange retrieves and parses commit/revert/finalize rollup events between block numbers: [from, to].
|
||||
func (c *L1Client) fetchRollupEventsInRange(ctx context.Context, from, to uint64) ([]types.Log, error) {
|
||||
func (c *L1Client) fetchRollupEventsInRange(from, to uint64) ([]types.Log, error) {
|
||||
log.Trace("L1Client fetchRollupEventsInRange", "fromBlock", from, "toBlock", to)
|
||||
|
||||
query := ethereum.FilterQuery{
|
||||
|
|
@ -80,8 +80,8 @@ func (c *L1Client) fetchRollupEventsInRange(ctx context.Context, from, to uint64
|
|||
}
|
||||
|
||||
// getLatestFinalizedBlockNumber fetches the block number of the latest finalized block from the L1 chain.
|
||||
func (c *L1Client) getLatestFinalizedBlockNumber(ctx context.Context) (uint64, error) {
|
||||
header, err := c.client.HeaderByNumber(ctx, big.NewInt(int64(rpc.FinalizedBlockNumber)))
|
||||
func (c *L1Client) getLatestFinalizedBlockNumber() (uint64, error) {
|
||||
header, err := c.client.HeaderByNumber(c.ctx, big.NewInt(int64(rpc.FinalizedBlockNumber)))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@ func TestL1Client(t *testing.T) {
|
|||
l1Client, err := newL1Client(ctx, mockClient, 11155111, scrollChainAddress, scrollChainABI)
|
||||
require.NoError(t, err, "Failed to initialize L1Client")
|
||||
|
||||
blockNumber, err := l1Client.getLatestFinalizedBlockNumber(ctx)
|
||||
blockNumber, err := l1Client.getLatestFinalizedBlockNumber()
|
||||
assert.NoError(t, err, "Error getting latest confirmed block number")
|
||||
assert.Equal(t, uint64(36), blockNumber, "Unexpected block number")
|
||||
|
||||
logs, err := l1Client.fetchRollupEventsInRange(ctx, 0, blockNumber)
|
||||
logs, err := l1Client.fetchRollupEventsInRange(0, blockNumber)
|
||||
assert.NoError(t, err, "Error fetching rollup events in range")
|
||||
assert.Empty(t, logs, "Expected no logs from fetchRollupEventsInRange")
|
||||
}
|
||||
|
||||
type mockEthClient struct {
|
||||
commitBatchRLP []byte
|
||||
txRLP []byte
|
||||
}
|
||||
|
||||
func (m *mockEthClient) BlockNumber(ctx context.Context) (uint64, error) {
|
||||
|
|
@ -63,7 +63,7 @@ func (m *mockEthClient) SubscribeFilterLogs(ctx context.Context, query ethereum.
|
|||
|
||||
func (m *mockEthClient) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||
var tx types.Transaction
|
||||
if err := rlp.DecodeBytes(m.commitBatchRLP, &tx); err != nil {
|
||||
if err := rlp.DecodeBytes(m.txRLP, &tx); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
return &tx, false, nil
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ import (
|
|||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/scroll-tech/da-codec/encoding"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv0"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv1"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv2"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv3"
|
||||
"github.com/scroll-tech/go-ethereum/accounts/abi"
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/core"
|
||||
|
|
@ -149,7 +154,7 @@ func (s *RollupSyncService) Stop() {
|
|||
}
|
||||
|
||||
func (s *RollupSyncService) fetchRollupEvents() {
|
||||
latestConfirmed, err := s.client.getLatestFinalizedBlockNumber(s.ctx)
|
||||
latestConfirmed, err := s.client.getLatestFinalizedBlockNumber()
|
||||
if err != nil {
|
||||
log.Warn("failed to get latest confirmed block number", "err", err)
|
||||
return
|
||||
|
|
@ -169,7 +174,7 @@ func (s *RollupSyncService) fetchRollupEvents() {
|
|||
to = latestConfirmed
|
||||
}
|
||||
|
||||
logs, err := s.client.fetchRollupEventsInRange(s.ctx, from, to)
|
||||
logs, err := s.client.fetchRollupEventsInRange(from, to)
|
||||
if err != nil {
|
||||
log.Error("failed to fetch rollup events in range", "from block", from, "to block", to, "err", err)
|
||||
return
|
||||
|
|
@ -219,22 +224,56 @@ func (s *RollupSyncService) parseAndUpdateRollupEventLogs(logs []types.Log, endB
|
|||
batchIndex := event.BatchIndex.Uint64()
|
||||
log.Trace("found new FinalizeBatch event", "batch index", batchIndex)
|
||||
|
||||
parentBatchMeta, chunks, err := s.getLocalInfoForBatch(batchIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get local node info, batch index: %v, err: %w", batchIndex, err)
|
||||
lastFinalizedBatchIndex := rawdb.ReadLastFinalizedBatchIndex(s.db)
|
||||
|
||||
// After darwin, FinalizeBatch event emitted every bundle, which contains multiple batches.
|
||||
// Therefore there are a range of finalized batches need to be saved into db.
|
||||
//
|
||||
// The range logic also applies to the batches before darwin when FinalizeBatch event emitted
|
||||
// per single batch. In this situation, `batchIndex` just equals to `*lastFinalizedBatchIndex + 1`
|
||||
// and only one batch is processed through the for loop.
|
||||
startBatchIndex := batchIndex
|
||||
if lastFinalizedBatchIndex != nil {
|
||||
startBatchIndex = *lastFinalizedBatchIndex + 1
|
||||
} else {
|
||||
log.Warn("got nil when reading last finalized batch index. This should happen only once.")
|
||||
}
|
||||
|
||||
endBlock, finalizedBatchMeta, err := validateBatch(event, parentBatchMeta, chunks, s.stack)
|
||||
parentBatchMeta := &rawdb.FinalizedBatchMeta{}
|
||||
if startBatchIndex > 0 {
|
||||
parentBatchMeta = rawdb.ReadFinalizedBatchMeta(s.db, startBatchIndex-1)
|
||||
}
|
||||
|
||||
var highestFinalizedBlockNumber uint64
|
||||
batchWriter := s.db.NewBatch()
|
||||
for index := startBatchIndex; index <= batchIndex; index++ {
|
||||
chunks, err := s.getLocalChunksForBatch(index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get local node info, batch index: %v, err: %w", index, err)
|
||||
}
|
||||
|
||||
endBlock, finalizedBatchMeta, err := validateBatch(index, event, parentBatchMeta, chunks, s.bc.Config(), s.stack)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fatal: validateBatch failed: finalize event: %v, err: %w", event, err)
|
||||
}
|
||||
|
||||
rawdb.WriteFinalizedL2BlockNumber(s.db, endBlock)
|
||||
rawdb.WriteFinalizedBatchMeta(s.db, batchIndex, finalizedBatchMeta)
|
||||
rawdb.WriteFinalizedBatchMeta(batchWriter, index, finalizedBatchMeta)
|
||||
highestFinalizedBlockNumber = endBlock
|
||||
parentBatchMeta = finalizedBatchMeta
|
||||
|
||||
if batchIndex%100 == 0 {
|
||||
log.Info("finalized batch progress", "batch index", batchIndex, "finalized l2 block height", endBlock)
|
||||
if index%100 == 0 {
|
||||
log.Info("finalized batch progress", "batch index", index, "finalized l2 block height", endBlock)
|
||||
}
|
||||
}
|
||||
|
||||
if err := batchWriter.Write(); err != nil {
|
||||
log.Error("fatal: failed to batch write finalized batch meta to database", "startBatchIndex", startBatchIndex, "endBatchIndex", batchIndex,
|
||||
"batchCount", batchIndex-startBatchIndex+1, "highestFinalizedBlockNumber", highestFinalizedBlockNumber, "err", err)
|
||||
return fmt.Errorf("failed to batch write finalized batch meta to database: %w", err)
|
||||
}
|
||||
rawdb.WriteFinalizedL2BlockNumber(s.db, highestFinalizedBlockNumber)
|
||||
rawdb.WriteLastFinalizedBatchIndex(s.db, batchIndex)
|
||||
log.Debug("write finalized l2 block number", "batch index", batchIndex, "finalized l2 block height", highestFinalizedBlockNumber)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown event, topic: %v, tx hash: %v", vLog.Topics[0].Hex(), vLog.TxHash.Hex())
|
||||
|
|
@ -248,17 +287,17 @@ func (s *RollupSyncService) parseAndUpdateRollupEventLogs(logs []types.Log, endB
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *RollupSyncService) getLocalInfoForBatch(batchIndex uint64) (*rawdb.FinalizedBatchMeta, []*Chunk, error) {
|
||||
func (s *RollupSyncService) getLocalChunksForBatch(batchIndex uint64) ([]*encoding.Chunk, error) {
|
||||
chunkBlockRanges := rawdb.ReadBatchChunkRanges(s.db, batchIndex)
|
||||
if len(chunkBlockRanges) == 0 {
|
||||
return nil, nil, fmt.Errorf("failed to get batch chunk ranges, empty chunk block ranges")
|
||||
return nil, fmt.Errorf("failed to get batch chunk ranges, empty chunk block ranges")
|
||||
}
|
||||
|
||||
endBlockNumber := chunkBlockRanges[len(chunkBlockRanges)-1].EndBlockNumber
|
||||
for i := 0; i < defaultMaxRetries; i++ {
|
||||
if s.ctx.Err() != nil {
|
||||
log.Info("Context canceled", "reason", s.ctx.Err())
|
||||
return nil, nil, s.ctx.Err()
|
||||
return nil, s.ctx.Err()
|
||||
}
|
||||
|
||||
localSyncedBlockHeight := s.bc.CurrentBlock().Number.Uint64()
|
||||
|
|
@ -273,24 +312,24 @@ func (s *RollupSyncService) getLocalInfoForBatch(batchIndex uint64) (*rawdb.Fina
|
|||
|
||||
localSyncedBlockHeight := s.bc.CurrentBlock().Number.Uint64()
|
||||
if localSyncedBlockHeight < endBlockNumber {
|
||||
return nil, nil, fmt.Errorf("local node is not synced up to the required block height: %v, local synced block height: %v", endBlockNumber, localSyncedBlockHeight)
|
||||
return nil, fmt.Errorf("local node is not synced up to the required block height: %v, local synced block height: %v", endBlockNumber, localSyncedBlockHeight)
|
||||
}
|
||||
|
||||
chunks := make([]*Chunk, len(chunkBlockRanges))
|
||||
chunks := make([]*encoding.Chunk, len(chunkBlockRanges))
|
||||
for i, cr := range chunkBlockRanges {
|
||||
chunks[i] = &Chunk{Blocks: make([]*WrappedBlock, cr.EndBlockNumber-cr.StartBlockNumber+1)}
|
||||
chunks[i] = &encoding.Chunk{Blocks: make([]*encoding.Block, cr.EndBlockNumber-cr.StartBlockNumber+1)}
|
||||
for j := cr.StartBlockNumber; j <= cr.EndBlockNumber; j++ {
|
||||
block := s.bc.GetBlockByNumber(j)
|
||||
if block == nil {
|
||||
return nil, nil, fmt.Errorf("failed to get block by number: %v", i)
|
||||
return nil, fmt.Errorf("failed to get block by number: %v", i)
|
||||
}
|
||||
txData := txsToTxsData(block.Transactions())
|
||||
txData := encoding.TxsToTxsData(block.Transactions())
|
||||
state, err := s.bc.StateAt(block.Root())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get block state, block: %v, err: %w", block.Hash().Hex(), err)
|
||||
return nil, fmt.Errorf("failed to get block state, block: %v, err: %w", block.Hash().Hex(), err)
|
||||
}
|
||||
withdrawRoot := withdrawtrie.ReadWTRSlot(rcfg.L2MessageQueueAddress, state)
|
||||
chunks[i].Blocks[j-cr.StartBlockNumber] = &WrappedBlock{
|
||||
chunks[i].Blocks[j-cr.StartBlockNumber] = &encoding.Block{
|
||||
Header: block.Header(),
|
||||
Transactions: txData,
|
||||
WithdrawRoot: withdrawRoot,
|
||||
|
|
@ -298,13 +337,7 @@ func (s *RollupSyncService) getLocalInfoForBatch(batchIndex uint64) (*rawdb.Fina
|
|||
}
|
||||
}
|
||||
|
||||
// get metadata of parent batch: default to genesis batch metadata.
|
||||
parentBatchMeta := &rawdb.FinalizedBatchMeta{}
|
||||
if batchIndex > 0 {
|
||||
parentBatchMeta = rawdb.ReadFinalizedBatchMeta(s.db, batchIndex-1)
|
||||
}
|
||||
|
||||
return parentBatchMeta, chunks, nil
|
||||
return chunks, nil
|
||||
}
|
||||
|
||||
func (s *RollupSyncService) getChunkRanges(batchIndex uint64, vLog *types.Log) ([]*rawdb.ChunkBlockRange, error) {
|
||||
|
|
@ -321,6 +354,10 @@ func (s *RollupSyncService) getChunkRanges(batchIndex uint64, vLog *types.Log) (
|
|||
return nil, fmt.Errorf("failed to get block by hash, block number: %v, block hash: %v, err: %w", vLog.BlockNumber, vLog.BlockHash.Hex(), err)
|
||||
}
|
||||
|
||||
if block == nil {
|
||||
return nil, fmt.Errorf("failed to get block by hash, block not found, block number: %v, block hash: %v", vLog.BlockNumber, vLog.BlockHash.Hex())
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, txInBlock := range block.Transactions() {
|
||||
if txInBlock.Hash() == vLog.TxHash {
|
||||
|
|
@ -354,68 +391,140 @@ func (s *RollupSyncService) decodeChunkBlockRanges(txData []byte) ([]*rawdb.Chun
|
|||
return nil, fmt.Errorf("failed to unpack transaction data using ABI, tx data: %v, err: %w", txData, err)
|
||||
}
|
||||
|
||||
if method.Name == "commitBatch" {
|
||||
type commitBatchArgs struct {
|
||||
Version uint8
|
||||
ParentBatchHeader []byte
|
||||
Chunks [][]byte
|
||||
SkippedL1MessageBitmap []byte
|
||||
}
|
||||
|
||||
var args commitBatchArgs
|
||||
err = method.Inputs.Copy(&args, values)
|
||||
if err != nil {
|
||||
if err = method.Inputs.Copy(&args, values); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode calldata into commitBatch args, values: %+v, err: %w", values, err)
|
||||
}
|
||||
|
||||
if args.Version != batchHeaderVersion {
|
||||
return nil, fmt.Errorf("unexpected batch version, expected: %v, got: %v", batchHeaderVersion, args.Version)
|
||||
return decodeBlockRangesFromEncodedChunks(encoding.CodecVersion(args.Version), args.Chunks)
|
||||
} else if method.Name == "commitBatchWithBlobProof" {
|
||||
type commitBatchWithBlobProofArgs struct {
|
||||
Version uint8
|
||||
ParentBatchHeader []byte
|
||||
Chunks [][]byte
|
||||
SkippedL1MessageBitmap []byte
|
||||
BlobDataProof []byte
|
||||
}
|
||||
|
||||
return DecodeChunkBlockRanges(args.Chunks)
|
||||
var args commitBatchWithBlobProofArgs
|
||||
if err = method.Inputs.Copy(&args, values); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode calldata into commitBatchWithBlobProofArgs args, values: %+v, err: %w", values, err)
|
||||
}
|
||||
|
||||
return decodeBlockRangesFromEncodedChunks(encoding.CodecVersion(args.Version), args.Chunks)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unexpected method name: %v", method.Name)
|
||||
}
|
||||
|
||||
// validateBatch verifies the consistency between the L1 contract and L2 node data.
|
||||
// It performs the following checks:
|
||||
// 1. Recalculates the batch hash locally
|
||||
// 2. Compares local state root, local withdraw root, and locally calculated batch hash with L1 data (for the last batch only when "finalize by bundle")
|
||||
//
|
||||
// The function will terminate the node and exit if any consistency check fails.
|
||||
// It returns the number of the end block, a finalized batch meta data, and an error if any.
|
||||
func validateBatch(event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.FinalizedBatchMeta, chunks []*Chunk, stack *node.Node) (uint64, *rawdb.FinalizedBatchMeta, error) {
|
||||
//
|
||||
// Parameters:
|
||||
// - batchIndex: batch index of the validated batch
|
||||
// - event: L1 finalize batch event data
|
||||
// - parentBatchMeta: metadata of the parent batch
|
||||
// - chunks: slice of chunk data for the current batch
|
||||
// - chainCfg: chain configuration to identify the codec version
|
||||
// - stack: node stack to terminate the node in case of inconsistency
|
||||
//
|
||||
// Returns:
|
||||
// - uint64: the end block height of the batch
|
||||
// - *rawdb.FinalizedBatchMeta: finalized batch metadata
|
||||
// - error: any error encountered during validation
|
||||
//
|
||||
// Note: This function is compatible with both "finalize by batch" and "finalize by bundle" methods.
|
||||
// In "finalize by bundle", only the last batch of each bundle is fully verified.
|
||||
// This check still ensures the correctness of all batch hashes in the bundle due to the parent-child relationship between batch hashes.
|
||||
func validateBatch(batchIndex uint64, event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.FinalizedBatchMeta, chunks []*encoding.Chunk, chainCfg *params.ChainConfig, stack *node.Node) (uint64, *rawdb.FinalizedBatchMeta, error) {
|
||||
if len(chunks) == 0 {
|
||||
return 0, nil, fmt.Errorf("invalid argument: length of chunks is 0, batch index: %v", event.BatchIndex.Uint64())
|
||||
return 0, nil, fmt.Errorf("invalid argument: length of chunks is 0, batch index: %v", batchIndex)
|
||||
}
|
||||
|
||||
startChunk := chunks[0]
|
||||
if len(startChunk.Blocks) == 0 {
|
||||
return 0, nil, fmt.Errorf("invalid argument: block count of start chunk is 0, batch index: %v", event.BatchIndex.Uint64())
|
||||
return 0, nil, fmt.Errorf("invalid argument: block count of start chunk is 0, batch index: %v", batchIndex)
|
||||
}
|
||||
startBlock := startChunk.Blocks[0]
|
||||
|
||||
endChunk := chunks[len(chunks)-1]
|
||||
if len(endChunk.Blocks) == 0 {
|
||||
return 0, nil, fmt.Errorf("invalid argument: block count of end chunk is 0, batch index: %v", event.BatchIndex.Uint64())
|
||||
return 0, nil, fmt.Errorf("invalid argument: block count of end chunk is 0, batch index: %v", batchIndex)
|
||||
}
|
||||
endBlock := endChunk.Blocks[len(endChunk.Blocks)-1]
|
||||
|
||||
// Note: All params of batch are calculated locally based on the block data.
|
||||
batch := &encoding.Batch{
|
||||
Index: batchIndex,
|
||||
TotalL1MessagePoppedBefore: parentBatchMeta.TotalL1MessagePopped,
|
||||
ParentBatchHash: parentBatchMeta.BatchHash,
|
||||
Chunks: chunks,
|
||||
}
|
||||
|
||||
var localBatchHash common.Hash
|
||||
if startBlock.Header.Number.Uint64() == 0 || !chainCfg.IsBernoulli(startBlock.Header.Number) { // codecv0: genesis batch or batches before Bernoulli
|
||||
daBatch, err := codecv0.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv0 DA batch, batch index: %v, err: %w", batchIndex, err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
} else if !chainCfg.IsCurie(startBlock.Header.Number) { // codecv1: batches after Bernoulli and before Curie
|
||||
daBatch, err := codecv1.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv1 DA batch, batch index: %v, err: %w", batchIndex, err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
} else if !chainCfg.IsDarwin(startBlock.Header.Number, startBlock.Header.Time) { // codecv2: batches after Curie and before Darwin
|
||||
daBatch, err := codecv2.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv2 DA batch, batch index: %v, err: %w", batchIndex, err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
} else { // codecv3: batches after Darwin
|
||||
daBatch, err := codecv3.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv3 DA batch, batch index: %v, err: %w", batchIndex, err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
}
|
||||
|
||||
localStateRoot := endBlock.Header.Root
|
||||
localWithdrawRoot := endBlock.WithdrawRoot
|
||||
|
||||
// Note: If the state root, withdraw root, and batch headers match, this ensures the consistency of blocks and transactions
|
||||
// (including skipped transactions) between L1 and L2.
|
||||
//
|
||||
// Only check when batch index matches the index of the event. This is compatible with both "finalize by batch" and "finalize by bundle":
|
||||
// - finalize by batch: check all batches
|
||||
// - finalize by bundle: check the last batch, because only one event (containing the info of the last batch) is emitted per bundle
|
||||
if batchIndex == event.BatchIndex.Uint64() {
|
||||
if localStateRoot != event.StateRoot {
|
||||
log.Error("State root mismatch", "batch index", event.BatchIndex.Uint64(), "start block", startBlock.Header.Number.Uint64(), "end block", endBlock.Header.Number.Uint64(), "parent batch hash", parentBatchMeta.BatchHash.Hex(), "l1 finalized state root", event.StateRoot.Hex(), "l2 state root", localStateRoot.Hex())
|
||||
stack.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
localWithdrawRoot := endBlock.WithdrawRoot
|
||||
if localWithdrawRoot != event.WithdrawRoot {
|
||||
log.Error("Withdraw root mismatch", "batch index", event.BatchIndex.Uint64(), "start block", startBlock.Header.Number.Uint64(), "end block", endBlock.Header.Number.Uint64(), "parent batch hash", parentBatchMeta.BatchHash.Hex(), "l1 finalized withdraw root", event.WithdrawRoot.Hex(), "l2 withdraw root", localWithdrawRoot.Hex())
|
||||
stack.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Note: All params for NewBatchHeader are calculated locally based on the block data.
|
||||
batchHeader, err := NewBatchHeader(batchHeaderVersion, event.BatchIndex.Uint64(), parentBatchMeta.TotalL1MessagePopped, parentBatchMeta.BatchHash, chunks)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to construct batch header, batch index: %v, err: %w", event.BatchIndex.Uint64(), err)
|
||||
}
|
||||
|
||||
// Note: If the batch headers match, this ensures the consistency of blocks and transactions
|
||||
// (including skipped transactions) between L1 and L2.
|
||||
localBatchHash := batchHeader.Hash()
|
||||
// Verify batch hash
|
||||
// This check ensures the correctness of all batch hashes in the bundle
|
||||
// due to the parent-child relationship between batch hashes
|
||||
if localBatchHash != event.BatchHash {
|
||||
log.Error("Batch hash mismatch", "batch index", event.BatchIndex.Uint64(), "start block", startBlock.Header.Number.Uint64(), "end block", endBlock.Header.Number.Uint64(), "parent batch hash", parentBatchMeta.BatchHash.Hex(), "parent TotalL1MessagePopped", parentBatchMeta.TotalL1MessagePopped, "l1 finalized batch hash", event.BatchHash.Hex(), "l2 batch hash", localBatchHash.Hex())
|
||||
chunksJson, err := json.Marshal(chunks)
|
||||
|
|
@ -426,6 +535,7 @@ func validateBatch(event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.Finalized
|
|||
stack.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
totalL1MessagePopped := parentBatchMeta.TotalL1MessagePopped
|
||||
for _, chunk := range chunks {
|
||||
|
|
@ -439,3 +549,94 @@ func validateBatch(event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.Finalized
|
|||
}
|
||||
return endBlock.Header.Number.Uint64(), finalizedBatchMeta, nil
|
||||
}
|
||||
|
||||
// decodeBlockRangesFromEncodedChunks decodes the provided chunks into a list of block ranges.
|
||||
func decodeBlockRangesFromEncodedChunks(codecVersion encoding.CodecVersion, chunks [][]byte) ([]*rawdb.ChunkBlockRange, error) {
|
||||
var chunkBlockRanges []*rawdb.ChunkBlockRange
|
||||
for _, chunk := range chunks {
|
||||
if len(chunk) < 1 {
|
||||
return nil, fmt.Errorf("invalid chunk, length is less than 1")
|
||||
}
|
||||
|
||||
numBlocks := int(chunk[0])
|
||||
|
||||
switch codecVersion {
|
||||
case encoding.CodecV0:
|
||||
if len(chunk) < 1+numBlocks*60 {
|
||||
return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk))
|
||||
}
|
||||
daBlocks := make([]*codecv0.DABlock, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*60 // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + 60
|
||||
daBlocks[i] = &codecv0.DABlock{}
|
||||
if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
case encoding.CodecV1:
|
||||
if len(chunk) != 1+numBlocks*60 {
|
||||
return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk))
|
||||
}
|
||||
daBlocks := make([]*codecv1.DABlock, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*60 // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + 60
|
||||
daBlocks[i] = &codecv1.DABlock{}
|
||||
if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
case encoding.CodecV2:
|
||||
if len(chunk) != 1+numBlocks*60 {
|
||||
return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk))
|
||||
}
|
||||
daBlocks := make([]*codecv2.DABlock, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*60 // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + 60
|
||||
daBlocks[i] = &codecv2.DABlock{}
|
||||
if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
case encoding.CodecV3:
|
||||
if len(chunk) != 1+numBlocks*60 {
|
||||
return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk))
|
||||
}
|
||||
daBlocks := make([]*codecv3.DABlock, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*60 // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + 60
|
||||
daBlocks[i] = &codecv3.DABlock{}
|
||||
if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected batch version %v", codecVersion)
|
||||
}
|
||||
}
|
||||
return chunkBlockRanges, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/scroll-tech/da-codec/encoding"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ func TestRollupSyncServiceStartAndStop(t *testing.T) {
|
|||
service.Stop()
|
||||
}
|
||||
|
||||
func TestDecodeChunkRanges(t *testing.T) {
|
||||
func TestDecodeChunkRangesCodecv0(t *testing.T) {
|
||||
scrollChainABI, err := scrollChainMetaData.GetAbi()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -57,17 +58,17 @@ func TestDecodeChunkRanges(t *testing.T) {
|
|||
scrollChainABI: scrollChainABI,
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("./testdata/commit_batch_transaction.json")
|
||||
data, err := os.ReadFile("./testdata/commitBatch_input_codecv0.json")
|
||||
require.NoError(t, err, "Failed to read json file")
|
||||
|
||||
type transactionJson struct {
|
||||
CallData string `json:"calldata"`
|
||||
type tx struct {
|
||||
Input string `json:"input"`
|
||||
}
|
||||
var txObj transactionJson
|
||||
err = json.Unmarshal(data, &txObj)
|
||||
var commitBatch tx
|
||||
err = json.Unmarshal(data, &commitBatch)
|
||||
require.NoError(t, err, "Failed to unmarshal transaction json")
|
||||
|
||||
testTxData, err := hex.DecodeString(txObj.CallData[2:])
|
||||
testTxData, err := hex.DecodeString(commitBatch.Input[2:])
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode string: %v", err)
|
||||
}
|
||||
|
|
@ -78,14 +79,21 @@ func TestDecodeChunkRanges(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 335921, EndBlockNumber: 335928},
|
||||
{StartBlockNumber: 335929, EndBlockNumber: 335933},
|
||||
{StartBlockNumber: 335934, EndBlockNumber: 335938},
|
||||
{StartBlockNumber: 335939, EndBlockNumber: 335942},
|
||||
{StartBlockNumber: 335943, EndBlockNumber: 335945},
|
||||
{StartBlockNumber: 335946, EndBlockNumber: 335949},
|
||||
{StartBlockNumber: 335950, EndBlockNumber: 335956},
|
||||
{StartBlockNumber: 335957, EndBlockNumber: 335962},
|
||||
{StartBlockNumber: 4435142, EndBlockNumber: 4435142},
|
||||
{StartBlockNumber: 4435143, EndBlockNumber: 4435144},
|
||||
{StartBlockNumber: 4435145, EndBlockNumber: 4435145},
|
||||
{StartBlockNumber: 4435146, EndBlockNumber: 4435146},
|
||||
{StartBlockNumber: 4435147, EndBlockNumber: 4435147},
|
||||
{StartBlockNumber: 4435148, EndBlockNumber: 4435148},
|
||||
{StartBlockNumber: 4435149, EndBlockNumber: 4435150},
|
||||
{StartBlockNumber: 4435151, EndBlockNumber: 4435151},
|
||||
{StartBlockNumber: 4435152, EndBlockNumber: 4435152},
|
||||
{StartBlockNumber: 4435153, EndBlockNumber: 4435153},
|
||||
{StartBlockNumber: 4435154, EndBlockNumber: 4435154},
|
||||
{StartBlockNumber: 4435155, EndBlockNumber: 4435155},
|
||||
{StartBlockNumber: 4435156, EndBlockNumber: 4435156},
|
||||
{StartBlockNumber: 4435157, EndBlockNumber: 4435157},
|
||||
{StartBlockNumber: 4435158, EndBlockNumber: 4435158},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
|
|
@ -94,12 +102,178 @@ func TestDecodeChunkRanges(t *testing.T) {
|
|||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Fatalf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
t.Errorf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChunkRanges(t *testing.T) {
|
||||
func TestDecodeChunkRangesCodecv1(t *testing.T) {
|
||||
scrollChainABI, err := scrollChainMetaData.GetAbi()
|
||||
require.NoError(t, err)
|
||||
|
||||
service := &RollupSyncService{
|
||||
scrollChainABI: scrollChainABI,
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("./testdata/commitBatch_input_codecv1.json")
|
||||
require.NoError(t, err, "Failed to read json file")
|
||||
|
||||
type tx struct {
|
||||
Input string `json:"input"`
|
||||
}
|
||||
var commitBatch tx
|
||||
err = json.Unmarshal(data, &commitBatch)
|
||||
require.NoError(t, err, "Failed to unmarshal transaction json")
|
||||
|
||||
testTxData, err := hex.DecodeString(commitBatch.Input[2:])
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode string: %v", err)
|
||||
}
|
||||
|
||||
ranges, err := service.decodeChunkBlockRanges(testTxData)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode chunk ranges: %v", err)
|
||||
}
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 1690, EndBlockNumber: 1780},
|
||||
{StartBlockNumber: 1781, EndBlockNumber: 1871},
|
||||
{StartBlockNumber: 1872, EndBlockNumber: 1962},
|
||||
{StartBlockNumber: 1963, EndBlockNumber: 2053},
|
||||
{StartBlockNumber: 2054, EndBlockNumber: 2144},
|
||||
{StartBlockNumber: 2145, EndBlockNumber: 2235},
|
||||
{StartBlockNumber: 2236, EndBlockNumber: 2326},
|
||||
{StartBlockNumber: 2327, EndBlockNumber: 2417},
|
||||
{StartBlockNumber: 2418, EndBlockNumber: 2508},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Errorf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeChunkRangesCodecv2(t *testing.T) {
|
||||
scrollChainABI, err := scrollChainMetaData.GetAbi()
|
||||
require.NoError(t, err)
|
||||
|
||||
service := &RollupSyncService{
|
||||
scrollChainABI: scrollChainABI,
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("./testdata/commitBatch_input_codecv2.json")
|
||||
require.NoError(t, err, "Failed to read json file")
|
||||
|
||||
type tx struct {
|
||||
Input string `json:"input"`
|
||||
}
|
||||
var commitBatch tx
|
||||
err = json.Unmarshal(data, &commitBatch)
|
||||
require.NoError(t, err, "Failed to unmarshal transaction json")
|
||||
|
||||
testTxData, err := hex.DecodeString(commitBatch.Input[2:])
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode string: %v", err)
|
||||
}
|
||||
|
||||
ranges, err := service.decodeChunkBlockRanges(testTxData)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode chunk ranges: %v", err)
|
||||
}
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 200, EndBlockNumber: 290},
|
||||
{StartBlockNumber: 291, EndBlockNumber: 381},
|
||||
{StartBlockNumber: 382, EndBlockNumber: 472},
|
||||
{StartBlockNumber: 473, EndBlockNumber: 563},
|
||||
{StartBlockNumber: 564, EndBlockNumber: 654},
|
||||
{StartBlockNumber: 655, EndBlockNumber: 745},
|
||||
{StartBlockNumber: 746, EndBlockNumber: 836},
|
||||
{StartBlockNumber: 837, EndBlockNumber: 927},
|
||||
{StartBlockNumber: 928, EndBlockNumber: 1018},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Errorf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeChunkRangesCodecv3(t *testing.T) {
|
||||
scrollChainABI, err := scrollChainMetaData.GetAbi()
|
||||
require.NoError(t, err)
|
||||
|
||||
service := &RollupSyncService{
|
||||
scrollChainABI: scrollChainABI,
|
||||
}
|
||||
|
||||
data, err := os.ReadFile("./testdata/commitBatchWithBlobProof_input_codecv3.json")
|
||||
require.NoError(t, err, "Failed to read json file")
|
||||
|
||||
type tx struct {
|
||||
Input string `json:"input"`
|
||||
}
|
||||
var commitBatch tx
|
||||
err = json.Unmarshal(data, &commitBatch)
|
||||
require.NoError(t, err, "Failed to unmarshal transaction json")
|
||||
|
||||
testTxData, err := hex.DecodeString(commitBatch.Input[2:])
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode string: %v", err)
|
||||
}
|
||||
|
||||
ranges, err := service.decodeChunkBlockRanges(testTxData)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode chunk ranges: %v", err)
|
||||
}
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 1, EndBlockNumber: 9},
|
||||
{StartBlockNumber: 10, EndBlockNumber: 20},
|
||||
{StartBlockNumber: 21, EndBlockNumber: 21},
|
||||
{StartBlockNumber: 22, EndBlockNumber: 22},
|
||||
{StartBlockNumber: 23, EndBlockNumber: 23},
|
||||
{StartBlockNumber: 24, EndBlockNumber: 24},
|
||||
{StartBlockNumber: 25, EndBlockNumber: 25},
|
||||
{StartBlockNumber: 26, EndBlockNumber: 26},
|
||||
{StartBlockNumber: 27, EndBlockNumber: 27},
|
||||
{StartBlockNumber: 28, EndBlockNumber: 28},
|
||||
{StartBlockNumber: 29, EndBlockNumber: 29},
|
||||
{StartBlockNumber: 30, EndBlockNumber: 30},
|
||||
{StartBlockNumber: 31, EndBlockNumber: 31},
|
||||
{StartBlockNumber: 32, EndBlockNumber: 32},
|
||||
{StartBlockNumber: 33, EndBlockNumber: 33},
|
||||
{StartBlockNumber: 34, EndBlockNumber: 34},
|
||||
{StartBlockNumber: 35, EndBlockNumber: 35},
|
||||
{StartBlockNumber: 36, EndBlockNumber: 36},
|
||||
{StartBlockNumber: 37, EndBlockNumber: 37},
|
||||
{StartBlockNumber: 38, EndBlockNumber: 38},
|
||||
{StartBlockNumber: 39, EndBlockNumber: 39},
|
||||
{StartBlockNumber: 40, EndBlockNumber: 40},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Errorf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChunkRangesCodecv0(t *testing.T) {
|
||||
genesisConfig := ¶ms.ChainConfig{
|
||||
Scroll: params.ScrollConfig{
|
||||
L1Config: ¶ms.L1Config{
|
||||
|
|
@ -110,12 +284,12 @@ func TestGetChunkRanges(t *testing.T) {
|
|||
}
|
||||
db := rawdb.NewDatabase(memorydb.New())
|
||||
|
||||
rlpData, err := os.ReadFile("./testdata/commit_batch_tx.rlp")
|
||||
rlpData, err := os.ReadFile("./testdata/commitBatch_codecv0.rlp")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to read RLP data: %v", err)
|
||||
}
|
||||
l1Client := &mockEthClient{
|
||||
commitBatchRLP: rlpData,
|
||||
txRLP: rlpData,
|
||||
}
|
||||
bc := &core.BlockChain{}
|
||||
stack, err := node.New(&node.DefaultConfig)
|
||||
|
|
@ -151,68 +325,562 @@ func TestGetChunkRanges(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestValidateBatch(t *testing.T) {
|
||||
templateBlockTrace1, err := os.ReadFile("./testdata/blockTrace_02.json")
|
||||
require.NoError(t, err)
|
||||
wrappedBlock1 := &WrappedBlock{}
|
||||
err = json.Unmarshal(templateBlockTrace1, wrappedBlock1)
|
||||
require.NoError(t, err)
|
||||
chunk1 := &Chunk{Blocks: []*WrappedBlock{wrappedBlock1}}
|
||||
func TestGetChunkRangesCodecv1(t *testing.T) {
|
||||
genesisConfig := ¶ms.ChainConfig{
|
||||
Scroll: params.ScrollConfig{
|
||||
L1Config: ¶ms.L1Config{
|
||||
L1ChainId: 11155111,
|
||||
ScrollChainAddress: common.HexToAddress("0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0"),
|
||||
},
|
||||
},
|
||||
}
|
||||
db := rawdb.NewDatabase(memorydb.New())
|
||||
|
||||
templateBlockTrace2, err := os.ReadFile("./testdata/blockTrace_03.json")
|
||||
require.NoError(t, err)
|
||||
wrappedBlock2 := &WrappedBlock{}
|
||||
err = json.Unmarshal(templateBlockTrace2, wrappedBlock2)
|
||||
require.NoError(t, err)
|
||||
chunk2 := &Chunk{Blocks: []*WrappedBlock{wrappedBlock2}}
|
||||
rlpData, err := os.ReadFile("./testdata/commitBatch_codecv1.rlp")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to read RLP data: %v", err)
|
||||
}
|
||||
l1Client := &mockEthClient{
|
||||
txRLP: rlpData,
|
||||
}
|
||||
bc := &core.BlockChain{}
|
||||
stack, err := node.New(&node.DefaultConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new P2P node: %v", err)
|
||||
}
|
||||
defer stack.Close()
|
||||
service, err := NewRollupSyncService(context.Background(), genesisConfig, db, l1Client, bc, stack)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new rollup sync service: %v", err)
|
||||
}
|
||||
|
||||
templateBlockTrace3, err := os.ReadFile("./testdata/blockTrace_04.json")
|
||||
vLog := &types.Log{
|
||||
TxHash: common.HexToHash("0x1"),
|
||||
}
|
||||
ranges, err := service.getChunkRanges(1, vLog)
|
||||
require.NoError(t, err)
|
||||
wrappedBlock3 := &WrappedBlock{}
|
||||
err = json.Unmarshal(templateBlockTrace3, wrappedBlock3)
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 1, EndBlockNumber: 11},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Fatalf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChunkRangesCodecv2(t *testing.T) {
|
||||
genesisConfig := ¶ms.ChainConfig{
|
||||
Scroll: params.ScrollConfig{
|
||||
L1Config: ¶ms.L1Config{
|
||||
L1ChainId: 11155111,
|
||||
ScrollChainAddress: common.HexToAddress("0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0"),
|
||||
},
|
||||
},
|
||||
}
|
||||
db := rawdb.NewDatabase(memorydb.New())
|
||||
|
||||
rlpData, err := os.ReadFile("./testdata/commitBatch_codecv2.rlp")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to read RLP data: %v", err)
|
||||
}
|
||||
l1Client := &mockEthClient{
|
||||
txRLP: rlpData,
|
||||
}
|
||||
bc := &core.BlockChain{}
|
||||
stack, err := node.New(&node.DefaultConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new P2P node: %v", err)
|
||||
}
|
||||
defer stack.Close()
|
||||
service, err := NewRollupSyncService(context.Background(), genesisConfig, db, l1Client, bc, stack)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new rollup sync service: %v", err)
|
||||
}
|
||||
|
||||
vLog := &types.Log{
|
||||
TxHash: common.HexToHash("0x2"),
|
||||
}
|
||||
ranges, err := service.getChunkRanges(1, vLog)
|
||||
require.NoError(t, err)
|
||||
chunk3 := &Chunk{Blocks: []*WrappedBlock{wrappedBlock3}}
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 143, EndBlockNumber: 143},
|
||||
{StartBlockNumber: 144, EndBlockNumber: 144},
|
||||
{StartBlockNumber: 145, EndBlockNumber: 145},
|
||||
{StartBlockNumber: 146, EndBlockNumber: 146},
|
||||
{StartBlockNumber: 147, EndBlockNumber: 147},
|
||||
{StartBlockNumber: 148, EndBlockNumber: 148},
|
||||
{StartBlockNumber: 149, EndBlockNumber: 149},
|
||||
{StartBlockNumber: 150, EndBlockNumber: 150},
|
||||
{StartBlockNumber: 151, EndBlockNumber: 151},
|
||||
{StartBlockNumber: 152, EndBlockNumber: 152},
|
||||
{StartBlockNumber: 153, EndBlockNumber: 153},
|
||||
{StartBlockNumber: 154, EndBlockNumber: 154},
|
||||
{StartBlockNumber: 155, EndBlockNumber: 155},
|
||||
{StartBlockNumber: 156, EndBlockNumber: 156},
|
||||
{StartBlockNumber: 157, EndBlockNumber: 157},
|
||||
{StartBlockNumber: 158, EndBlockNumber: 158},
|
||||
{StartBlockNumber: 159, EndBlockNumber: 159},
|
||||
{StartBlockNumber: 160, EndBlockNumber: 160},
|
||||
{StartBlockNumber: 161, EndBlockNumber: 161},
|
||||
{StartBlockNumber: 162, EndBlockNumber: 162},
|
||||
{StartBlockNumber: 163, EndBlockNumber: 163},
|
||||
{StartBlockNumber: 164, EndBlockNumber: 164},
|
||||
{StartBlockNumber: 165, EndBlockNumber: 168},
|
||||
{StartBlockNumber: 169, EndBlockNumber: 169},
|
||||
{StartBlockNumber: 170, EndBlockNumber: 170},
|
||||
{StartBlockNumber: 171, EndBlockNumber: 171},
|
||||
{StartBlockNumber: 172, EndBlockNumber: 172},
|
||||
{StartBlockNumber: 173, EndBlockNumber: 173},
|
||||
{StartBlockNumber: 174, EndBlockNumber: 174},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Fatalf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChunkRangesCodecv3(t *testing.T) {
|
||||
genesisConfig := ¶ms.ChainConfig{
|
||||
Scroll: params.ScrollConfig{
|
||||
L1Config: ¶ms.L1Config{
|
||||
L1ChainId: 11155111,
|
||||
ScrollChainAddress: common.HexToAddress("0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0"),
|
||||
},
|
||||
},
|
||||
}
|
||||
db := rawdb.NewDatabase(memorydb.New())
|
||||
|
||||
rlpData, err := os.ReadFile("./testdata/commitBatchWithBlobProof_codecv3.rlp")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to read RLP data: %v", err)
|
||||
}
|
||||
l1Client := &mockEthClient{
|
||||
txRLP: rlpData,
|
||||
}
|
||||
bc := &core.BlockChain{}
|
||||
stack, err := node.New(&node.DefaultConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new P2P node: %v", err)
|
||||
}
|
||||
defer stack.Close()
|
||||
service, err := NewRollupSyncService(context.Background(), genesisConfig, db, l1Client, bc, stack)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to new rollup sync service: %v", err)
|
||||
}
|
||||
|
||||
vLog := &types.Log{
|
||||
TxHash: common.HexToHash("0x3"),
|
||||
}
|
||||
ranges, err := service.getChunkRanges(1, vLog)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedRanges := []*rawdb.ChunkBlockRange{
|
||||
{StartBlockNumber: 41, EndBlockNumber: 41},
|
||||
{StartBlockNumber: 42, EndBlockNumber: 42},
|
||||
{StartBlockNumber: 43, EndBlockNumber: 43},
|
||||
{StartBlockNumber: 44, EndBlockNumber: 44},
|
||||
{StartBlockNumber: 45, EndBlockNumber: 45},
|
||||
{StartBlockNumber: 46, EndBlockNumber: 46},
|
||||
{StartBlockNumber: 47, EndBlockNumber: 47},
|
||||
{StartBlockNumber: 48, EndBlockNumber: 48},
|
||||
{StartBlockNumber: 49, EndBlockNumber: 49},
|
||||
{StartBlockNumber: 50, EndBlockNumber: 50},
|
||||
{StartBlockNumber: 51, EndBlockNumber: 51},
|
||||
{StartBlockNumber: 52, EndBlockNumber: 52},
|
||||
{StartBlockNumber: 53, EndBlockNumber: 53},
|
||||
{StartBlockNumber: 54, EndBlockNumber: 54},
|
||||
{StartBlockNumber: 55, EndBlockNumber: 55},
|
||||
{StartBlockNumber: 56, EndBlockNumber: 56},
|
||||
{StartBlockNumber: 57, EndBlockNumber: 57},
|
||||
{StartBlockNumber: 58, EndBlockNumber: 58},
|
||||
{StartBlockNumber: 59, EndBlockNumber: 59},
|
||||
{StartBlockNumber: 60, EndBlockNumber: 60},
|
||||
{StartBlockNumber: 61, EndBlockNumber: 61},
|
||||
{StartBlockNumber: 62, EndBlockNumber: 62},
|
||||
{StartBlockNumber: 63, EndBlockNumber: 63},
|
||||
{StartBlockNumber: 64, EndBlockNumber: 64},
|
||||
{StartBlockNumber: 65, EndBlockNumber: 65},
|
||||
{StartBlockNumber: 66, EndBlockNumber: 66},
|
||||
{StartBlockNumber: 67, EndBlockNumber: 67},
|
||||
{StartBlockNumber: 68, EndBlockNumber: 68},
|
||||
{StartBlockNumber: 69, EndBlockNumber: 69},
|
||||
{StartBlockNumber: 70, EndBlockNumber: 70},
|
||||
}
|
||||
|
||||
if len(expectedRanges) != len(ranges) {
|
||||
t.Fatalf("Expected range length %v, got %v", len(expectedRanges), len(ranges))
|
||||
}
|
||||
|
||||
for i := range ranges {
|
||||
if *expectedRanges[i] != *ranges[i] {
|
||||
t.Fatalf("Mismatch at index %d: expected %v, got %v", i, *expectedRanges[i], *ranges[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateBatchCodecv0(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
|
||||
parentBatchMeta1 := &rawdb.FinalizedBatchMeta{}
|
||||
event1 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(0),
|
||||
BatchHash: common.HexToHash("0xd0f52bc254646e639bf24cc34606319a111975b2fdc431b1381eb6199bc09790"),
|
||||
BatchHash: common.HexToHash("0xfd3ecf106ce993adc6db68e42ce701bfe638434395abdeeb871f7bd395ae2368"),
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1, parentBatchMeta1, []*Chunk{chunk1, chunk2, chunk3}, nil)
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1.BatchIndex.Uint64(), event1, parentBatchMeta1, []*encoding.Chunk{chunk1, chunk2, chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock1)
|
||||
|
||||
templateBlockTrace4, err := os.ReadFile("./testdata/blockTrace_05.json")
|
||||
require.NoError(t, err)
|
||||
wrappedBlock4 := &WrappedBlock{}
|
||||
err = json.Unmarshal(templateBlockTrace4, wrappedBlock4)
|
||||
require.NoError(t, err)
|
||||
chunk4 := &Chunk{Blocks: []*WrappedBlock{wrappedBlock4}}
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
parentBatchMeta2 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event1.BatchHash,
|
||||
TotalL1MessagePopped: 11,
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
StateRoot: event1.StateRoot,
|
||||
WithdrawRoot: event1.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta2, finalizedBatchMeta1)
|
||||
event2 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(1),
|
||||
BatchHash: common.HexToHash("0xfb77bf8f3bf449126ebbf403fdccfcf78636e34d72d62eed8da0e8c9fd38fa63"),
|
||||
BatchHash: common.HexToHash("0xadb8e526c3fdc2045614158300789cd66e7a945efe5a484db00b5ef9a26016d7"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2, parentBatchMeta2, []*Chunk{chunk4}, nil)
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2.BatchIndex.Uint64(), event2, parentBatchMeta2, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock2)
|
||||
|
||||
parentBatchMeta3 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event2.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
StateRoot: event2.StateRoot,
|
||||
WithdrawRoot: event2.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta3, finalizedBatchMeta2)
|
||||
}
|
||||
|
||||
func TestValidateBatchCodecv1(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{BernoulliBlock: big.NewInt(0)}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
|
||||
parentBatchMeta1 := &rawdb.FinalizedBatchMeta{}
|
||||
event1 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(0),
|
||||
BatchHash: common.HexToHash("0x73cb3310646716cb782702a0ec4ad33cf55633c85daf96b641953c5defe58031"),
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1.BatchIndex.Uint64(), event1, parentBatchMeta1, []*encoding.Chunk{chunk1, chunk2, chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock1)
|
||||
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
parentBatchMeta2 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event1.BatchHash,
|
||||
TotalL1MessagePopped: 11,
|
||||
StateRoot: event1.StateRoot,
|
||||
WithdrawRoot: event1.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta2, finalizedBatchMeta1)
|
||||
event2 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(1),
|
||||
BatchHash: common.HexToHash("0x7f230ce84b4bf86f8ee22ffb5c145e3ef3ddf2a76da4936a33f33cebdb63a48a"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2.BatchIndex.Uint64(), event2, parentBatchMeta2, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock2)
|
||||
|
||||
parentBatchMeta3 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event2.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: event2.StateRoot,
|
||||
WithdrawRoot: event2.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta3, finalizedBatchMeta2)
|
||||
}
|
||||
|
||||
func TestValidateBatchCodecv2(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0)}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
|
||||
parentBatchMeta1 := &rawdb.FinalizedBatchMeta{}
|
||||
event1 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(0),
|
||||
BatchHash: common.HexToHash("0xaccf37a0b974f2058692d366b2ea85502c99db4a0bcb9b77903b49bf866a463b"),
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1.BatchIndex.Uint64(), event1, parentBatchMeta1, []*encoding.Chunk{chunk1, chunk2, chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock1)
|
||||
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
parentBatchMeta2 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event1.BatchHash,
|
||||
TotalL1MessagePopped: 11,
|
||||
StateRoot: event1.StateRoot,
|
||||
WithdrawRoot: event1.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta2, finalizedBatchMeta1)
|
||||
event2 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(1),
|
||||
BatchHash: common.HexToHash("0x62ec61e1fdb334868ffd471df601f6858e692af01d42b5077c805a9fd4558c91"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2.BatchIndex.Uint64(), event2, parentBatchMeta2, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock2)
|
||||
|
||||
parentBatchMeta3 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event2.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: event2.StateRoot,
|
||||
WithdrawRoot: event2.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta3, finalizedBatchMeta2)
|
||||
}
|
||||
|
||||
func TestValidateBatchCodecv3(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64)}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
|
||||
parentBatchMeta1 := &rawdb.FinalizedBatchMeta{}
|
||||
event1 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(0),
|
||||
BatchHash: common.HexToHash("0x015eb56fb95bf9a06157cfb8389ba7c2b6b08373e22581ac2ba387003708265d"),
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1.BatchIndex.Uint64(), event1, parentBatchMeta1, []*encoding.Chunk{chunk1, chunk2, chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock1)
|
||||
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
parentBatchMeta2 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event1.BatchHash,
|
||||
TotalL1MessagePopped: 11,
|
||||
StateRoot: event1.StateRoot,
|
||||
WithdrawRoot: event1.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta2, finalizedBatchMeta1)
|
||||
event2 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(1),
|
||||
BatchHash: common.HexToHash("0x382cb0d507e3d7507f556c52e05f76b05e364ad26205e7f62c95967a19c2f35d"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2.BatchIndex.Uint64(), event2, parentBatchMeta2, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock2)
|
||||
|
||||
parentBatchMeta3 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event2.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: event2.StateRoot,
|
||||
WithdrawRoot: event2.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta3, finalizedBatchMeta2)
|
||||
}
|
||||
|
||||
func TestValidateBatchUpgrades(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(3), CurieBlock: big.NewInt(14), DarwinTime: func() *uint64 { t := uint64(1684762320); return &t }()}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
|
||||
parentBatchMeta1 := &rawdb.FinalizedBatchMeta{}
|
||||
event1 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(0),
|
||||
BatchHash: common.HexToHash("0x4605465b7470c8565b123330d7186805caf9a7f2656d8e9e744b62e14ca22c3d"),
|
||||
StateRoot: chunk1.Blocks[len(chunk1.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk1.Blocks[len(chunk1.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(event1.BatchIndex.Uint64(), event1, parentBatchMeta1, []*encoding.Chunk{chunk1}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(2), endBlock1)
|
||||
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
|
||||
parentBatchMeta2 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event1.BatchHash,
|
||||
TotalL1MessagePopped: 0,
|
||||
StateRoot: event1.StateRoot,
|
||||
WithdrawRoot: event1.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta2, finalizedBatchMeta1)
|
||||
event2 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(1),
|
||||
BatchHash: common.HexToHash("0xc4af33bce87aa702edc3ad4b7d34730d25719427704e250787f99e0f55049252"),
|
||||
StateRoot: chunk2.Blocks[len(chunk2.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk2.Blocks[len(chunk2.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(event2.BatchIndex.Uint64(), event2, parentBatchMeta2, []*encoding.Chunk{chunk2}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(3), endBlock2)
|
||||
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
|
||||
parentBatchMeta3 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event2.BatchHash,
|
||||
TotalL1MessagePopped: 0,
|
||||
StateRoot: event2.StateRoot,
|
||||
WithdrawRoot: event2.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta3, finalizedBatchMeta2)
|
||||
event3 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(2),
|
||||
BatchHash: common.HexToHash("0x9f87f2de2019ed635f867b1e61be6a607c3174ced096f370fd18556c38833c62"),
|
||||
StateRoot: chunk3.Blocks[len(chunk3.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk3.Blocks[len(chunk3.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock3, finalizedBatchMeta3, err := validateBatch(event3.BatchIndex.Uint64(), event3, parentBatchMeta3, []*encoding.Chunk{chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock3)
|
||||
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
parentBatchMeta4 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event3.BatchHash,
|
||||
TotalL1MessagePopped: 11,
|
||||
StateRoot: event3.StateRoot,
|
||||
WithdrawRoot: event3.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta4, finalizedBatchMeta3)
|
||||
event4 := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(3),
|
||||
BatchHash: common.HexToHash("0xd33332aef8efbc9a0be4c4694088ac0dd052d2d3ad3ffda5e4c2010825e476bc"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
endBlock4, finalizedBatchMeta4, err := validateBatch(event4.BatchIndex.Uint64(), event4, parentBatchMeta4, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock4)
|
||||
|
||||
parentBatchMeta5 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event4.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: event4.StateRoot,
|
||||
WithdrawRoot: event4.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta5, finalizedBatchMeta4)
|
||||
}
|
||||
|
||||
func TestValidateBatchInFinalizeByBundle(t *testing.T) {
|
||||
chainConfig := ¶ms.ChainConfig{LondonBlock: big.NewInt(0), BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: func() *uint64 { t := uint64(0); return &t }()}
|
||||
|
||||
block1 := readBlockFromJSON(t, "./testdata/blockTrace_02.json")
|
||||
block2 := readBlockFromJSON(t, "./testdata/blockTrace_03.json")
|
||||
block3 := readBlockFromJSON(t, "./testdata/blockTrace_04.json")
|
||||
block4 := readBlockFromJSON(t, "./testdata/blockTrace_05.json")
|
||||
|
||||
chunk1 := &encoding.Chunk{Blocks: []*encoding.Block{block1}}
|
||||
chunk2 := &encoding.Chunk{Blocks: []*encoding.Block{block2}}
|
||||
chunk3 := &encoding.Chunk{Blocks: []*encoding.Block{block3}}
|
||||
chunk4 := &encoding.Chunk{Blocks: []*encoding.Block{block4}}
|
||||
|
||||
event := &L1FinalizeBatchEvent{
|
||||
BatchIndex: big.NewInt(3),
|
||||
BatchHash: common.HexToHash("0xaa6dc7cc432c8d46a9373e1e96d829a1e24e52fe0468012ff062793ea8f5b55e"),
|
||||
StateRoot: chunk4.Blocks[len(chunk4.Blocks)-1].Header.Root,
|
||||
WithdrawRoot: chunk4.Blocks[len(chunk4.Blocks)-1].WithdrawRoot,
|
||||
}
|
||||
|
||||
endBlock1, finalizedBatchMeta1, err := validateBatch(0, event, &rawdb.FinalizedBatchMeta{}, []*encoding.Chunk{chunk1}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(2), endBlock1)
|
||||
|
||||
endBlock2, finalizedBatchMeta2, err := validateBatch(1, event, finalizedBatchMeta1, []*encoding.Chunk{chunk2}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(3), endBlock2)
|
||||
|
||||
endBlock3, finalizedBatchMeta3, err := validateBatch(2, event, finalizedBatchMeta2, []*encoding.Chunk{chunk3}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(13), endBlock3)
|
||||
|
||||
endBlock4, finalizedBatchMeta4, err := validateBatch(3, event, finalizedBatchMeta3, []*encoding.Chunk{chunk4}, chainConfig, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uint64(17), endBlock4)
|
||||
|
||||
parentBatchMeta5 := &rawdb.FinalizedBatchMeta{
|
||||
BatchHash: event.BatchHash,
|
||||
TotalL1MessagePopped: 42,
|
||||
StateRoot: event.StateRoot,
|
||||
WithdrawRoot: event.WithdrawRoot,
|
||||
}
|
||||
assert.Equal(t, parentBatchMeta5, finalizedBatchMeta4)
|
||||
}
|
||||
|
||||
func readBlockFromJSON(t *testing.T, filename string) *encoding.Block {
|
||||
data, err := os.ReadFile(filename)
|
||||
assert.NoError(t, err)
|
||||
|
||||
block := &encoding.Block{}
|
||||
assert.NoError(t, json.Unmarshal(data, block))
|
||||
return block
|
||||
}
|
||||
|
|
|
|||
BIN
rollup/rollup_sync_service/testdata/commitBatchWithBlobProof_codecv3.rlp
vendored
Normal file
BIN
rollup/rollup_sync_service/testdata/commitBatchWithBlobProof_codecv3.rlp
vendored
Normal file
Binary file not shown.
31
rollup/rollup_sync_service/testdata/commitBatchWithBlobProof_input_codecv3.json
vendored
Normal file
31
rollup/rollup_sync_service/testdata/commitBatchWithBlobProof_input_codecv3.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
rollup/rollup_sync_service/testdata/commitBatch_codecv1.rlp
vendored
Normal file
BIN
rollup/rollup_sync_service/testdata/commitBatch_codecv1.rlp
vendored
Normal file
Binary file not shown.
BIN
rollup/rollup_sync_service/testdata/commitBatch_codecv2.rlp
vendored
Normal file
BIN
rollup/rollup_sync_service/testdata/commitBatch_codecv2.rlp
vendored
Normal file
Binary file not shown.
27
rollup/rollup_sync_service/testdata/commitBatch_input_codecv0.json
vendored
Normal file
27
rollup/rollup_sync_service/testdata/commitBatch_input_codecv0.json
vendored
Normal file
File diff suppressed because one or more lines are too long
31
rollup/rollup_sync_service/testdata/commitBatch_input_codecv1.json
vendored
Normal file
31
rollup/rollup_sync_service/testdata/commitBatch_input_codecv1.json
vendored
Normal file
File diff suppressed because one or more lines are too long
31
rollup/rollup_sync_service/testdata/commitBatch_input_codecv2.json
vendored
Normal file
31
rollup/rollup_sync_service/testdata/commitBatch_input_codecv2.json
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue