Skip to content

Commit

Permalink
time is sec, get from executionPayloadHeader
Browse files Browse the repository at this point in the history
Signed-off-by: nidhi-singh02 <[email protected]>
  • Loading branch information
nidhi-singh02 committed Sep 25, 2024
1 parent 5a6d4f5 commit 9e44788
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mod/cli/pkg/commands/genesis/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func AddExecutionPayloadCmd(chainSpec common.ChainSpec) *cobra.Command {
}

// Set the genesis time from app Genesis in the payload
payload.Timestamp = uint64(appGenesis.GenesisTime.UnixNano())
payload.Timestamp = uint64(appGenesis.GenesisTime.Unix())

// create the app state
appGenesisState, err := genutiltypes.GenesisStateFromAppGenesis(
Expand Down
3 changes: 2 additions & 1 deletion mod/consensus-types/pkg/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Genesis[
DepositT any,
ExecutionPayloadHeaderT interface {
NewFromJSON([]byte, uint32) (ExecutionPayloadHeaderT, error)
GetTimestamp() math.U64
},
] struct {
// ForkVersion is the fork version of the genesis slot.
Expand Down Expand Up @@ -76,7 +77,7 @@ func (g *Genesis[

// GetGenesisTime returns the genesis time.
func (g *Genesis[DepositT, ExecutionPayloadHeaderT]) GetGenesisTime() uint64 {
return g.GetGenesisTime()
return uint64(g.ExecutionPayloadHeader.GetTimestamp())
}

// UnmarshalJSON for Genesis.
Expand Down
7 changes: 0 additions & 7 deletions mod/node-api/handlers/beacon/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package beacon

import (
"encoding/hex"
"github.com/berachain/beacon-kit/mod/errors"
"strconv"

beacontypes "github.com/berachain/beacon-kit/mod/node-api/handlers/beacon/types"
Expand Down Expand Up @@ -50,12 +49,6 @@ func (h *Handler[_, ContextT, _, _, _]) GetGenesis(_ ContextT) (any, error) {
return nil, err
}

if genesisTime == 0 {
h.Logger().Warn("Genesis time is 0, this may indicate an initialization issue")
// Optionally, you might want to return an error here instead of continuing
return nil, errors.New("genesis time not properly initialized")
}

return types.Wrap(beacontypes.GenesisData{
GenesisTime: strconv.FormatUint(genesisTime, 10),
GenesisValidatorsRoot: genesisRoot,
Expand Down
7 changes: 0 additions & 7 deletions mod/state-transition/pkg/core/state_processor_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package core

import (
"fmt"
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/constants"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/hex"
Expand All @@ -48,10 +47,6 @@ func (sp *StateProcessor[
executionPayloadHeader ExecutionPayloadHeaderT,
genesisVersion common.Version,
) (transition.ValidatorUpdates, error) {

fmt.Printf("Execution Payload Header InitializePreminedBeaconStateFromEth1 %v %v \n",
executionPayloadHeader.GetTimestamp(), executionPayloadHeader.GetBlockHash())

var (
blkHeader BeaconBlockHeaderT
blkBody BeaconBlockBodyT
Expand Down Expand Up @@ -158,9 +153,7 @@ func (sp *StateProcessor[
}

genesisTime := uint64(executionPayloadHeader.GetTimestamp())
fmt.Printf("Setting genesis time %v \n", genesisTime)
if err = st.SetGenesisTime(genesisTime); err != nil {
fmt.Errorf("failed to set genesis time %v", err)
return nil, err
}

Expand Down

0 comments on commit 9e44788

Please sign in to comment.