From c7a690d3982e664d17ef5e4b93623f847e31f5ea Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Sun, 13 Oct 2024 12:49:55 -0400 Subject: [PATCH] nit --- mod/node-api/handlers/proof/block_proposer.go | 5 +++-- .../handlers/proof/execution_fee_recipient.go | 2 +- mod/node-api/handlers/proof/execution_number.go | 2 +- mod/node-api/handlers/utils/id.go | 15 ++++++++------- mod/storage/pkg/block/store.go | 4 +--- mod/storage/pkg/block/store_test.go | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mod/node-api/handlers/proof/block_proposer.go b/mod/node-api/handlers/proof/block_proposer.go index c7e141db7a..a252ff9308 100644 --- a/mod/node-api/handlers/proof/block_proposer.go +++ b/mod/node-api/handlers/proof/block_proposer.go @@ -26,8 +26,9 @@ import ( "github.com/berachain/beacon-kit/mod/node-api/handlers/utils" ) -// GetBlockProposer returns the block proposer pubkey for the given block id -// along with a merkle proof that can be verified against the beacon block root. +// GetBlockProposer returns the block proposer pubkey for the given timestamp +// id along with a merkle proof that can be verified against the beacon block +// root. func (h *Handler[ BeaconBlockHeaderT, _, _, ContextT, _, _, ]) GetBlockProposer(c ContextT) (any, error) { diff --git a/mod/node-api/handlers/proof/execution_fee_recipient.go b/mod/node-api/handlers/proof/execution_fee_recipient.go index 5e4864931d..1513d3a047 100644 --- a/mod/node-api/handlers/proof/execution_fee_recipient.go +++ b/mod/node-api/handlers/proof/execution_fee_recipient.go @@ -27,7 +27,7 @@ import ( ) // GetExecutionFeeRecipient returns the fee recipient from the latest execution -// payload header for the given block id, along with the proof that can be +// payload header for the given timestamp id, along with the proof that can be // verified against the beacon block root. func (h *Handler[ BeaconBlockHeaderT, _, _, ContextT, _, _, diff --git a/mod/node-api/handlers/proof/execution_number.go b/mod/node-api/handlers/proof/execution_number.go index 1bb1d58ee5..4c128de2cf 100644 --- a/mod/node-api/handlers/proof/execution_number.go +++ b/mod/node-api/handlers/proof/execution_number.go @@ -27,7 +27,7 @@ import ( ) // GetExecutionNumber returns the block number from the latest execution -// payload header for the given block id, along with the proof that can be +// payload header for the given timestamp id, along with the proof that can be // verified against the beacon block root. func (h *Handler[ BeaconBlockHeaderT, _, _, ContextT, _, _, diff --git a/mod/node-api/handlers/utils/id.go b/mod/node-api/handlers/utils/id.go index 25469c8a1e..e31cda61af 100644 --- a/mod/node-api/handlers/utils/id.go +++ b/mod/node-api/handlers/utils/id.go @@ -70,17 +70,18 @@ func SlotFromBlockID[StorageBackendT interface { return storage.GetSlotByBlockRoot(root) } -// ParentSlotFromTimestampID returns the slot from the block timestamp ID. +// ParentSlotFromTimestampID returns the parent slot corresponding to the +// timestamp ID. // // NOTE: `timestampID` shares the same semantics as `stateID`, with the -// modification of being able to query by next block instead of -// . +// modification of being able to query by next block's instead of +// the current block's . // // The must be prefixed by the 't', followed by the timestamp -// in decimal notation. For example 't1728681738' corresponds to the slot with -// next block timestamp of 1728681738. Providing just the string '1728681738' -// (without the prefix 't') will query for the beacon block with slot -// 1728681738. +// in decimal UNIX notation. For example 't1728681738' corresponds to the slot +// which has the next block with a timestamp of 1728681738. Providing just the +// string '1728681738' (without the prefix 't') will query for the beacon block +// for slot 1728681738. func ParentSlotFromTimestampID[StorageBackendT interface { GetParentSlotByTimestamp(timestamp math.U64) (math.Slot, error) }](timestampID string, storage StorageBackendT) (math.Slot, error) { diff --git a/mod/storage/pkg/block/store.go b/mod/storage/pkg/block/store.go index dadd1e4bcc..30cd59d900 100644 --- a/mod/storage/pkg/block/store.go +++ b/mod/storage/pkg/block/store.go @@ -93,9 +93,7 @@ func (kv *KVStore[BeaconBlockT]) GetParentSlotByTimestamp( ) (math.Slot, error) { slot, _ := kv.timestamps.Peek(timestamp) if slot == 0 { - return slot, fmt.Errorf( - "parent slot not found at timestamp: %d", timestamp, - ) + return slot, fmt.Errorf("slot not found at timestamp: %d", timestamp) } return slot - 1, nil diff --git a/mod/storage/pkg/block/store_test.go b/mod/storage/pkg/block/store_test.go index 6416a463f6..14de7a5fef 100644 --- a/mod/storage/pkg/block/store_test.go +++ b/mod/storage/pkg/block/store_test.go @@ -65,7 +65,7 @@ func TestBlockStore(t *testing.T) { require.NoError(t, err) } - // Get the slots by roots & execution numbers. + // Get the slots by roots & timestamps. for i := math.Slot(3); i <= 7; i++ { slot, err = blockStore.GetSlotByBlockRoot([32]byte{byte(i)}) require.NoError(t, err) @@ -73,7 +73,7 @@ func TestBlockStore(t *testing.T) { slot, err = blockStore.GetParentSlotByTimestamp(i) require.NoError(t, err) - require.Equal(t, i, slot) + require.Equal(t, i-1, slot) slot, err = blockStore.GetSlotByStateRoot([32]byte{byte(i)}) require.NoError(t, err)