diff --git a/core/blockchain.go b/core/blockchain.go index 3f325be8e..513c73690 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -238,7 +238,7 @@ type BlockChain struct { currentFinalBlock atomic.Pointer[types.Header] // Latest (consensus) finalized block currentSafeBlock atomic.Pointer[types.Header] // Latest (consensus) safe block - currentBaseCelestiaHeight atomic.Uint32 // Latest finalized block height on Celestia + currentBaseCelestiaHeight atomic.Uint64 // Latest finalized block height on Celestia bodyCache *lru.Cache[common.Hash, *types.Body] bodyRLPCache *lru.Cache[common.Hash, rlp.RawValue] @@ -630,7 +630,7 @@ func (bc *BlockChain) SetFinalized(header *types.Header) { } // SetCelestiaFinalized sets the finalized block and the lowest Celestia height to find next finalized at. -func (bc *BlockChain) SetCelestiaFinalized(header *types.Header, celHeight uint32) { +func (bc *BlockChain) SetCelestiaFinalized(header *types.Header, celHeight uint64) { rawdb.WriteBaseCelestiaHeight(bc.db, celHeight) bc.currentBaseCelestiaHeight.Store(celHeight) bc.SetFinalized(header) diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 1695d4284..fe1986f72 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -64,7 +64,7 @@ func (bc *BlockChain) CurrentSafeBlock() *types.Header { // CurrentBaseCelestiaHeight retrieves the current base celestia height of the // canonical chain. The height is retrieved from the blockchain's internal cache. -func (bc *BlockChain) CurrentBaseCelestiaHeight() uint32 { +func (bc *BlockChain) CurrentBaseCelestiaHeight() uint64 { return bc.currentBaseCelestiaHeight.Load() } diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index affd81e30..e54f4964b 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -234,18 +234,18 @@ func WriteFinalizedBlockHash(db ethdb.KeyValueWriter, hash common.Hash) { } // ReadFinalizedCelestiaBlockHeight retrieves the height of the finalized block. -func ReadBaseCelestiaHeight(db ethdb.KeyValueReader) uint32 { +func ReadBaseCelestiaHeight(db ethdb.KeyValueReader) uint64 { data, _ := db.Get(headBaseCelestiaHeightKey) - if len(data) != 4 { + if len(data) != 8 { return 0 } - number := binary.BigEndian.Uint32(data) + number := binary.BigEndian.Uint64(data) return number } // WriteFinalizedCelestiaBlockHeight stores the height of the finalized block. -func WriteBaseCelestiaHeight(db ethdb.KeyValueWriter, height uint32) { - byteHeight := encodeCometbftBlockNumber(height) +func WriteBaseCelestiaHeight(db ethdb.KeyValueWriter, height uint64) { + byteHeight := encodeBlockNumber(height) if err := db.Put(headBaseCelestiaHeightKey, byteHeight); err != nil { log.Crit("Failed to store base celestia height", "err", err) } diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index fd21adc4a..493c3cdff 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -154,13 +154,6 @@ func encodeBlockNumber(number uint64) []byte { return enc } -// encodeCometbftBlockNumber encodes a block number as big endian uint32 -func encodeCometbftBlockNumber(number uint32) []byte { - enc := make([]byte, 4) - binary.BigEndian.PutUint32(enc, number) - return enc -} - // headerKeyPrefix = headerPrefix + num (uint64 big endian) func headerKeyPrefix(number uint64) []byte { return append(headerPrefix, encodeBlockNumber(number)...) diff --git a/go.mod b/go.mod index 8e688ed58..a687df819 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/ethereum/go-ethereum go 1.21 require ( - buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-84e5e35facb9.3 - buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-84e5e35facb9.1 + buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-1e80fd5dcebf.3 + buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-1e80fd5dcebf.1 buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.1-20240529204957-2697e2110d78.1 buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.1-20240529204957-1b3cb2034833.1 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 diff --git a/go.sum b/go.sum index 48da2e818..b8089f613 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-84e5e35facb9.3 h1:6in5tlvH/3jJVebwGa9Jozk10cv3Z1ywvIel/dPvjiI= -buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-84e5e35facb9.3/go.mod h1:a6zZmUTv2CgDH+qt9I3fpgd2ZFDANAsydJ0llR/UJWQ= -buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.0-20240529204957-84e5e35facb9.1/go.mod h1:i8KW5A3rChnuHEEO9wGUm/qmCu35Xvo+6ZzDlNr14YU= -buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-84e5e35facb9.1 h1:Fv9Z92tuBzGfNX8FCLY+KS/P2DOhpoU6Fv0CUAsEVtY= -buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-84e5e35facb9.1/go.mod h1:7DJyah9av4v/dKSMnTk1dTjF+l7ZeikR7px3g83wbXg= +buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-1e80fd5dcebf.3 h1:KixoYCHvSxzIcY6+8SMVx2H6RSzjPw9JurVJdwdd52g= +buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-00000000000000-1e80fd5dcebf.3/go.mod h1:tMQzkTb5yGwSBepMZLegwmmFb+A7QZk0rfK+aBZ7RV8= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.0-20240531221625-1e80fd5dcebf.1/go.mod h1:i8KW5A3rChnuHEEO9wGUm/qmCu35Xvo+6ZzDlNr14YU= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-1e80fd5dcebf.1 h1:tn/DyogJ+aFAMjLGjQNqyRmPE8mWQiae8WNyCcDk1/A= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-00000000000000-1e80fd5dcebf.1/go.mod h1:7DJyah9av4v/dKSMnTk1dTjF+l7ZeikR7px3g83wbXg= buf.build/gen/go/astria/primitives/grpc/go v1.3.0-20240529204957-2697e2110d78.3/go.mod h1:SdhNfNS2x19mgnKcRJYvB1z5fyLDE0ycJ5lF+H/Z3f8= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.0-20240529204957-2697e2110d78.1/go.mod h1:t7VCP+ORGGLNXUOwi6T6h99GntTUT7bWzK6BQa/uTbA= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.1-20240529204957-2697e2110d78.1 h1:FP1NQSG3SYFFFr4qRVIqD/VD51ipMzJ2XsnD6Qgc82w= diff --git a/grpc/execution/server_test.go b/grpc/execution/server_test.go index 7af30fc4e..6c111ba72 100644 --- a/grpc/execution/server_test.go +++ b/grpc/execution/server_test.go @@ -29,7 +29,6 @@ func TestExecutionService_GetGenesisInfo(t *testing.T) { require.True(t, bytes.Equal(genesisInfo.RollupId, hashedRollupId[:]), "RollupId is not correct") require.Equal(t, genesisInfo.GetSequencerGenesisBlockHeight(), ethservice.BlockChain().Config().AstriaSequencerInitialHeight, "SequencerInitialHeight is not correct") - require.Equal(t, genesisInfo.GetCelestiaBaseBlockHeight(), ethservice.BlockChain().Config().AstriaCelestiaInitialHeight, "CelestiaInitialHeight is not correct") require.Equal(t, genesisInfo.GetCelestiaBlockVariance(), ethservice.BlockChain().Config().AstriaCelestiaHeightVariance, "CelestiaHeightVariance is not correct") require.True(t, serviceV1Alpha1.genesisInfoCalled, "GetGenesisInfo should be called") } @@ -55,6 +54,8 @@ func TestExecutionServiceServerV1Alpha2_GetCommitmentState(t *testing.T) { require.True(t, bytes.Equal(commitmentState.Firm.Hash, firmBlock.Hash().Bytes()), "Firm Block Hashes do not match") require.True(t, bytes.Equal(commitmentState.Firm.ParentBlockHash, firmBlock.ParentHash.Bytes()), "Firm Block Parent Hash do not match") require.Equal(t, uint64(commitmentState.Firm.Number), firmBlock.Number.Uint64(), "Firm Block Number do not match") + require.Equal(t, commitmentState.BaseCelestiaHeight, ethservice.BlockChain().Config().AstriaCelestiaInitialHeight, "BaseCelestiaHeight is not correct") + require.True(t, serviceV1Alpha1.getCommitmentStateCalled, "GetCommitmentState should be called") } diff --git a/params/config.go b/params/config.go index fd8924bfe..09cb045e9 100644 --- a/params/config.go +++ b/params/config.go @@ -343,8 +343,8 @@ type ChainConfig struct { AstriaExtraDataOverride hexutil.Bytes `json:"astriaExtraDataOverride,omitempty"` AstriaRollupName string `json:"astriaRollupName"` AstriaSequencerInitialHeight uint32 `json:"astriaSequencerInitialHeight"` - AstriaCelestiaInitialHeight uint32 `json:"astriaCelestiaInitialHeight"` - AstriaCelestiaHeightVariance uint32 `json:"astriaCelestiaHeightVariance,omitempty"` + AstriaCelestiaInitialHeight uint64 `json:"astriaCelestiaInitialHeight"` + AstriaCelestiaHeightVariance uint64 `json:"astriaCelestiaHeightVariance,omitempty"` AstriaBridgeAddressConfigs []AstriaBridgeAddressConfig `json:"astriaBridgeAddresses,omitempty"` AstriaFeeCollectors map[uint32]common.Address `json:"astriaFeeCollectors"` AstriaEIP1559Params *AstriaEIP1559Params `json:"astriaEIP1559Params,omitempty"`