Skip to content
Open
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
14 changes: 9 additions & 5 deletions beacon-chain/core/gloas/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ func upgradeToGloas(beaconState state.BeaconState) (state.BeaconState, error) {
return nil, errors.Wrap(err, "could not compute empty execution requests root")
}

latestBlockHeader := beaconState.LatestBlockHeader()

s := &ethpb.BeaconStateGloas{
GenesisTime: uint64(beaconState.GenesisTime().Unix()),
GenesisValidatorsRoot: beaconState.GenesisValidatorsRoot(),
Expand All @@ -273,7 +275,7 @@ func upgradeToGloas(beaconState state.BeaconState) (state.BeaconState, error) {
CurrentVersion: params.BeaconConfig().GloasForkVersion,
Epoch: time.CurrentEpoch(beaconState),
},
LatestBlockHeader: beaconState.LatestBlockHeader(),
LatestBlockHeader: latestBlockHeader,
BlockRoots: beaconState.BlockRoots(),
StateRoots: beaconState.StateRoots(),
HistoricalRoots: beaconState.HistoricalRoots(),
Expand All @@ -294,12 +296,14 @@ func upgradeToGloas(beaconState state.BeaconState) (state.BeaconState, error) {
CurrentSyncCommittee: currentSyncCommittee,
NextSyncCommittee: nextSyncCommittee,
LatestExecutionPayloadBid: &ethpb.ExecutionPayloadBid{
ParentBlockHash: payloadHeader.ParentHash(),
ParentBlockRoot: latestBlockHeader.ParentRoot,
BlockHash: payloadHeader.BlockHash(),
GasLimit: payloadHeader.GasLimit(),
PrevRandao: payloadHeader.PrevRandao(),
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
ParentBlockHash: make([]byte, fieldparams.RootLength),
ParentBlockRoot: make([]byte, fieldparams.RootLength),
PrevRandao: make([]byte, fieldparams.RootLength),
GasLimit: payloadHeader.GasLimit(),
BuilderIndex: params.BeaconConfig().BuilderIndexSelfBuild,
Slot: latestBlockHeader.Slot,
ExecutionRequestsRoot: emptyExecutionRequestsRoot[:],
},
NextWithdrawalIndex: wi,
Expand Down
13 changes: 9 additions & 4 deletions beacon-chain/core/gloas/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
consensusblocks "github.com/OffchainLabs/prysm/v7/consensus-types/blocks"
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
"github.com/OffchainLabs/prysm/v7/crypto/bls"
"github.com/OffchainLabs/prysm/v7/encoding/bytesutil"
enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1"
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v7/testing/require"
Expand All @@ -35,7 +36,9 @@ func TestUpgradeToGloas_Basic(t *testing.T) {
require.NoError(t, st.SetPendingConsolidations([]*ethpb.PendingConsolidation{{SourceIndex: 3, TargetIndex: 4}}))

blockHash := bytes.Repeat([]byte{0xAB}, 32)
header := &enginev1.ExecutionPayloadHeaderDeneb{BlockHash: blockHash}
parentHash := bytes.Repeat([]byte{0xCD}, 32)
prevRandao := bytes.Repeat([]byte{0xEF}, 32)
header := &enginev1.ExecutionPayloadHeaderDeneb{BlockHash: blockHash, ParentHash: parentHash, PrevRandao: prevRandao}
wrappedHeader, err := consensusblocks.WrappedExecutionPayloadHeaderDeneb(header)
require.NoError(t, err)
require.NoError(t, st.SetLatestExecutionPayloadHeader(wrappedHeader))
Expand All @@ -60,9 +63,11 @@ func TestUpgradeToGloas_Basic(t *testing.T) {
copy(wantBlockHash[:], blockHash)
require.DeepSSZEqual(t, wantBlockHash, bid.BlockHash())
require.DeepSSZEqual(t, [20]byte{}, bid.FeeRecipient())
require.DeepSSZEqual(t, [32]byte{}, bid.ParentBlockHash())
require.DeepSSZEqual(t, [32]byte{}, bid.ParentBlockRoot())
require.DeepSSZEqual(t, [32]byte{}, bid.PrevRandao())
require.DeepSSZEqual(t, bytesutil.ToBytes32(parentHash), bid.ParentBlockHash())
require.DeepSSZEqual(t, bytesutil.ToBytes32(preForkState.LatestBlockHeader().ParentRoot), bid.ParentBlockRoot())
require.DeepSSZEqual(t, bytesutil.ToBytes32(prevRandao), bid.PrevRandao())
require.Equal(t, params.BeaconConfig().BuilderIndexSelfBuild, bid.BuilderIndex())
require.Equal(t, preForkState.LatestBlockHeader().Slot, bid.Slot())

latestBlockHash, err := mSt.LatestBlockHash()
require.NoError(t, err)
Expand Down
3 changes: 3 additions & 0 deletions changelog/terence_gloas-fork-bid-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- Explicitly set execution payload bid fields when upgrading to Gloas per consensus-specs#5553.
Loading