mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
feat(L1 follower): add commitAndFinalizeBatch method (#1140)
* add commitAndFinalizeBatch method to L1Reader to support enforced batches in L1 follower and rollup verifier * chore: auto version bump [bot] * update ABI --------- Co-authored-by: jonastheis <jonastheis@users.noreply.github.com>
This commit is contained in:
parent
61cfff3bc5
commit
974cfcd726
4 changed files with 45 additions and 3 deletions
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 5 // Major version component of the current release
|
||||
VersionMinor = 8 // Minor version component of the current release
|
||||
VersionPatch = 23 // Patch version component of the current release
|
||||
VersionPatch = 24 // Patch version component of the current release
|
||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -22,6 +22,7 @@ func TestMethodSignatures(t *testing.T) {
|
|||
assert.Equal(t, crypto.Keccak256Hash([]byte("commitBatch(uint8,bytes,bytes[],bytes)")).Bytes()[:4], ScrollChainABI.Methods[commitBatchMethodName].ID)
|
||||
assert.Equal(t, crypto.Keccak256Hash([]byte("commitBatchWithBlobProof(uint8,bytes,bytes[],bytes,bytes)")).Bytes()[:4], ScrollChainABI.Methods[commitBatchWithBlobProofMethodName].ID)
|
||||
assert.Equal(t, crypto.Keccak256Hash([]byte("commitBatches(uint8,bytes32,bytes32)")).Bytes()[:4], ScrollChainABI.Methods[commitBatchesV7MethodName].ID)
|
||||
assert.Equal(t, crypto.Keccak256Hash([]byte("commitAndFinalizeBatch(uint8,bytes32,(bytes,uint256,bytes32,bytes32,bytes))")).Bytes()[:4], ScrollChainABI.Methods[commitAndFinalizeBatch].ID)
|
||||
assert.Equal(t, crypto.Keccak256Hash([]byte("finalizeBundlePostEuclidV2(bytes,uint256,bytes32,bytes32,bytes)")).Bytes()[:4], ScrollChainABI.Methods[finalizeBundlePostEuclidV2MethodName].ID)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/scroll-tech/da-codec/encoding"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum"
|
||||
"github.com/scroll-tech/go-ethereum/accounts/abi"
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
|
|
@ -97,7 +99,7 @@ func (r *Reader) FinalizedL1MessageQueueIndex(blockNumber uint64) (uint64, error
|
|||
return next - 1, nil
|
||||
}
|
||||
|
||||
func (r *Reader) LatestFinalizedBatch(blockNumber uint64) (uint64, error) {
|
||||
func (r *Reader) LatestFinalizedBatchIndex(blockNumber uint64) (uint64, error) {
|
||||
data, err := r.scrollChainABI.Pack(lastFinalizedBatchIndex)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to pack %s: %w", lastFinalizedBatchIndex, err)
|
||||
|
|
@ -398,6 +400,28 @@ func (r *Reader) FetchCommitTxData(commitEvent *CommitBatchEvent) (*CommitBatchA
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode calldata into commitBatch args %s, values: %+v, err: %w", commitBatchesV7MethodName, values, err)
|
||||
}
|
||||
} else if method.Name == commitAndFinalizeBatch {
|
||||
commitAndFinalizeArgs, err := newCommitAndFinalizeBatchArgs(method, values)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode calldata into commitAndFinalizeBatch args %s, values: %+v, err: %w", commitAndFinalizeBatch, values, err)
|
||||
}
|
||||
|
||||
// in commitAndFinalizeBatch, the last batch hash is encoded in the finalize struct as this is the only batch we're
|
||||
// committing when calling this function.
|
||||
codec, err := encoding.CodecFromVersion(encoding.CodecVersion(commitAndFinalizeArgs.Version))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get codec from version %d, err: %w", commitAndFinalizeArgs.Version, err)
|
||||
}
|
||||
daBatch, err := codec.NewDABatchFromBytes(commitAndFinalizeArgs.FinalizeStruct.BatchHeader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode daBatch from bytes, err: %w", err)
|
||||
}
|
||||
|
||||
args = &CommitBatchArgs{
|
||||
Version: commitAndFinalizeArgs.Version,
|
||||
ParentBatchHash: commitAndFinalizeArgs.ParentBatchHash,
|
||||
LastBatchHash: daBatch.Hash(),
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("unknown method name for commit transaction: %s", method.Name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue