Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
joroshiba committed May 31, 2024
1 parent c143ea0 commit 38c4bd6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
10 changes: 5 additions & 5 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 0 additions & 7 deletions core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
3 changes: 2 additions & 1 deletion grpc/execution/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 38c4bd6

Please sign in to comment.