Skip to content

Commit

Permalink
Merge branch 'handleMessageLimits' of https://github.com/prysmaticlab…
Browse files Browse the repository at this point in the history
…s/geth-sharding into handleMessageLimits
  • Loading branch information
nisdas committed Jan 16, 2025
2 parents 07c9e4a + c1e5b73 commit 8fff960
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
uses: dsaltares/fetch-gh-release-asset@aa2ab1243d6e0d5b405b973c89fa4d06a2d0fff7 # 1.1.2
with:
repo: OffchainLabs/unclog
version: "tags/v0.1.3"
file: "unclog"

- name: Get new changelog files
Expand Down
13 changes: 13 additions & 0 deletions beacon-chain/db/kv/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,19 @@ func (s *Store) unmarshalState(_ context.Context, enc []byte, validatorEntries [
}

switch {
case hasFuluKey(enc):
protoState := &ethpb.BeaconStateFulu{}
if err := protoState.UnmarshalSSZ(enc[len(fuluKey):]); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal encoding for Electra")
}
ok, err := s.isStateValidatorMigrationOver()
if err != nil {
return nil, err
}
if ok {
protoState.Validators = validatorEntries
}
return statenative.InitializeFromProtoUnsafeFulu(protoState)
case hasElectraKey(enc):
protoState := &ethpb.BeaconStateElectra{}
if err := protoState.UnmarshalSSZ(enc[len(electraKey):]); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/p2p/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ func TestStaticPeering_PeersAreAdded(t *testing.T) {
}

func TestHostIsResolved(t *testing.T) {
// As defined in RFC 2606 , example.org is a
// reserved example domain name.
exampleHost := "example.org"
// ip.addr.tools - construct domain names that resolve to any given IP address
// ex: 192-0-2-1.ip.addr.tools resolves to 192.0.2.1.
exampleHost := "96-7-129-13.ip.addr.tools"
exampleIP := "96.7.129.13"

s := &Service{
Expand Down
3 changes: 3 additions & 0 deletions changelog/james-prysm_e2e-scenario-fork-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- added conditional evaluators to fix scenario e2e tests
3 changes: 3 additions & 0 deletions changelog/james-prysm_handle-pbgeneric-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- fix panic with type cast on pbgenericblock()
2 changes: 2 additions & 0 deletions changelog/kasey_unclog-v0-1-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Changed
- Version pinning unclog after making some ux improvements.
3 changes: 3 additions & 0 deletions changelog/manu_fulu_to_blinded.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- `ToBlinded`: Use Fulu struct for Fulu (instead of Electra)
3 changes: 3 additions & 0 deletions changelog/pvl_dns_test_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Fixed a p2p test to reliably return a static IP through DNS resolution. [[PR]](https://github.com/prysmaticlabs/prysm/pull/14800)
3 changes: 3 additions & 0 deletions changelog/tt_fix_generate_genesis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Prysmctl generate genesis state: fix truncation of ExtraData to 32 bytes to satisfy SSZ marshaling
2 changes: 1 addition & 1 deletion config/params/mainnet_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,5 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
c.CapellaForkVersion[0] = 3
c.DenebForkVersion[0] = 4
c.ElectraForkVersion[0] = 5
c.FuluForkVersion[0] = 5
c.FuluForkVersion[0] = 6
}
5 changes: 4 additions & 1 deletion consensus-types/blocks/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,10 @@ func PayloadToHeaderDeneb(payload interfaces.ExecutionData) (*enginev1.Execution
}, nil
}

var PayloadToHeaderElectra = PayloadToHeaderDeneb
var (
PayloadToHeaderElectra = PayloadToHeaderDeneb
PayloadToHeaderFulu = PayloadToHeaderDeneb
)

// IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has
// a non-zero value, this function will return false.
Expand Down
61 changes: 55 additions & 6 deletions consensus-types/blocks/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,38 @@ func (b *SignedBeaconBlock) PbGenericBlock() (*eth.GenericSignedBeaconBlock, err
Block: &eth.GenericSignedBeaconBlock_BlindedDeneb{BlindedDeneb: pb.(*eth.SignedBlindedBeaconBlockDeneb)},
}, nil
}
bc, ok := pb.(*eth.SignedBeaconBlockContentsDeneb)
if !ok {
return nil, fmt.Errorf("PbGenericBlock() only supports block content type but got %T", pb)
}
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_Deneb{Deneb: pb.(*eth.SignedBeaconBlockContentsDeneb)},
Block: &eth.GenericSignedBeaconBlock_Deneb{Deneb: bc},
}, nil
case version.Electra:
if b.IsBlinded() {
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_BlindedElectra{BlindedElectra: pb.(*eth.SignedBlindedBeaconBlockElectra)},
}, nil
}
bc, ok := pb.(*eth.SignedBeaconBlockContentsElectra)
if !ok {
return nil, fmt.Errorf("PbGenericBlock() only supports block content type but got %T", pb)
}
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_Electra{Electra: pb.(*eth.SignedBeaconBlockContentsElectra)},
Block: &eth.GenericSignedBeaconBlock_Electra{Electra: bc},
}, nil
case version.Fulu:
if b.IsBlinded() {
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_BlindedFulu{BlindedFulu: pb.(*eth.SignedBlindedBeaconBlockFulu)},
}, nil
}
bc, ok := pb.(*eth.SignedBeaconBlockContentsFulu)
if !ok {
return nil, fmt.Errorf("PbGenericBlock() only supports block content type but got %T", pb)
}
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_Fulu{Fulu: pb.(*eth.SignedBeaconBlockContentsFulu)},
Block: &eth.GenericSignedBeaconBlock_Fulu{Fulu: bc},
}, nil
default:
return nil, errIncorrectBlockVersion
Expand All @@ -166,14 +178,51 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
return nil, err
}

if b.version >= version.Fulu {
p, ok := payload.Proto().(*enginev1.ExecutionPayloadDeneb)
if !ok {
return nil, fmt.Errorf("%T is not an execution payload header of Deneb version", p)
}
header, err := PayloadToHeaderFulu(payload)
if err != nil {
return nil, errors.Wrap(err, "payload to header fulu")
}

return initBlindedSignedBlockFromProtoFulu(
&eth.SignedBlindedBeaconBlockFulu{
Message: &eth.BlindedBeaconBlockFulu{
Slot: b.block.slot,
ProposerIndex: b.block.proposerIndex,
ParentRoot: b.block.parentRoot[:],
StateRoot: b.block.stateRoot[:],
Body: &eth.BlindedBeaconBlockBodyFulu{
RandaoReveal: b.block.body.randaoReveal[:],
Eth1Data: b.block.body.eth1Data,
Graffiti: b.block.body.graffiti[:],
ProposerSlashings: b.block.body.proposerSlashings,
AttesterSlashings: b.block.body.attesterSlashingsElectra,
Attestations: b.block.body.attestationsElectra,
Deposits: b.block.body.deposits,
VoluntaryExits: b.block.body.voluntaryExits,
SyncAggregate: b.block.body.syncAggregate,
ExecutionPayloadHeader: header,
BlsToExecutionChanges: b.block.body.blsToExecutionChanges,
BlobKzgCommitments: b.block.body.blobKzgCommitments,
ExecutionRequests: b.block.body.executionRequests,
},
},
Signature: b.signature[:],
})
}

if b.version >= version.Electra {
p, ok := payload.Proto().(*enginev1.ExecutionPayloadDeneb)
if !ok {
return nil, fmt.Errorf("%T is not an execution payload header of Deneb version", p)
}
header, err := PayloadToHeaderElectra(payload)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "payload to header electra")
}
return initBlindedSignedBlockFromProtoElectra(
&eth.SignedBlindedBeaconBlockElectra{
Expand Down Expand Up @@ -206,7 +255,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
case *enginev1.ExecutionPayload:
header, err := PayloadToHeader(payload)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "payload to header")
}
return initBlindedSignedBlockFromProtoBellatrix(
&eth.SignedBlindedBeaconBlockBellatrix{
Expand Down Expand Up @@ -261,7 +310,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
case *enginev1.ExecutionPayloadDeneb:
header, err := PayloadToHeaderDeneb(payload)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "payload to header deneb")
}
return initBlindedSignedBlockFromProtoDeneb(
&eth.SignedBlindedBeaconBlockDeneb{
Expand Down
10 changes: 7 additions & 3 deletions runtime/interop/premine-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ func (s *PremineGenesisConfig) setLatestBlockHeader(g state.BeaconState) error {

func (s *PremineGenesisConfig) setExecutionPayload(g state.BeaconState) error {
gb := s.GB
extraData := gb.Extra()
if len(extraData) > 32 {
extraData = extraData[:32]
}

if s.Version >= version.Deneb {
payload := &enginev1.ExecutionPayloadDeneb{
Expand All @@ -634,7 +638,7 @@ func (s *PremineGenesisConfig) setExecutionPayload(g state.BeaconState) error {
GasLimit: gb.GasLimit(),
GasUsed: gb.GasUsed(),
Timestamp: gb.Time(),
ExtraData: gb.Extra(),
ExtraData: extraData,
BaseFeePerGas: bytesutil.PadTo(bytesutil.ReverseByteOrder(gb.BaseFee().Bytes()), fieldparams.RootLength),
BlockHash: gb.Hash().Bytes(),
Transactions: make([][]byte, 0),
Expand Down Expand Up @@ -673,7 +677,7 @@ func (s *PremineGenesisConfig) setExecutionPayload(g state.BeaconState) error {
GasLimit: gb.GasLimit(),
GasUsed: gb.GasUsed(),
Timestamp: gb.Time(),
ExtraData: gb.Extra(),
ExtraData: extraData,
BaseFeePerGas: bytesutil.PadTo(bytesutil.ReverseByteOrder(gb.BaseFee().Bytes()), fieldparams.RootLength),
BlockHash: gb.Hash().Bytes(),
Transactions: make([][]byte, 0),
Expand Down Expand Up @@ -709,7 +713,7 @@ func (s *PremineGenesisConfig) setExecutionPayload(g state.BeaconState) error {
GasLimit: gb.GasLimit(),
GasUsed: gb.GasUsed(),
Timestamp: gb.Time(),
ExtraData: gb.Extra(),
ExtraData: extraData,
BaseFeePerGas: bytesutil.PadTo(bytesutil.ReverseByteOrder(gb.BaseFee().Bytes()), fieldparams.RootLength),
BlockHash: gb.Hash().Bytes(),
Transactions: make([][]byte, 0),
Expand Down
26 changes: 14 additions & 12 deletions testing/endtoend/endtoend_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ func addIfForkSet(
return evals
}

func scenarioEvals() []types.Evaluator {
return []types.Evaluator{
func scenarioEvals(cfg *params.BeaconChainConfig) []types.Evaluator {
evals := []types.Evaluator{
ev.PeersConnect,
ev.HealthzCheck,
ev.MetricsCheck,
Expand All @@ -198,18 +198,19 @@ func scenarioEvals() []types.Evaluator {
ev.ProposeVoluntaryExit,
ev.ValidatorsHaveExited,
ev.ColdStateCheckpoint,
ev.AltairForkTransition,
ev.BellatrixForkTransition,
ev.CapellaForkTransition,
ev.DenebForkTransition,
ev.FinishedSyncing,
ev.AllNodesHaveSameHead,
ev.ValidatorSyncParticipation,
}
evals = addIfForkSet(evals, cfg.AltairForkEpoch, ev.AltairForkTransition)
evals = addIfForkSet(evals, cfg.BellatrixForkEpoch, ev.BellatrixForkTransition)
evals = addIfForkSet(evals, cfg.CapellaForkEpoch, ev.CapellaForkTransition)
evals = addIfForkSet(evals, cfg.DenebForkEpoch, ev.DenebForkTransition)
return evals
}

func scenarioEvalsMulti() []types.Evaluator {
return []types.Evaluator{
func scenarioEvalsMulti(cfg *params.BeaconChainConfig) []types.Evaluator {
evals := []types.Evaluator{
ev.PeersConnect,
ev.HealthzCheck,
ev.MetricsCheck,
Expand All @@ -218,11 +219,12 @@ func scenarioEvalsMulti() []types.Evaluator {
ev.ProposeVoluntaryExit,
ev.ValidatorsHaveExited,
ev.ColdStateCheckpoint,
ev.AltairForkTransition,
ev.BellatrixForkTransition,
ev.CapellaForkTransition,
ev.DenebForkTransition,
ev.FinishedSyncing,
ev.AllNodesHaveSameHead,
}
evals = addIfForkSet(evals, cfg.AltairForkEpoch, ev.AltairForkTransition)
evals = addIfForkSet(evals, cfg.BellatrixForkEpoch, ev.BellatrixForkTransition)
evals = addIfForkSet(evals, cfg.CapellaForkEpoch, ev.CapellaForkTransition)
evals = addIfForkSet(evals, cfg.DenebForkEpoch, ev.DenebForkTransition)
return evals
}
6 changes: 4 additions & 2 deletions testing/endtoend/mainnet_scenario_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
)

func TestEndToEnd_MultiScenarioRun_Multiclient(t *testing.T) {
runner := e2eMainnet(t, false, true, types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2EMainnetTestConfig()), types.WithEpochs(24))
runner.config.Evaluators = scenarioEvalsMulti()
cfg := types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2EMainnetTestConfig())
runner := e2eMainnet(t, false, true, cfg, types.WithEpochs(24))
// override for scenario tests
runner.config.Evaluators = scenarioEvalsMulti(cfg)
runner.config.EvalInterceptor = runner.multiScenarioMulticlient
runner.scenarioRunner()
}
14 changes: 8 additions & 6 deletions testing/endtoend/minimal_scenario_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
)

func TestEndToEnd_MultiScenarioRun(t *testing.T) {
runner := e2eMinimal(t, types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2ETestConfig()), types.WithEpochs(26))

runner.config.Evaluators = scenarioEvals()
cfg := types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2ETestConfig())
runner := e2eMinimal(t, cfg, types.WithEpochs(26))
// override for scenario tests
runner.config.Evaluators = scenarioEvals(cfg)
runner.config.EvalInterceptor = runner.multiScenario
runner.scenarioRunner()
}
Expand All @@ -30,9 +31,10 @@ func TestEndToEnd_MinimalConfig_ValidatorRESTApi(t *testing.T) {

func TestEndToEnd_ScenarioRun_EEOffline(t *testing.T) {
t.Skip("TODO(#10242) Prysm is current unable to handle an offline e2e")
runner := e2eMinimal(t, types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2ETestConfig()))

runner.config.Evaluators = scenarioEvals()
cfg := types.InitForkCfg(version.Bellatrix, version.Deneb, params.E2ETestConfig())
runner := e2eMinimal(t, cfg)
// override for scenario tests
runner.config.Evaluators = scenarioEvals(cfg)
runner.config.EvalInterceptor = runner.eeOffline
runner.scenarioRunner()
}
27 changes: 27 additions & 0 deletions testing/util/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,30 @@ func TestGenerateVoluntaryExits(t *testing.T) {
require.NoError(t, err)
require.NoError(t, coreBlock.VerifyExitAndSignature(val, beaconState, exit))
}

func Test_PostDenebPbGenericBlock_ErrorsForPlainBlock(t *testing.T) {
t.Run("Deneb block returns type error", func(t *testing.T) {
eb := NewBeaconBlockDeneb()
b, err := blocks.NewSignedBeaconBlock(eb)
require.NoError(t, err)

_, err = b.PbGenericBlock()
require.ErrorContains(t, "PbGenericBlock() only supports block content type but got", err)
})
t.Run("Electra block returns type error", func(t *testing.T) {
eb := NewBeaconBlockElectra()
b, err := blocks.NewSignedBeaconBlock(eb)
require.NoError(t, err)

_, err = b.PbGenericBlock()
require.ErrorContains(t, "PbGenericBlock() only supports block content type but got", err)
})
t.Run("Fulu block returns type error", func(t *testing.T) {
eb := NewBeaconBlockFulu()
b, err := blocks.NewSignedBeaconBlock(eb)
require.NoError(t, err)

_, err = b.PbGenericBlock()
require.ErrorContains(t, "PbGenericBlock() only supports block content type but got", err)
})
}

0 comments on commit 8fff960

Please sign in to comment.