Skip to content

Commit

Permalink
Capella E2E (#11951)
Browse files Browse the repository at this point in the history
* save changes

* fix build

* fix build

* fix signatures

* fix

* fix

* finally fix it

* mainnet

* deps

* make it 10

* back to phase0

* fix build

* gofmt

* etherbase

* rm logs

* build

* james review

* fix yaml

* Update testing/endtoend/evaluators/fork.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* radek's review

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
  • Loading branch information
nisdas and rkapka authored Feb 10, 2023
1 parent 5092738 commit 76ed634
Show file tree
Hide file tree
Showing 27 changed files with 558 additions and 182 deletions.
1 change: 1 addition & 0 deletions beacon-chain/core/validators/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators",
visibility = [
"//beacon-chain:__subpackages__",
"//testing/endtoend:__subpackages__",
"//testing/spectest:__subpackages__",
],
deps = [
Expand Down
8 changes: 4 additions & 4 deletions beacon-chain/execution/engine_client_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func FuzzExchangeTransitionConfiguration(f *testing.F) {

func FuzzExecutionPayload(f *testing.F) {
logsBloom := [256]byte{'j', 'u', 'n', 'k'}
execData := &beacon.ExecutableDataV1{
execData := &beacon.ExecutableData{
ParentHash: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}),
FeeRecipient: common.Address([20]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}),
StateRoot: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}),
Expand All @@ -135,7 +135,7 @@ func FuzzExecutionPayload(f *testing.F) {
assert.NoError(f, err)
f.Add(output)
f.Fuzz(func(t *testing.T, jsonBlob []byte) {
gethResp := &beacon.ExecutableDataV1{}
gethResp := &beacon.ExecutableData{}
prysmResp := &pb.ExecutionPayload{}
gethErr := json.Unmarshal(jsonBlob, gethResp)
prysmErr := json.Unmarshal(jsonBlob, prysmResp)
Expand All @@ -147,10 +147,10 @@ func FuzzExecutionPayload(f *testing.F) {
gethBlob, gethErr := json.Marshal(gethResp)
prysmBlob, prysmErr := json.Marshal(prysmResp)
assert.Equal(t, gethErr != nil, prysmErr != nil, "geth and prysm unmarshaller return inconsistent errors")
newGethResp := &beacon.ExecutableDataV1{}
newGethResp := &beacon.ExecutableData{}
newGethErr := json.Unmarshal(prysmBlob, newGethResp)
assert.NoError(t, newGethErr)
newGethResp2 := &beacon.ExecutableDataV1{}
newGethResp2 := &beacon.ExecutableData{}
newGethErr = json.Unmarshal(gethBlob, newGethResp2)
assert.NoError(t, newGethErr)

Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/execution/rpc_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (s *Service) newRPCClientWithAuth(ctx context.Context, endpoint network.End
}
switch u.Scheme {
case "http", "https":
client, err = gethRPC.DialHTTPWithClient(endpoint.Url, endpoint.HttpClient())
client, err = gethRPC.DialOptions(ctx, endpoint.Url, gethRPC.WithHTTPClient(endpoint.HttpClient()))
if err != nil {
return nil, err
}
Expand Down
11 changes: 11 additions & 0 deletions beacon-chain/execution/testing/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/params"
clparams "github.com/prysmaticlabs/prysm/v3/config/params"
"github.com/prysmaticlabs/prysm/v3/time/slots"
)

// defaultMinerAddress is used to send deposits and test transactions in the e2e test.
Expand Down Expand Up @@ -83,6 +84,15 @@ func GethTestnetGenesis(genesisTime uint64, cfg *clparams.BeaconChainConfig) cor
if !ok {
panic(fmt.Sprintf("unable to parse TerminalTotalDifficulty as an integer = %s", clparams.BeaconConfig().TerminalTotalDifficulty))
}
var shanghaiTime *uint64
if cfg.CapellaForkEpoch != math.MaxUint64 {
startSlot, err := slots.EpochStart(cfg.CapellaForkEpoch)
if err == nil {
startTime := slots.StartTime(genesisTime, startSlot)
newTime := uint64(startTime.Unix())
shanghaiTime = &newTime
}
}
cc := &params.ChainConfig{
ChainID: big.NewInt(defaultTestChainId),
HomesteadBlock: bigz,
Expand All @@ -106,6 +116,7 @@ func GethTestnetGenesis(genesisTime uint64, cfg *clparams.BeaconChainConfig) cor
Period: cfg.SecondsPerETH1Block,
Epoch: 20000,
},
ShanghaiTime: shanghaiTime,
}
da := defaultDepositContractAllocation(cfg.DepositContractAddress)
ma := minerAllocation()
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func (e *EnumValue) String() string {
func (e EnumValue) GenericFlag() *cli.GenericFlag {
*e.Destination = e.Value
var i cli.Generic = &e
return &cli.GenericFlag{Name: e.Name, Usage: e.Usage, Destination: &i, Value: i}
return &cli.GenericFlag{Name: e.Name, Usage: e.Usage, Destination: i, Value: i}
}
4 changes: 3 additions & 1 deletion config/params/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,18 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte {
fmt.Sprintf("EPOCHS_PER_ETH1_VOTING_PERIOD: %d", cfg.EpochsPerEth1VotingPeriod),
fmt.Sprintf("SHARD_COMMITTEE_PERIOD: %d", cfg.ShardCommitteePeriod),
fmt.Sprintf("MIN_VALIDATOR_WITHDRAWABILITY_DELAY: %d", cfg.MinValidatorWithdrawabilityDelay),
fmt.Sprintf("MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: %d", cfg.MaxValidatorsPerWithdrawalsSweep),
fmt.Sprintf("MAX_SEED_LOOKAHEAD: %d", cfg.MaxSeedLookahead),
fmt.Sprintf("EJECTION_BALANCE: %d", cfg.EjectionBalance),
fmt.Sprintf("MIN_PER_EPOCH_CHURN_LIMIT: %d", cfg.MinPerEpochChurnLimit),
fmt.Sprintf("DEPOSIT_CHAIN_ID: %d", cfg.DepositChainID),
fmt.Sprintf("DEPOSIT_NETWORK_ID: %d", cfg.DepositNetworkID),
fmt.Sprintf("ALTAIR_FORK_EPOCH: %d", cfg.AltairForkEpoch),
fmt.Sprintf("ALTAIR_FORK_VERSION: %#x", cfg.AltairForkVersion),
fmt.Sprintf("CAPELLA_FORK_VERSION: %#x", cfg.CapellaForkVersion),
fmt.Sprintf("BELLATRIX_FORK_EPOCH: %d", cfg.BellatrixForkEpoch),
fmt.Sprintf("BELLATRIX_FORK_VERSION: %#x", cfg.BellatrixForkVersion),
fmt.Sprintf("CAPELLA_FORK_EPOCH: %d", cfg.CapellaForkEpoch),
fmt.Sprintf("CAPELLA_FORK_VERSION: %#x", cfg.CapellaForkVersion),
fmt.Sprintf("INACTIVITY_SCORE_BIAS: %d", cfg.InactivityScoreBias),
fmt.Sprintf("INACTIVITY_SCORE_RECOVERY_RATE: %d", cfg.InactivityScoreRecoveryRate),
fmt.Sprintf("TERMINAL_TOTAL_DIFFICULTY: %s", cfg.TerminalTotalDifficulty),
Expand Down
6 changes: 3 additions & 3 deletions config/params/testdata/e2e_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BELLATRIX_FORK_VERSION: 0x020000fd
BELLATRIX_FORK_EPOCH: 8
# Capella
CAPELLA_FORK_VERSION: 0x030000fd
CAPELLA_FORK_EPOCH: 18446744073709551615
CAPELLA_FORK_EPOCH: 10


# Time parameters
Expand All @@ -49,8 +49,8 @@ CAPELLA_FORK_EPOCH: 18446744073709551615
SECONDS_PER_SLOT: 10 # Override for e2e tests
# 14 (estimate from Eth1 mainnet)
SECONDS_PER_ETH1_BLOCK: 2 # Override for e2e tests
# 2**8 (= 256) epochs
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
# [customized] faster time for withdrawals
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 1
# [customized] higher frequency of committee turnover and faster time to acceptable voluntary exit
SHARD_COMMITTEE_PERIOD: 4 # Override for e2e tests
# [customized] process deposits more quickly, but insecure
Expand Down
18 changes: 12 additions & 6 deletions config/params/testnet_e2e_config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package params

const (
altairE2EForkEpoch = 6
bellatrixE2EForkEpoch = 8
AltairE2EForkEpoch = 6
BellatrixE2EForkEpoch = 8
CapellaE2EForkEpoch = 10
)

// E2ETestConfig retrieves the configurations made specifically for E2E testing.
Expand All @@ -17,6 +18,7 @@ func E2ETestConfig() *BeaconChainConfig {
e2eConfig.MinGenesisActiveValidatorCount = 256
e2eConfig.GenesisDelay = 10 // 10 seconds so E2E has enough time to process deposits and get started.
e2eConfig.ChurnLimitQuotient = 65536
e2eConfig.MaxValidatorsPerWithdrawalsSweep = 128

// Time parameters.
e2eConfig.SecondsPerSlot = 10
Expand All @@ -26,14 +28,16 @@ func E2ETestConfig() *BeaconChainConfig {
e2eConfig.EpochsPerEth1VotingPeriod = 2
e2eConfig.ShardCommitteePeriod = 4
e2eConfig.MaxSeedLookahead = 1
e2eConfig.MinValidatorWithdrawabilityDelay = 1

// PoW parameters.
e2eConfig.DepositChainID = 1337 // Chain ID of eth1 dev net.
e2eConfig.DepositNetworkID = 1337 // Network ID of eth1 dev net.

// Fork Parameters.
e2eConfig.AltairForkEpoch = altairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = bellatrixE2EForkEpoch
e2eConfig.AltairForkEpoch = AltairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = BellatrixE2EForkEpoch
e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch

// Terminal Total Difficulty.
e2eConfig.TerminalTotalDifficulty = "480"
Expand Down Expand Up @@ -64,14 +68,16 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
e2eConfig.SqrRootSlotsPerEpoch = 5
e2eConfig.SecondsPerETH1Block = 2
e2eConfig.ShardCommitteePeriod = 4
e2eConfig.MinValidatorWithdrawabilityDelay = 1

// PoW parameters.
e2eConfig.DepositChainID = 1337 // Chain ID of eth1 dev net.
e2eConfig.DepositNetworkID = 1337 // Network ID of eth1 dev net.

// Altair Fork Parameters.
e2eConfig.AltairForkEpoch = altairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = bellatrixE2EForkEpoch
e2eConfig.AltairForkEpoch = AltairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = BellatrixE2EForkEpoch
e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch

// Terminal Total Difficulty.
e2eConfig.TerminalTotalDifficulty = "480"
Expand Down
2 changes: 1 addition & 1 deletion config/params/testnet_prater_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func PraterConfig() *BeaconChainConfig {
cfg.DepositNetworkID = eth1Params.GoerliChainConfig.ChainID.Uint64()
cfg.AltairForkEpoch = 36660
cfg.AltairForkVersion = []byte{0x1, 0x0, 0x10, 0x20}
cfg.CapellaForkVersion = []byte{0x3, 0x0, 0x10, 0x20}
cfg.BellatrixForkEpoch = 112260
cfg.BellatrixForkVersion = []byte{0x2, 0x0, 0x10, 0x20}
cfg.CapellaForkVersion = []byte{0x3, 0x0, 0x10, 0x20}
cfg.TerminalTotalDifficulty = "10790000"
cfg.DepositContractAddress = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
cfg.InitializeForkSchedule()
Expand Down
4 changes: 4 additions & 0 deletions consensus-types/blocks/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ func BuildSignedBeaconBlockFromExecutionPayload(
// This is particularly useful for using the values from API calls.
func BeaconBlockContainerToSignedBeaconBlock(obj *eth.BeaconBlockContainer) (interfaces.ReadOnlySignedBeaconBlock, error) {
switch obj.Block.(type) {
case *eth.BeaconBlockContainer_BlindedCapellaBlock:
return NewSignedBeaconBlock(obj.GetBlindedCapellaBlock())
case *eth.BeaconBlockContainer_CapellaBlock:
return NewSignedBeaconBlock(obj.GetCapellaBlock())
case *eth.BeaconBlockContainer_BlindedBellatrixBlock:
return NewSignedBeaconBlock(obj.GetBlindedBellatrixBlock())
case *eth.BeaconBlockContainer_BellatrixBlock:
Expand Down
Loading

0 comments on commit 76ed634

Please sign in to comment.