mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-03 02:23:48 +00:00
* port changes from #1013 * port changes from #1068 * go.mod tidy * fix compile error * fix goimports * fix log * address review comments * upgrade golang.org/x/net to 0.23.0 * port changes from #1018 * fix tests and linter errors * address review comments * refactor rollup sync service / verifier to use CalldataBlobSource to retrieve data from L1 * add configuration and initialize blob clients * fix unit tests * remove unused code * address review comments * address more review comments * implement first version of new da-codec and to handle multiple batches submitted in one transaction * add CommitBatchDAV7 and handle multiple commit events submitted in a single transactions * fix bug due to previous batch being empty when processing the first batch within a set of batches * Allow using MPT * update to latest da-codec * add field to CommittedBatchMeta to store LastL1MessageQueueHash for CodecV7 batches * adjust rollup verifier to support CodecV7 batches * address review comments * fix issues after merge * go mod tidy * fix unit tests * update da-codec * add test TestValidateBatchCodecV7 * go mod tidy * do not log error on shutdown * add sanity check for version to deserialization of committedBatchMetaV7 * port changes from #1073 * chore: auto version bump [bot] * address review comments * add more logs * disable ENRUpdater if DA sync mode is enabled * exit pipeline if context is cancelled * correctly handle override by setting the head of the chain to the parent's height so that created blocks will always become part of canonical chain * fix error with genesis event being nil * chore: auto version bump [bot] * chore: auto version bump [bot] * adjust to renaming in CodecV7 * implement carrying forward of L1 MessageQueue index * fix issue after upgrading from old storage to new format where batchIndex was 0 and all batches would be skipped * add new RevertBatch event * add commitBatches to be able to read calldata of CodecV7/EuclidV2 committed batches * implement finding of L1 message queue height for initial batch in recovery mode * add sanity checks for computed batches from events and batch hashes given via calldata from commit transaction * update ScrollChain ABI * chore: auto version bump [bot] * remove initial batch form DAQueue * go mod tidy * fix underflow bug when l1DeploymentBlock==0 * fix bug with wrong parentBatchHash of first batch of batches submitted in a single tx * update to latest da-codec * address review comments * address review comments * fix bug when l1MessageV2StartIndex==0 serialized to [] (empty slice) which would always be decoded to non-existing instead of 0 * chore: auto version bump [bot] * cache go dependencies in Dockerfile.mockccc * chore: auto version bump [bot] * add INFO log when reverting rollup events in L1 follower mode * change LastProcessedMessageQueueIndex of finalize event to totalL1MessagesPoppedOverall * cleanup * chore: auto version bump [bot] --------- Co-authored-by: Ömer Faruk Irmak <omerfirmak@gmail.com> Co-authored-by: Thegaram <Thegaram@users.noreply.github.com> Co-authored-by: jonastheis <jonastheis@users.noreply.github.com>
105 lines
3.2 KiB
Go
105 lines
3.2 KiB
Go
package l1
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/scroll-tech/go-ethereum/common"
|
|
"github.com/scroll-tech/go-ethereum/core/types"
|
|
"github.com/scroll-tech/go-ethereum/crypto"
|
|
)
|
|
|
|
func TestEventSignatures(t *testing.T) {
|
|
assert.Equal(t, crypto.Keccak256Hash([]byte("CommitBatch(uint256,bytes32)")), ScrollChainABI.Events[commitBatchEventName].ID)
|
|
assert.Equal(t, crypto.Keccak256Hash([]byte("RevertBatch(uint256,bytes32)")), ScrollChainABI.Events[revertBatchV0EventName].ID)
|
|
assert.Equal(t, crypto.Keccak256Hash([]byte("RevertBatch(uint256,uint256)")), ScrollChainABI.Events[revertBatchV7EventName].ID)
|
|
assert.Equal(t, crypto.Keccak256Hash([]byte("FinalizeBatch(uint256,bytes32,bytes32,bytes32)")), ScrollChainABI.Events[finalizeBatchEventName].ID)
|
|
}
|
|
|
|
func TestUnpackLog(t *testing.T) {
|
|
mockBatchIndex := big.NewInt(123)
|
|
finishMockBatchIndex := big.NewInt(125)
|
|
mockBatchHash := crypto.Keccak256Hash([]byte("mockBatch"))
|
|
mockStateRoot := crypto.Keccak256Hash([]byte("mockStateRoot"))
|
|
mockWithdrawRoot := crypto.Keccak256Hash([]byte("mockWithdrawRoot"))
|
|
|
|
tests := []struct {
|
|
eventName string
|
|
mockLog types.Log
|
|
expected interface{}
|
|
out interface{}
|
|
}{
|
|
{
|
|
commitBatchEventName,
|
|
types.Log{
|
|
Data: nil,
|
|
Topics: []common.Hash{ScrollChainABI.Events[commitBatchEventName].ID, common.BigToHash(mockBatchIndex), mockBatchHash},
|
|
},
|
|
&CommitBatchEventUnpacked{
|
|
BatchIndex: mockBatchIndex,
|
|
BatchHash: mockBatchHash,
|
|
},
|
|
&CommitBatchEventUnpacked{},
|
|
},
|
|
{
|
|
revertBatchV0EventName,
|
|
types.Log{
|
|
Data: nil,
|
|
Topics: []common.Hash{ScrollChainABI.Events[revertBatchV0EventName].ID, common.BigToHash(mockBatchIndex), mockBatchHash},
|
|
},
|
|
&RevertBatchEventV0Unpacked{
|
|
BatchIndex: mockBatchIndex,
|
|
BatchHash: mockBatchHash,
|
|
},
|
|
&RevertBatchEventV0Unpacked{},
|
|
},
|
|
{
|
|
revertBatchV7EventName,
|
|
types.Log{
|
|
Data: nil,
|
|
Topics: []common.Hash{ScrollChainABI.Events[revertBatchV7EventName].ID, common.BigToHash(mockBatchIndex), common.BigToHash(mockBatchIndex)},
|
|
},
|
|
&RevertBatchEventV7Unpacked{
|
|
StartBatchIndex: mockBatchIndex,
|
|
FinishBatchIndex: mockBatchIndex,
|
|
},
|
|
&RevertBatchEventV7Unpacked{},
|
|
},
|
|
{
|
|
revertBatchV7EventName,
|
|
types.Log{
|
|
Data: nil,
|
|
Topics: []common.Hash{ScrollChainABI.Events[revertBatchV7EventName].ID, common.BigToHash(mockBatchIndex), common.BigToHash(finishMockBatchIndex)},
|
|
},
|
|
&RevertBatchEventV7Unpacked{
|
|
StartBatchIndex: mockBatchIndex,
|
|
FinishBatchIndex: finishMockBatchIndex,
|
|
},
|
|
&RevertBatchEventV7Unpacked{},
|
|
},
|
|
{
|
|
finalizeBatchEventName,
|
|
types.Log{
|
|
Data: append(mockStateRoot.Bytes(), mockWithdrawRoot.Bytes()...),
|
|
Topics: []common.Hash{ScrollChainABI.Events[finalizeBatchEventName].ID, common.BigToHash(mockBatchIndex), mockBatchHash},
|
|
},
|
|
&FinalizeBatchEventUnpacked{
|
|
BatchIndex: mockBatchIndex,
|
|
BatchHash: mockBatchHash,
|
|
StateRoot: mockStateRoot,
|
|
WithdrawRoot: mockWithdrawRoot,
|
|
},
|
|
&FinalizeBatchEventUnpacked{},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.eventName, func(t *testing.T) {
|
|
err := UnpackLog(ScrollChainABI, tt.out, tt.eventName, tt.mockLog)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, tt.expected, tt.out)
|
|
})
|
|
}
|
|
}
|