Skip to content

Commit

Permalink
Merge branch 'develop' into publish_blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
0w3n-d committed Oct 1, 2024
2 parents 1898ac0 + 6d499bc commit 9dd4d31
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve

### Changed

- Electra: Updated interop genesis generator to support Electra.
- `getLocalPayload` has been refactored to enable work in ePBS branch.
- `TestNodeServer_GetPeer` and `TestNodeServer_ListPeers` test flakes resolved by iterating the whole peer list to find
a match rather than taking the first peer in the map.
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/prysm/beacon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ go_library(
"//consensus-types/blocks:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/validator:go_default_library",
"//monitoring/tracing/trace:go_default_library",
"//encoding/bytesutil:go_default_library",
"//monitoring/tracing/trace:go_default_library",
"//network/httputil:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
Expand Down
4 changes: 4 additions & 0 deletions runtime/interop/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ go_test(
"generate_genesis_state_bellatrix_test.go",
"generate_genesis_state_test.go",
"generate_keys_test.go",
"premine-state_test.go",
],
data = [
"keygen_test_vector.yaml",
Expand All @@ -61,9 +62,12 @@ go_test(
"//container/trie:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//runtime/version:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"//time:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
"@com_github_go_yaml_yaml//:go_default_library",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
Expand Down
72 changes: 72 additions & 0 deletions runtime/interop/premine-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ func (s *PremineGenesisConfig) empty() (state.BeaconState, error) {
if err != nil {
return nil, err
}
case version.Electra:
e, err = state_native.InitializeFromProtoElectra(&ethpb.BeaconStateElectra{})
if err != nil {
return nil, err
}
default:
return nil, errUnsupportedVersion
}
Expand Down Expand Up @@ -336,6 +341,8 @@ func (s *PremineGenesisConfig) setFork(g state.BeaconState) error {
pv, cv = params.BeaconConfig().BellatrixForkVersion, params.BeaconConfig().CapellaForkVersion
case version.Deneb:
pv, cv = params.BeaconConfig().CapellaForkVersion, params.BeaconConfig().DenebForkVersion
case version.Electra:
pv, cv = params.BeaconConfig().ElectraForkVersion, params.BeaconConfig().ElectraForkVersion
default:
return errUnsupportedVersion
}
Expand Down Expand Up @@ -524,6 +531,39 @@ func (s *PremineGenesisConfig) setLatestBlockHeader(g state.BeaconState) error {
BlsToExecutionChanges: make([]*ethpb.SignedBLSToExecutionChange, 0),
BlobKzgCommitments: make([][]byte, 0),
}
case version.Electra:
body = &ethpb.BeaconBlockBodyElectra{
RandaoReveal: make([]byte, 96),
Eth1Data: &ethpb.Eth1Data{
DepositRoot: make([]byte, 32),
BlockHash: make([]byte, 32),
},
Graffiti: make([]byte, 32),
SyncAggregate: &ethpb.SyncAggregate{
SyncCommitteeBits: make([]byte, fieldparams.SyncCommitteeLength/8),
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength),
},
ExecutionPayload: &enginev1.ExecutionPayloadElectra{
ParentHash: make([]byte, 32),
FeeRecipient: make([]byte, 20),
StateRoot: make([]byte, 32),
ReceiptsRoot: make([]byte, 32),
LogsBloom: make([]byte, 256),
PrevRandao: make([]byte, 32),
ExtraData: make([]byte, 0),
BaseFeePerGas: make([]byte, 32),
BlockHash: make([]byte, 32),
Transactions: make([][]byte, 0),
Withdrawals: make([]*enginev1.Withdrawal, 0),
},
BlsToExecutionChanges: make([]*ethpb.SignedBLSToExecutionChange, 0),
BlobKzgCommitments: make([][]byte, 0),
ExecutionRequests: &enginev1.ExecutionRequests{
Deposits: make([]*enginev1.DepositRequest, 0),
Withdrawals: make([]*enginev1.WithdrawalRequest, 0),
Consolidations: make([]*enginev1.ConsolidationRequest, 0),
},
}
default:
return errUnsupportedVersion
}
Expand Down Expand Up @@ -640,6 +680,38 @@ func (s *PremineGenesisConfig) setExecutionPayload(g state.BeaconState) error {
if err != nil {
return err
}
case version.Electra:
payload := &enginev1.ExecutionPayloadElectra{
ParentHash: gb.ParentHash().Bytes(),
FeeRecipient: gb.Coinbase().Bytes(),
StateRoot: gb.Root().Bytes(),
ReceiptsRoot: gb.ReceiptHash().Bytes(),
LogsBloom: gb.Bloom().Bytes(),
PrevRandao: params.BeaconConfig().ZeroHash[:],
BlockNumber: gb.NumberU64(),
GasLimit: gb.GasLimit(),
GasUsed: gb.GasUsed(),
Timestamp: gb.Time(),
ExtraData: gb.Extra()[:32],
BaseFeePerGas: bytesutil.PadTo(bytesutil.ReverseByteOrder(gb.BaseFee().Bytes()), fieldparams.RootLength),
BlockHash: gb.Hash().Bytes(),
Transactions: make([][]byte, 0),
Withdrawals: make([]*enginev1.Withdrawal, 0),
ExcessBlobGas: *gb.ExcessBlobGas(),
BlobGasUsed: *gb.BlobGasUsed(),
}
wep, err := blocks.WrappedExecutionPayloadElectra(payload)
if err != nil {
return err
}
eph, err := blocks.PayloadToHeaderElectra(wep)
if err != nil {
return err
}
ed, err = blocks.WrappedExecutionPayloadHeaderElectra(eph)
if err != nil {
return err
}
default:
return errUnsupportedVersion
}
Expand Down
26 changes: 26 additions & 0 deletions runtime/interop/premine-state_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package interop

import (
"context"
"math/big"
"testing"

"github.com/ethereum/go-ethereum/core/types"
"github.com/prysmaticlabs/prysm/v5/runtime/version"
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/time"
)

func TestPremineGenesis_Electra(t *testing.T) {
one := uint64(1)

genesis := types.NewBlockWithHeader(&types.Header{
Time: uint64(time.Now().Unix()),
Extra: make([]byte, 32),
BaseFee: big.NewInt(1),
ExcessBlobGas: &one,
BlobGasUsed: &one,
})
_, err := NewPreminedGenesis(context.Background(), genesis.Time(), 10, 10, version.Electra, genesis)
require.NoError(t, err)
}

0 comments on commit 9dd4d31

Please sign in to comment.