Skip to content

Commit

Permalink
wip: accinputhash calc and test
Browse files Browse the repository at this point in the history
  • Loading branch information
revitteth committed Nov 28, 2024
1 parent 3692c5a commit 9b85f26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 9 additions & 4 deletions turbo/jsonrpc/zkevm_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func TestGetBatchByNumber(t *testing.T) {
assert.NoError(err)
err = hDB.WriteBlockGlobalExitRoot(uint64(i+1), gers[i])
assert.NoError(err)
l1InforTree := &zktypes.L1InfoTreeUpdate{
l1InfoTree := &zktypes.L1InfoTreeUpdate{
Index: uint64(i),
GER: gers[i],
MainnetExitRoot: mainnetExitRoots[i],
Expand All @@ -413,7 +413,11 @@ func TestGetBatchByNumber(t *testing.T) {
Timestamp: times[i],
BlockNumber: uint64(i + 1),
}
err = hDB.WriteL1InfoTreeUpdateToGer(l1InforTree)
err = hDB.WriteL1InfoTreeUpdateToGer(l1InfoTree)
assert.NoError(err)
err = hDB.WriteL1InfoTreeUpdate(l1InfoTree)
assert.NoError(err)
err = hDB.WriteL1InfoTreeRoot(hashes[i], uint64(i))
assert.NoError(err)
}

Expand All @@ -435,6 +439,8 @@ func TestGetBatchByNumber(t *testing.T) {
assert.NoError(err)
}

accInputHash := common.HexToHash("0xd24388f39169a9187e66711e42c8da0dfd9f9089ec46c9a95d29a1f25a58234a")

for i := 0; i < 4; i++ {
_, err := erigonDB.WriteHeader(big.NewInt(int64(i+1)), hashes[i], stateRoots[i], txsRoot[i], parentHashes[i], coinBase, times[i], gasLimits[i], params.TestChainConfig)
assert.NoError(err)
Expand All @@ -443,7 +449,6 @@ func TestGetBatchByNumber(t *testing.T) {
}
tx.Commit()
var response []byte
accInputHash := common.HexToHash("0xd24388f39169a9187e66711e42c8da0dfd9f9089ec46c9a95d29a1f25a58234a")
response = append(response, accInputHash.Bytes()...)
response = append(response, common.Hash{}.Bytes()...)
response = append(response, common.FromHex(fmt.Sprintf("0x%064x", 1))...)
Expand Down Expand Up @@ -480,7 +485,7 @@ func TestGetBatchByNumber(t *testing.T) {
assert.Equal(gers[len(gers)-1], batch.GlobalExitRoot)
assert.Equal(mainnetExitRoots[len(mainnetExitRoots)-1], batch.MainnetExitRoot)
assert.Equal(rollupExitRoots[len(rollupExitRoots)-1], batch.RollupExitRoot)
assert.Equal(common.HexToHash("0x97d1524156ccb46723e5c3c87951da9a390499ba288161d879df1dbc03d49afc"), batch.AccInputHash)
assert.Equal(common.HexToHash("0xebf7acfdbfb4ea6ef8775e7d2246d7d4f3d8c280fbe7649e1b90eb7490ea19e6"), batch.AccInputHash)
assert.Equal(common.HexToHash("0x22ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba97"), *batch.SendSequencesTxHash)
assert.Equal(rpctypes.ArgUint64(1714427009), batch.Timestamp)
assert.Equal(true, batch.Closed)
Expand Down
4 changes: 4 additions & 0 deletions zk/acc_input_hash/acc_input_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func TestCalculateAccInputHash(t *testing.T) {
expectError: false,
setup: func(t *testing.T) (*MockAccInputHashReader, *MockBlockReader) {
reader := &MockAccInputHashReader{
ForkIds: map[uint64]uint64{
4: 7,
},
AccInputHashes: map[uint64]common.Hash{
4: common.HexToHash("0xbbb"),
},
Expand Down Expand Up @@ -207,6 +210,7 @@ func TestCalculateAccInputHash(t *testing.T) {
reader := &MockAccInputHashReader{
AccInputHashes: map[uint64]common.Hash{},
ForkIds: map[uint64]uint64{
0: 7,
1: 7,
2: 7,
},
Expand Down
1 change: 1 addition & 0 deletions zk/stages/stage_l1_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestSpawnStageL1Syncer(t *testing.T) {
latestBlock := types.NewBlockWithHeader(latestBlockHeader)

EthermanMock.EXPECT().BlockByNumber(gomock.Any(), nil).Return(latestBlock, nil).AnyTimes()
EthermanMock.EXPECT().CallContract(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()

filterQuery := ethereum.FilterQuery{
FromBlock: l1FirstBlock,
Expand Down

0 comments on commit 9b85f26

Please sign in to comment.