Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion beacon-chain/rpc/eth/beacon/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func TestGetSpec(t *testing.T) {
config.BellatrixForkEpoch = 101
config.CapellaForkVersion = []byte("CapellaForkVersion")
config.CapellaForkEpoch = 103
config.DenebForkVersion = []byte("DenebForkVersion")
config.DenebForkEpoch = 105
config.BLSWithdrawalPrefixByte = byte('b')
config.ETH1AddressWithdrawalPrefixByte = byte('c')
config.GenesisDelay = 24
Expand Down Expand Up @@ -136,7 +138,7 @@ func TestGetSpec(t *testing.T) {
resp, err := server.GetSpec(context.Background(), &emptypb.Empty{})
require.NoError(t, err)

assert.Equal(t, 105, len(resp.Data))
assert.Equal(t, 107, len(resp.Data))
for k, v := range resp.Data {
switch k {
case "CONFIG_NAME":
Expand Down Expand Up @@ -205,6 +207,10 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "0x"+hex.EncodeToString([]byte("CapellaForkVersion")), v)
case "CAPELLA_FORK_EPOCH":
assert.Equal(t, "103", v)
case "DENEB_FORK_VERSION":
assert.Equal(t, "0x"+hex.EncodeToString([]byte("DenebForkVersion")), v)
case "DENEB_FORK_EPOCH":
assert.Equal(t, "105", v)
case "MIN_ANCHOR_POW_BLOCK_DIFFICULTY":
assert.Equal(t, "1000", v)
case "BLS_WITHDRAWAL_PREFIX":
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/state/state-native/beacon_state_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type BeaconState struct {
nextSyncCommittee *ethpb.SyncCommittee
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
latestExecutionPayloadHeaderDeneb *enginev1.ExecutionPayloadHeaderDeneb
nextWithdrawalIndex uint64
nextWithdrawalValidatorIndex primitives.ValidatorIndex

Expand Down
1 change: 1 addition & 0 deletions beacon-chain/state/state-native/beacon_state_minimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type BeaconState struct {
nextSyncCommittee *ethpb.SyncCommittee
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
latestExecutionPayloadHeaderDeneb *enginev1.ExecutionPayloadHeaderDeneb
nextWithdrawalIndex uint64
nextWithdrawalValidatorIndex primitives.ValidatorIndex

Expand Down
36 changes: 36 additions & 0 deletions beacon-chain/state/state-native/getters_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ func TestBeaconState_LatestBlockHeader_Capella(t *testing.T) {
)
}

func TestBeaconState_LatestBlockHeader_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateLatestBlockHeader(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{})
},
func(BH *ethpb.BeaconBlockHeader) (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{LatestBlockHeader: BH})
},
)
}

func TestBeaconState_BlockRoots_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateBlockRootsNative(
t,
Expand Down Expand Up @@ -104,6 +116,18 @@ func TestBeaconState_BlockRoots_Capella(t *testing.T) {
)
}

func TestBeaconState_BlockRoots_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateBlockRootsNative(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{})
},
func(BR [][]byte) (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{BlockRoots: BR})
},
)
}

func TestBeaconState_BlockRootAtIndex_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateBlockRootAtIndexNative(
t,
Expand Down Expand Up @@ -151,3 +175,15 @@ func TestBeaconState_BlockRootAtIndex_Capella(t *testing.T) {
},
)
}

func TestBeaconState_BlockRootAtIndex_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateBlockRootAtIndexNative(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{})
},
func(BR [][]byte) (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{BlockRoots: BR})
},
)
}
64 changes: 64 additions & 0 deletions beacon-chain/state/state-native/getters_checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func TestBeaconState_PreviousJustifiedCheckpointNil_Capella(t *testing.T) {
})
}

func TestBeaconState_PreviousJustifiedCheckpointNil_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpointNil(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{})
})
}

func TestBeaconState_PreviousJustifiedCheckpoint_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
t,
Expand Down Expand Up @@ -73,6 +81,14 @@ func TestBeaconState_PreviousJustifiedCheckpoint_Capella(t *testing.T) {
})
}

func TestBeaconState_PreviousJustifiedCheckpoint_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStatePreviousJustifiedCheckpoint(
t,
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{PreviousJustifiedCheckpoint: cp})
})
}

func TestBeaconState_CurrentJustifiedCheckpointNil_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
t,
Expand Down Expand Up @@ -105,6 +121,14 @@ func TestBeaconState_CurrentJustifiedCheckpointNil_Capella(t *testing.T) {
})
}

func TestBeaconState_CurrentJustifiedCheckpointNil_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpointNil(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{})
})
}

func TestBeaconState_CurrentJustifiedCheckpoint_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
t,
Expand Down Expand Up @@ -137,6 +161,14 @@ func TestBeaconState_CurrentJustifiedCheckpoint_Capella(t *testing.T) {
})
}

func TestBeaconState_CurrentJustifiedCheckpoint_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateCurrentJustifiedCheckpoint(
t,
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{CurrentJustifiedCheckpoint: cp})
})
}

func TestBeaconState_FinalizedCheckpointNil_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
t,
Expand Down Expand Up @@ -169,6 +201,14 @@ func TestBeaconState_FinalizedCheckpointNil_Capella(t *testing.T) {
})
}

func TestBeaconState_FinalizedCheckpointNil_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateFinalizedCheckpointNil(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{})
})
}

func TestBeaconState_FinalizedCheckpoint_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
t,
Expand Down Expand Up @@ -201,6 +241,14 @@ func TestBeaconState_FinalizedCheckpoint_Capella(t *testing.T) {
})
}

func TestBeaconState_FinalizedCheckpoint_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateFinalizedCheckpoint(
t,
func(cp *ethpb.Checkpoint) (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{FinalizedCheckpoint: cp})
})
}

func TestBeaconState_JustificationBitsNil_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateJustificationBitsNil(
t,
Expand Down Expand Up @@ -233,6 +281,14 @@ func TestBeaconState_JustificationBitsNil_Capella(t *testing.T) {
})
}

func TestBeaconState_JustificationBitsNil_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateJustificationBitsNil(
t,
func() (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{})
})
}

func TestBeaconState_JustificationBits_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateJustificationBits(
t,
Expand Down Expand Up @@ -264,3 +320,11 @@ func TestBeaconState_JustificationBits_Capella(t *testing.T) {
return InitializeFromProtoUnsafeCapella(&ethpb.BeaconStateCapella{JustificationBits: bits})
})
}

func TestBeaconState_JustificationBits_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateJustificationBits(
t,
func(bits bitfield.Bitvector4) (state.BeaconState, error) {
return InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{JustificationBits: bits})
})
}
11 changes: 10 additions & 1 deletion beacon-chain/state/state-native/getters_payload_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData,
if b.version == version.Bellatrix {
return blocks.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeaderVal())
}
return blocks.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapellaVal(), 0)

if b.version == version.Capella {
return blocks.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapellaVal(), 0)
}

return blocks.WrappedExecutionPayloadHeaderDeneb(b.latestExecutionPayloadHeaderDenebVal(), 0)
}

// latestExecutionPayloadHeaderVal of the beacon state.
Expand All @@ -34,3 +39,7 @@ func (b *BeaconState) latestExecutionPayloadHeaderVal() *enginev1.ExecutionPaylo
func (b *BeaconState) latestExecutionPayloadHeaderCapellaVal() *enginev1.ExecutionPayloadHeaderCapella {
return ethpb.CopyExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapella)
}

func (b *BeaconState) latestExecutionPayloadHeaderDenebVal() *enginev1.ExecutionPayloadHeaderDeneb {
return ethpb.CopyExecutionPayloadHeaderDeneb(b.latestExecutionPayloadHeaderDeneb)
}
72 changes: 72 additions & 0 deletions beacon-chain/state/state-native/getters_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,37 @@ func (b *BeaconState) ToProtoUnsafe() interface{} {
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
HistoricalSummaries: b.historicalSummaries,
}
case version.Deneb:
return &ethpb.BeaconStateDeneb{
GenesisTime: b.genesisTime,
GenesisValidatorsRoot: gvrCopy[:],
Slot: b.slot,
Fork: b.fork,
LatestBlockHeader: b.latestBlockHeader,
BlockRoots: b.blockRoots.Slice(),
StateRoots: b.stateRoots.Slice(),
HistoricalRoots: b.historicalRoots.Slice(),
Eth1Data: b.eth1Data,
Eth1DataVotes: b.eth1DataVotes,
Eth1DepositIndex: b.eth1DepositIndex,
Validators: b.validators,
Balances: b.balances,
RandaoMixes: b.randaoMixes.Slice(),
Slashings: b.slashings,
PreviousEpochParticipation: b.previousEpochParticipation,
CurrentEpochParticipation: b.currentEpochParticipation,
JustificationBits: b.justificationBits,
PreviousJustifiedCheckpoint: b.previousJustifiedCheckpoint,
CurrentJustifiedCheckpoint: b.currentJustifiedCheckpoint,
FinalizedCheckpoint: b.finalizedCheckpoint,
InactivityScores: b.inactivityScores,
CurrentSyncCommittee: b.currentSyncCommittee,
NextSyncCommittee: b.nextSyncCommittee,
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderDeneb,
NextWithdrawalIndex: b.nextWithdrawalIndex,
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
HistoricalSummaries: b.historicalSummaries,
}
default:
return nil
}
Expand Down Expand Up @@ -255,6 +286,37 @@ func (b *BeaconState) ToProto() interface{} {
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
HistoricalSummaries: b.historicalSummariesVal(),
}
case version.Deneb:
return &ethpb.BeaconStateDeneb{
GenesisTime: b.genesisTime,
GenesisValidatorsRoot: gvrCopy[:],
Slot: b.slot,
Fork: b.forkVal(),
LatestBlockHeader: b.latestBlockHeaderVal(),
BlockRoots: b.blockRoots.Slice(),
StateRoots: b.stateRoots.Slice(),
HistoricalRoots: b.historicalRoots.Slice(),
Eth1Data: b.eth1DataVal(),
Eth1DataVotes: b.eth1DataVotesVal(),
Eth1DepositIndex: b.eth1DepositIndex,
Validators: b.validatorsVal(),
Balances: b.balancesVal(),
RandaoMixes: b.randaoMixes.Slice(),
Slashings: b.slashingsVal(),
PreviousEpochParticipation: b.previousEpochParticipationVal(),
CurrentEpochParticipation: b.currentEpochParticipationVal(),
JustificationBits: b.justificationBitsVal(),
PreviousJustifiedCheckpoint: b.previousJustifiedCheckpointVal(),
CurrentJustifiedCheckpoint: b.currentJustifiedCheckpointVal(),
FinalizedCheckpoint: b.finalizedCheckpointVal(),
InactivityScores: b.inactivityScoresVal(),
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
NextSyncCommittee: b.nextSyncCommitteeVal(),
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderDenebVal(),
NextWithdrawalIndex: b.nextWithdrawalIndex,
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
HistoricalSummaries: b.historicalSummariesVal(),
}
default:
return nil
}
Expand Down Expand Up @@ -338,3 +400,13 @@ func ProtobufBeaconStateCapella(s interface{}) (*ethpb.BeaconStateCapella, error
}
return pbState, nil
}

// ProtobufBeaconStateDeneb transforms an input into beacon state Deneb in the form of protobuf.
// Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconStateDeneb(s interface{}) (*ethpb.BeaconStateDeneb, error) {
pbState, ok := s.(*ethpb.BeaconStateDeneb)
if !ok {
return nil, errors.New("input is not type pb.ProtobufBeaconStateDeneb")
}
return pbState, nil
}
6 changes: 6 additions & 0 deletions beacon-chain/state/state-native/getters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func TestBeaconState_SlotDataRace_Capella(t *testing.T) {
})
}

func TestBeaconState_SlotDataRace_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateSlotDataRace(t, func() (state.BeaconState, error) {
return InitializeFromProtoDeneb(&ethpb.BeaconStateDeneb{Slot: 1})
})
}

func TestBeaconState_MatchCurrentJustifiedCheckpt_Phase0(t *testing.T) {
testtmpl.VerifyBeaconStateMatchCurrentJustifiedCheckptNative(
t,
Expand Down
8 changes: 8 additions & 0 deletions beacon-chain/state/state-native/getters_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func TestBeaconState_ValidatorAtIndexReadOnly_HandlesNilSlice_Capella(t *testing
})
}

func TestBeaconState_ValidatorAtIndexReadOnly_HandlesNilSlice_Deneb(t *testing.T) {
testtmpl.VerifyBeaconStateValidatorAtIndexReadOnlyHandlesNilSlice(t, func() (state.BeaconState, error) {
return statenative.InitializeFromProtoUnsafeDeneb(&ethpb.BeaconStateDeneb{
Validators: nil,
})
})
}

func TestValidatorIndexOutOfRangeError(t *testing.T) {
err := statenative.NewValidatorIndexOutOfRangeError(1)
require.Equal(t, err.Error(), "index 1 out of range")
Expand Down
Loading