Use time.Time instead of uint64 for genesis time (#15419)

* Convert genesis times from seconds to time.Time

* Fixing failed forkchoice tests in a new commit so it doesn't get worse

Fixing failed spectest tests in a new commit so it doesn't get worse

Fixing forkchoice tests, then spectests

* Fixing forkchoice tests, then spectests. Now asking for help...

* Fix TestForkChoice_GetProposerHead

* Fix broken build

* Resolve TODO(preston) items

* Changelog fragment

* Resolve TODO(preston) items again

* Resolve lint issues

* Use consistant field names for sinceSlotStart (no spaces)

* Manu's feedback

* Renamed StartTime -> UnsafeStartTime, marked as deprecated because it doesn't handle overflow scenarios.
Renamed SlotTime -> StartTime
Renamed SlotAt -> At
Handled the error in cases where StartTime was used.

@james-prysm feedback

* Revert beacon-chain/blockchain/receive_block_test.go from 1b7844de

* Fixing issues after rebase

* Accepted suggestions from @potuz

* Remove CanonicalHeadSlot from merge conflicts

---------

Co-authored-by: potuz <potuz@prysmaticlabs.com>
This commit is contained in:
Preston Van Loon
2025-07-14 16:04:50 -05:00
committed by GitHub
parent 56e8881bc1
commit 499d27b6ae
143 changed files with 659 additions and 595 deletions

View File

@@ -242,7 +242,7 @@ func TestService_waitForStateInitialization(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
gt := time.Unix(int64(st.GenesisTime()), 0)
gt := st.GenesisTime()
s, gs := newService(ctx, &mock.ChainService{State: st, Genesis: gt, ValidatorsRoot: [32]byte{}})
expectedGenesisTime := gt
@@ -356,7 +356,8 @@ func TestService_Resync(t *testing.T) {
st, err := util.NewBeaconState()
require.NoError(t, err)
futureSlot := primitives.Slot(160)
require.NoError(t, st.SetGenesisTime(uint64(makeGenesisTime(futureSlot).Unix())))
genesis := makeGenesisTime(futureSlot)
require.NoError(t, st.SetGenesisTime(genesis))
return &mock.ChainService{
State: st,
Root: genesisRoot[:],
@@ -364,7 +365,7 @@ func TestService_Resync(t *testing.T) {
FinalizedCheckPoint: &eth.Checkpoint{
Epoch: slots.ToEpoch(futureSlot),
},
Genesis: time.Now(),
Genesis: genesis,
ValidatorsRoot: [32]byte{},
}
},
@@ -392,6 +393,7 @@ func TestService_Resync(t *testing.T) {
BlobStorage: filesystem.NewEphemeralBlobStorage(t),
})
assert.NotNil(t, s)
s.genesisTime = mc.Genesis
assert.Equal(t, primitives.Slot(0), s.cfg.Chain.HeadSlot())
err := s.Resync()
if tt.wantedErr != "" {