mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
Compare commits
12 Commits
prysm-web-
...
v3.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
648ab9f2c2 | ||
|
|
43a0b4bb16 | ||
|
|
57d7207554 | ||
|
|
b7b5b28c5a | ||
|
|
968dc5d1e8 | ||
|
|
c24016f006 | ||
|
|
661cbc45ae | ||
|
|
4bd4d6392d | ||
|
|
5f4c26875b | ||
|
|
6aab2b2b8d | ||
|
|
b7a878d011 | ||
|
|
2ae9f1be9e |
@@ -342,9 +342,9 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "e0c0b5dc609b3a221e74c720f483c595441f2ad5e38bb8aa3522636039945a6f",
|
||||
sha256 = "b2226874526805d64c29e5053fa28e511b57c0860585d6d59777ee81ff4859ca",
|
||||
urls = [
|
||||
"https://github.com/prysmaticlabs/prysm-web-ui/releases/download/v2.0.1/prysm-web-ui.tar.gz",
|
||||
"https://github.com/prysmaticlabs/prysm-web-ui/releases/download/v2.0.2/prysm-web-ui.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ func TestHeadState_CanRetrieve(t *testing.T) {
|
||||
c.head = &head{state: s}
|
||||
headState, err := c.HeadState(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, headState.InnerStateUnsafe(), s.InnerStateUnsafe(), "Incorrect head state received")
|
||||
assert.DeepEqual(t, headState.ToProtoUnsafe(), s.ToProtoUnsafe(), "Incorrect head state received")
|
||||
}
|
||||
|
||||
func TestGenesisTime_CanRetrieve(t *testing.T) {
|
||||
|
||||
@@ -89,7 +89,7 @@ func TestSaveHead_Different(t *testing.T) {
|
||||
pb, err := headBlock.Proto()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, newHeadSignedBlock, pb, "Head did not change")
|
||||
assert.DeepSSZEqual(t, headState.CloneInnerState(), service.headState(ctx).CloneInnerState(), "Head did not change")
|
||||
assert.DeepSSZEqual(t, headState.ToProto(), service.headState(ctx).ToProto(), "Head did not change")
|
||||
}
|
||||
|
||||
func TestSaveHead_Different_Reorg(t *testing.T) {
|
||||
@@ -147,7 +147,7 @@ func TestSaveHead_Different_Reorg(t *testing.T) {
|
||||
pb, err := headBlock.Proto()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, newHeadSignedBlock, pb, "Head did not change")
|
||||
assert.DeepSSZEqual(t, headState.CloneInnerState(), service.headState(ctx).CloneInnerState(), "Head did not change")
|
||||
assert.DeepSSZEqual(t, headState.ToProto(), service.headState(ctx).ToProto(), "Head did not change")
|
||||
require.LogsContain(t, hook, "Chain reorg occurred")
|
||||
require.LogsContain(t, hook, "distance=1")
|
||||
require.LogsContain(t, hook, "depth=1")
|
||||
|
||||
@@ -338,7 +338,7 @@ func reportEpochMetrics(ctx context.Context, postState, headState state.BeaconSt
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return errors.Errorf("invalid state type provided: %T", headState.InnerStateUnsafe())
|
||||
return errors.Errorf("invalid state type provided: %T", headState.ToProtoUnsafe())
|
||||
}
|
||||
prevEpochActiveBalances.Set(float64(b.ActivePrevEpoch))
|
||||
prevEpochSourceBalances.Set(float64(b.PrevEpochAttested))
|
||||
|
||||
@@ -256,7 +256,7 @@ func TestStore_UpdateCheckpointState(t *testing.T) {
|
||||
|
||||
cached, err = service.checkpointStateCache.StateByCheckpoint(newCheckpoint)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, returned.InnerStateUnsafe(), cached.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, returned.ToProtoUnsafe(), cached.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestAttEpoch_MatchPrevEpoch(t *testing.T) {
|
||||
|
||||
@@ -667,7 +667,8 @@ func (s *Service) fillMissingPayloadIDRoutine(ctx context.Context, stateFeed *ev
|
||||
if !atHalfSlot(ti) {
|
||||
continue
|
||||
}
|
||||
_, id, has := s.cfg.ProposerSlotIndexCache.GetProposerPayloadIDs(s.CurrentSlot()+1, s.headRoot())
|
||||
// Head root should be empty when retrieving proposer index for the next slot.
|
||||
_, id, has := s.cfg.ProposerSlotIndexCache.GetProposerPayloadIDs(s.CurrentSlot()+1, [32]byte{} /* head root */)
|
||||
// There exists proposer for next slot, but we haven't called fcu w/ payload attribute yet.
|
||||
if has && id == [8]byte{} {
|
||||
headBlock, err := s.headBlock()
|
||||
|
||||
@@ -83,7 +83,7 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service {
|
||||
srv.Stop()
|
||||
})
|
||||
bState, _ := util.DeterministicGenesisState(t, 10)
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
mockTrie, err := trie.NewTrie(0)
|
||||
require.NoError(t, err)
|
||||
@@ -325,7 +325,7 @@ func TestChainService_InitializeChainInfo(t *testing.T) {
|
||||
assert.DeepEqual(t, headBlock, pb, "Head block incorrect")
|
||||
s, err := c.HeadState(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, headState.InnerStateUnsafe(), s.InnerStateUnsafe(), "Head state incorrect")
|
||||
assert.DeepSSZEqual(t, headState.ToProtoUnsafe(), s.ToProtoUnsafe(), "Head state incorrect")
|
||||
assert.Equal(t, c.HeadSlot(), headBlock.Block.Slot, "Head slot incorrect")
|
||||
r, err := c.HeadRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
@@ -380,7 +380,7 @@ func TestChainService_InitializeChainInfo_SetHeadAtGenesis(t *testing.T) {
|
||||
require.NoError(t, c.StartFromSavedState(headState))
|
||||
s, err := c.HeadState(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, headState.InnerStateUnsafe(), s.InnerStateUnsafe(), "Head state incorrect")
|
||||
assert.DeepSSZEqual(t, headState.ToProtoUnsafe(), s.ToProtoUnsafe(), "Head state incorrect")
|
||||
assert.Equal(t, genesisRoot, c.originBlockRoot, "Genesis block root incorrect")
|
||||
pb, err := c.head.block.Proto()
|
||||
require.NoError(t, err)
|
||||
|
||||
8
beacon-chain/cache/checkpoint_state_test.go
vendored
8
beacon-chain/cache/checkpoint_state_test.go
vendored
@@ -33,9 +33,9 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
s, err = cache.StateByCheckpoint(cp1)
|
||||
require.NoError(t, err)
|
||||
|
||||
pbState1, err := state_native.ProtobufBeaconStatePhase0(s.InnerStateUnsafe())
|
||||
pbState1, err := state_native.ProtobufBeaconStatePhase0(s.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
pbstate, err := state_native.ProtobufBeaconStatePhase0(st.InnerStateUnsafe())
|
||||
pbstate, err := state_native.ProtobufBeaconStatePhase0(st.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState1, pbstate) {
|
||||
t.Error("incorrectly cached state")
|
||||
@@ -50,11 +50,11 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
|
||||
s, err = cache.StateByCheckpoint(cp2)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, st2.CloneInnerState(), s.CloneInnerState(), "incorrectly cached state")
|
||||
assert.DeepEqual(t, st2.ToProto(), s.ToProto(), "incorrectly cached state")
|
||||
|
||||
s, err = cache.StateByCheckpoint(cp1)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, st.CloneInnerState(), s.CloneInnerState(), "incorrectly cached state")
|
||||
assert.DeepEqual(t, st.ToProto(), s.ToProto(), "incorrectly cached state")
|
||||
}
|
||||
|
||||
func TestCheckpointStateCache_MaxSize(t *testing.T) {
|
||||
|
||||
2
beacon-chain/cache/skip_slot_cache_test.go
vendored
2
beacon-chain/cache/skip_slot_cache_test.go
vendored
@@ -33,5 +33,5 @@ func TestSkipSlotCache_RoundTrip(t *testing.T) {
|
||||
|
||||
res, err := c.Get(ctx, r)
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, res.CloneInnerState(), s.CloneInnerState(), "Expected equal protos to return from cache")
|
||||
assert.DeepEqual(t, res.ToProto(), s.ToProto(), "Expected equal protos to return from cache")
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func BenchmarkHashTreeRootState_FullState(b *testing.B) {
|
||||
func BenchmarkMarshalState_FullState(b *testing.B) {
|
||||
beaconState, err := benchmark.PreGenstateFullEpochs()
|
||||
require.NoError(b, err)
|
||||
natState, err := state_native.ProtobufBeaconStatePhase0(beaconState.InnerStateUnsafe())
|
||||
natState, err := state_native.ProtobufBeaconStatePhase0(beaconState.ToProtoUnsafe())
|
||||
require.NoError(b, err)
|
||||
b.Run("Proto_Marshal", func(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
@@ -148,7 +148,7 @@ func BenchmarkMarshalState_FullState(b *testing.B) {
|
||||
func BenchmarkUnmarshalState_FullState(b *testing.B) {
|
||||
beaconState, err := benchmark.PreGenstateFullEpochs()
|
||||
require.NoError(b, err)
|
||||
natState, err := state_native.ProtobufBeaconStatePhase0(beaconState.InnerStateUnsafe())
|
||||
natState, err := state_native.ProtobufBeaconStatePhase0(beaconState.ToProtoUnsafe())
|
||||
require.NoError(b, err)
|
||||
protoObject, err := proto.Marshal(natState)
|
||||
require.NoError(b, err)
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestSkipSlotCache_OK(t *testing.T) {
|
||||
transition.SkipSlotCache.Enable()
|
||||
defer transition.SkipSlotCache.Disable()
|
||||
bState, privs := util.DeterministicGenesisState(t, params.MinimalSpecConfig().MinGenesisActiveValidatorCount)
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.CloneInnerState())
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.ToProto())
|
||||
require.NoError(t, err)
|
||||
originalState, err := state_native.InitializeFromProtoPhase0(pbState)
|
||||
require.NoError(t, err)
|
||||
@@ -42,12 +42,12 @@ func TestSkipSlotCache_OK(t *testing.T) {
|
||||
bState, err = transition.ExecuteStateTransition(context.Background(), bState, wsb)
|
||||
require.NoError(t, err, "Could not process state transition")
|
||||
|
||||
assert.DeepEqual(t, originalState.CloneInnerState(), bState.CloneInnerState(), "Skipped slots cache leads to different states")
|
||||
assert.DeepEqual(t, originalState.ToProto(), bState.ToProto(), "Skipped slots cache leads to different states")
|
||||
}
|
||||
|
||||
func TestSkipSlotCache_ConcurrentMixup(t *testing.T) {
|
||||
bState, privs := util.DeterministicGenesisState(t, params.MinimalSpecConfig().MinGenesisActiveValidatorCount)
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.CloneInnerState())
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(bState.ToProto())
|
||||
require.NoError(t, err)
|
||||
originalState, err := state_native.InitializeFromProtoPhase0(pbState)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -98,9 +98,9 @@ func TestGenesisState_HashEquality(t *testing.T) {
|
||||
state, err := transition.GenesisBeaconState(context.Background(), deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)})
|
||||
require.NoError(t, err)
|
||||
|
||||
pbState1, err := state_native.ProtobufBeaconStatePhase0(state1.CloneInnerState())
|
||||
pbState1, err := state_native.ProtobufBeaconStatePhase0(state1.ToProto())
|
||||
require.NoError(t, err)
|
||||
pbstate, err := state_native.ProtobufBeaconStatePhase0(state.CloneInnerState())
|
||||
pbstate, err := state_native.ProtobufBeaconStatePhase0(state.ToProto())
|
||||
require.NoError(t, err)
|
||||
|
||||
root1, err1 := hash.HashProto(pbState1)
|
||||
|
||||
@@ -51,7 +51,7 @@ type ReadOnlyDatabase interface {
|
||||
DepositContractAddress(ctx context.Context) ([]byte, error)
|
||||
// ExecutionChainData operations.
|
||||
ExecutionChainData(ctx context.Context) (*ethpb.ETH1ChainData, error)
|
||||
// Fee reicipients operations.
|
||||
// Fee recipients operations.
|
||||
FeeRecipientByValidatorID(ctx context.Context, id types.ValidatorIndex) (common.Address, error)
|
||||
RegistrationByValidatorID(ctx context.Context, id types.ValidatorIndex) (*ethpb.ValidatorRegistrationV1, error)
|
||||
// origin checkpoint sync support
|
||||
@@ -85,7 +85,7 @@ type NoHeadAccessDatabase interface {
|
||||
SaveExecutionChainData(ctx context.Context, data *ethpb.ETH1ChainData) error
|
||||
// Run any required database migrations.
|
||||
RunMigrations(ctx context.Context) error
|
||||
// Fee reicipients operations.
|
||||
// Fee recipients operations.
|
||||
SaveFeeRecipientsByValidatorIDs(ctx context.Context, ids []types.ValidatorIndex, addrs []common.Address) error
|
||||
SaveRegistrationsByValidatorIDs(ctx context.Context, ids []types.ValidatorIndex, regs []*ethpb.ValidatorRegistrationV1) error
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ func Test_migrateStateValidators(t *testing.T) {
|
||||
assert.NoError(t, hashErr)
|
||||
individualHashes = append(individualHashes, hash[:])
|
||||
}
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(st.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(st.ToProtoUnsafe())
|
||||
assert.NoError(t, err)
|
||||
validatorsFoundCount := 0
|
||||
for _, val := range pbState.Validators {
|
||||
@@ -138,7 +138,7 @@ func Test_migrateStateValidators(t *testing.T) {
|
||||
blockRoot := [32]byte{'A'}
|
||||
rcvdState, err := dbStore.State(context.Background(), blockRoot)
|
||||
assert.NoError(t, err)
|
||||
require.DeepSSZEqual(t, rcvdState.InnerStateUnsafe(), state.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, rcvdState.ToProtoUnsafe(), state.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// find hashes of the validators that are set as part of the state
|
||||
var hashes []byte
|
||||
@@ -151,7 +151,7 @@ func Test_migrateStateValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
// check if all the validators that were in the state, are stored properly in the validator bucket
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(rcvdState.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStatePhase0(rcvdState.ToProtoUnsafe())
|
||||
assert.NoError(t, err)
|
||||
validatorsFoundCount := 0
|
||||
for _, val := range pbState.Validators {
|
||||
@@ -241,7 +241,7 @@ func Test_migrateAltairStateValidators(t *testing.T) {
|
||||
blockRoot := [32]byte{'A'}
|
||||
rcvdState, err := dbStore.State(context.Background(), blockRoot)
|
||||
assert.NoError(t, err)
|
||||
require.DeepSSZEqual(t, rcvdState.InnerStateUnsafe(), state.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, rcvdState.ToProtoUnsafe(), state.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// find hashes of the validators that are set as part of the state
|
||||
var hashes []byte
|
||||
@@ -254,7 +254,7 @@ func Test_migrateAltairStateValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
// check if all the validators that were in the state, are stored properly in the validator bucket
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(rcvdState.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(rcvdState.ToProtoUnsafe())
|
||||
assert.NoError(t, err)
|
||||
validatorsFoundCount := 0
|
||||
for _, val := range pbState.Validators {
|
||||
|
||||
@@ -189,7 +189,7 @@ func getValidators(states []state.ReadOnlyBeaconState) ([][]byte, map[string]*et
|
||||
validatorsEntries := make(map[string]*ethpb.Validator) // It's a map to make sure that you store only new validator entries.
|
||||
validatorKeys := make([][]byte, len(states)) // For every state, this stores a compressed list of validator keys.
|
||||
for i, st := range states {
|
||||
pb, ok := st.InnerStateUnsafe().(withValidators)
|
||||
pb, ok := st.ToProtoUnsafe().(withValidators)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("could not cast state to interface with GetValidators()")
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (s *Store) saveStatesEfficientInternal(ctx context.Context, tx *bolt.Tx, bl
|
||||
// validator entries.To bring the gap closer, we empty the validators
|
||||
// just before Put() and repopulate that state with original validators.
|
||||
// look at issue https://github.com/prysmaticlabs/prysm/issues/9262.
|
||||
switch rawType := states[i].InnerStateUnsafe().(type) {
|
||||
switch rawType := states[i].ToProtoUnsafe().(type) {
|
||||
case *ethpb.BeaconState:
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(rawType)
|
||||
if err != nil {
|
||||
@@ -534,15 +534,15 @@ func (s *Store) unmarshalState(_ context.Context, enc []byte, validatorEntries [
|
||||
|
||||
// marshal versioned state from struct type down to bytes.
|
||||
func marshalState(ctx context.Context, st state.ReadOnlyBeaconState) ([]byte, error) {
|
||||
switch st.InnerStateUnsafe().(type) {
|
||||
switch st.ToProtoUnsafe().(type) {
|
||||
case *ethpb.BeaconState:
|
||||
rState, ok := st.InnerStateUnsafe().(*ethpb.BeaconState)
|
||||
rState, ok := st.ToProtoUnsafe().(*ethpb.BeaconState)
|
||||
if !ok {
|
||||
return nil, errors.New("non valid inner state")
|
||||
}
|
||||
return encode(ctx, rState)
|
||||
case *ethpb.BeaconStateAltair:
|
||||
rState, ok := st.InnerStateUnsafe().(*ethpb.BeaconStateAltair)
|
||||
rState, ok := st.ToProtoUnsafe().(*ethpb.BeaconStateAltair)
|
||||
if !ok {
|
||||
return nil, errors.New("non valid inner state")
|
||||
}
|
||||
@@ -555,7 +555,7 @@ func marshalState(ctx context.Context, st state.ReadOnlyBeaconState) ([]byte, er
|
||||
}
|
||||
return snappy.Encode(nil, append(altairKey, rawObj...)), nil
|
||||
case *ethpb.BeaconStateBellatrix:
|
||||
rState, ok := st.InnerStateUnsafe().(*ethpb.BeaconStateBellatrix)
|
||||
rState, ok := st.ToProtoUnsafe().(*ethpb.BeaconStateBellatrix)
|
||||
if !ok {
|
||||
return nil, errors.New("non valid inner state")
|
||||
}
|
||||
@@ -568,7 +568,7 @@ func marshalState(ctx context.Context, st state.ReadOnlyBeaconState) ([]byte, er
|
||||
}
|
||||
return snappy.Encode(nil, append(bellatrixKey, rawObj...)), nil
|
||||
case *ethpb.BeaconStateCapella:
|
||||
rState, ok := st.InnerStateUnsafe().(*ethpb.BeaconStateCapella)
|
||||
rState, ok := st.ToProtoUnsafe().(*ethpb.BeaconStateCapella)
|
||||
if !ok {
|
||||
return nil, errors.New("non valid inner state")
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestState_CanSaveRetrieve(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe(), "saved state and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe(), "saved state and retrieved state are not matching")
|
||||
|
||||
savedS, err = db.State(context.Background(), [32]byte{'B'})
|
||||
require.NoError(t, err)
|
||||
@@ -77,7 +77,7 @@ func TestState_CanSaveRetrieveValidatorEntries(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// check if the index of the second state is still present.
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
@@ -129,7 +129,7 @@ func TestStateAltair_CanSaveRetrieveValidatorEntries(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// check if the index of the second state is still present.
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
@@ -239,7 +239,7 @@ func TestState_CanSaveRetrieveValidatorEntriesWithoutCache(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// check if the index of the second state is still present.
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
@@ -360,7 +360,7 @@ func TestGenesisState_CanSaveRetrieve(t *testing.T) {
|
||||
|
||||
savedGenesisS, err := db.GenesisState(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, st.InnerStateUnsafe(), savedGenesisS.InnerStateUnsafe(), "Did not retrieve saved state")
|
||||
assert.DeepSSZEqual(t, st.ToProtoUnsafe(), savedGenesisS.ToProtoUnsafe(), "Did not retrieve saved state")
|
||||
require.NoError(t, db.SaveGenesisBlockRoot(context.Background(), [32]byte{'C'}))
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) {
|
||||
st, err := util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, st.SetSlot(1))
|
||||
s0 := st.InnerStateUnsafe()
|
||||
s0 := st.ToProtoUnsafe()
|
||||
require.NoError(t, db.SaveState(context.Background(), st, r))
|
||||
|
||||
b.Block.Slot = 100
|
||||
@@ -493,7 +493,7 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) {
|
||||
st, err = util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, st.SetSlot(100))
|
||||
s1 := st.InnerStateUnsafe()
|
||||
s1 := st.ToProtoUnsafe()
|
||||
require.NoError(t, db.SaveState(context.Background(), st, r1))
|
||||
|
||||
b.Block.Slot = 1000
|
||||
@@ -505,21 +505,21 @@ func TestStore_SaveDeleteState_CanGetHighestBelow(t *testing.T) {
|
||||
st, err = util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, st.SetSlot(1000))
|
||||
s2 := st.InnerStateUnsafe()
|
||||
s2 := st.ToProtoUnsafe()
|
||||
|
||||
require.NoError(t, db.SaveState(context.Background(), st, r2))
|
||||
|
||||
highest, err := db.HighestSlotStatesBelow(context.Background(), 2)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), s0)
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), s0)
|
||||
|
||||
highest, err = db.HighestSlotStatesBelow(context.Background(), 101)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), s1)
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), s1)
|
||||
|
||||
highest, err = db.HighestSlotStatesBelow(context.Background(), 1001)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), s2)
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), s2)
|
||||
}
|
||||
|
||||
func TestStore_GenesisState_CanGetHighestBelow(t *testing.T) {
|
||||
@@ -546,14 +546,14 @@ func TestStore_GenesisState_CanGetHighestBelow(t *testing.T) {
|
||||
|
||||
highest, err := db.HighestSlotStatesBelow(context.Background(), 2)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), st.InnerStateUnsafe())
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), st.ToProtoUnsafe())
|
||||
|
||||
highest, err = db.HighestSlotStatesBelow(context.Background(), 1)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), genesisState.InnerStateUnsafe())
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), genesisState.ToProtoUnsafe())
|
||||
highest, err = db.HighestSlotStatesBelow(context.Background(), 0)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, highest[0].InnerStateUnsafe(), genesisState.InnerStateUnsafe())
|
||||
assert.DeepSSZEqual(t, highest[0].ToProtoUnsafe(), genesisState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestStore_CleanUpDirtyStates_AboveThreshold(t *testing.T) {
|
||||
@@ -680,7 +680,7 @@ func TestAltairState_CanSaveRetrieve(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe())
|
||||
|
||||
savedS, err = db.State(context.Background(), [32]byte{'B'})
|
||||
require.NoError(t, err)
|
||||
@@ -831,7 +831,7 @@ func TestStateBellatrix_CanSaveRetrieveValidatorEntries(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe(), "saved state with validators and retrieved state are not matching")
|
||||
|
||||
// check if the index of the second state is still present.
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
@@ -874,7 +874,7 @@ func TestBellatrixState_CanSaveRetrieve(t *testing.T) {
|
||||
savedS, err := db.State(context.Background(), r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.DeepSSZEqual(t, st.InnerStateUnsafe(), savedS.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, st.ToProtoUnsafe(), savedS.ToProtoUnsafe())
|
||||
|
||||
savedS, err = db.State(context.Background(), [32]byte{'B'})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -550,7 +550,7 @@ func (s *Service) processChainStartIfReady(ctx context.Context, blockHash [32]by
|
||||
|
||||
// savePowchainData saves all powchain related metadata to disk.
|
||||
func (s *Service) savePowchainData(ctx context.Context) error {
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(s.preGenesisState.ToProtoUnsafe())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ func (s *Service) ensureValidPowchainData(ctx context.Context) error {
|
||||
return errors.Wrap(err, "unable to retrieve eth1 data")
|
||||
}
|
||||
if eth1Data == nil || !eth1Data.ChainstartData.Chainstarted || !validateDepositContainers(eth1Data.DepositContainers) {
|
||||
pbState, err := native.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
|
||||
pbState, err := native.ProtobufBeaconStatePhase0(s.preGenesisState.ToProtoUnsafe())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ go_library(
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/wrapper:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//crypto/ecdsa:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
@@ -74,7 +75,6 @@ go_library(
|
||||
"@com_github_ethereum_go_ethereum//p2p/discover:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_kr_pretty//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//config:go_default_library",
|
||||
@@ -150,6 +150,7 @@ go_test(
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/wrapper:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//crypto/ecdsa:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
@@ -168,7 +169,6 @@ go_test(
|
||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/crypto:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/host:go_default_library",
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/peers/peerdata"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/peers/scorers"
|
||||
mockp2p "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/testing"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/eth/v1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
@@ -26,7 +27,7 @@ func TestPeer_AtMaxLimit(t *testing.T) {
|
||||
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, 2000))
|
||||
require.NoError(t, err, "Failed to p2p listen")
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
}
|
||||
s.peers = peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
PeerLimit: 0,
|
||||
@@ -70,7 +71,7 @@ func TestPeer_AtMaxLimit(t *testing.T) {
|
||||
|
||||
func TestService_InterceptBannedIP(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
PeerLimit: 20,
|
||||
ScorerParams: &scorers.Config{},
|
||||
@@ -98,7 +99,7 @@ func TestService_InterceptBannedIP(t *testing.T) {
|
||||
func TestService_RejectInboundPeersBeyondLimit(t *testing.T) {
|
||||
limit := 20
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
PeerLimit: limit,
|
||||
ScorerParams: &scorers.Config{},
|
||||
@@ -140,7 +141,7 @@ func TestPeer_BelowMaxLimit(t *testing.T) {
|
||||
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, 2000))
|
||||
require.NoError(t, err, "Failed to p2p listen")
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
}
|
||||
s.peers = peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
PeerLimit: 1,
|
||||
@@ -191,7 +192,7 @@ func TestPeerAllowList(t *testing.T) {
|
||||
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, 2000))
|
||||
require.NoError(t, err, "Failed to p2p listen")
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -237,7 +238,7 @@ func TestPeerDenyList(t *testing.T) {
|
||||
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, 2000))
|
||||
require.NoError(t, err, "Failed to p2p listen")
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -272,7 +273,7 @@ func TestPeerDenyList(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_Allow(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -292,7 +293,7 @@ func TestService_InterceptAddrDial_Allow(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_Public(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -340,7 +341,7 @@ func TestService_InterceptAddrDial_Public(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_Private(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -369,7 +370,7 @@ func TestService_InterceptAddrDial_Private(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_AllowPrivate(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -398,7 +399,7 @@ func TestService_InterceptAddrDial_AllowPrivate(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_DenyPublic(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
@@ -427,7 +428,7 @@ func TestService_InterceptAddrDial_DenyPublic(t *testing.T) {
|
||||
|
||||
func TestService_InterceptAddrDial_AllowConflict(t *testing.T) {
|
||||
s := &Service{
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
ScorerParams: &scorers.Config{},
|
||||
}),
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
testp2p "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/testing"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/wrapper"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
prysmNetwork "github.com/prysmaticlabs/prysm/v3/network"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
@@ -246,7 +246,7 @@ func TestInboundPeerLimit(t *testing.T) {
|
||||
fakePeer := testp2p.NewTestP2P(t)
|
||||
s := &Service{
|
||||
cfg: &Config{MaxPeers: 30},
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, false),
|
||||
ipLimiter: leakybucket.NewCollector(ipLimit, ipBurst, 1*time.Second, false),
|
||||
peers: peers.NewStatus(context.Background(), &peers.StatusConfig{
|
||||
PeerLimit: 30,
|
||||
ScorerParams: &scorers.Config{},
|
||||
|
||||
@@ -115,7 +115,7 @@ func TestSszNetworkEncoder_DecodeWithMultipleFrames(t *testing.T) {
|
||||
maxChunkSize := uint64(1 << 22)
|
||||
encoder.MaxChunkSize = maxChunkSize
|
||||
params.OverrideBeaconNetworkConfig(c)
|
||||
_, err := e.EncodeWithMaxLength(buf, st.InnerStateUnsafe().(*ethpb.BeaconState))
|
||||
_, err := e.EncodeWithMaxLength(buf, st.ToProtoUnsafe().(*ethpb.BeaconState))
|
||||
require.NoError(t, err)
|
||||
// Max snappy block size
|
||||
if buf.Len() <= 76490 {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
@@ -29,6 +28,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/peers/scorers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
prysmnetwork "github.com/prysmaticlabs/prysm/v3/network"
|
||||
"github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/metadata"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime"
|
||||
@@ -123,7 +123,7 @@ func NewService(ctx context.Context, cfg *Config) (*Service, error) {
|
||||
log.WithError(err).Error("Failed to create address filter")
|
||||
return nil, err
|
||||
}
|
||||
s.ipLimiter = leakybucket.NewCollector(ipLimit, ipBurst, true /* deleteEmptyBuckets */)
|
||||
s.ipLimiter = leakybucket.NewCollector(ipLimit, ipBurst, 30*time.Second, true /* deleteEmptyBuckets */)
|
||||
|
||||
opts := s.buildOptions(ipAddr, s.privKey)
|
||||
h, err := libp2p.New(opts...)
|
||||
|
||||
@@ -20,14 +20,19 @@ import (
|
||||
)
|
||||
|
||||
type testSSZResponseJson struct {
|
||||
Version string `json:"version"`
|
||||
Data string `json:"data"`
|
||||
Version string `json:"version"`
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func (t testSSZResponseJson) SSZVersion() string {
|
||||
return t.Version
|
||||
}
|
||||
|
||||
func (t testSSZResponseJson) SSZOptimistic() bool {
|
||||
return t.ExecutionOptimistic
|
||||
}
|
||||
|
||||
func (t testSSZResponseJson) SSZData() string {
|
||||
return t.Data
|
||||
}
|
||||
|
||||
@@ -439,6 +439,12 @@ type bellatrixBlockResponseJson struct {
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
}
|
||||
|
||||
type bellatrixBlindedBlockResponseJson struct {
|
||||
Version string `json:"version"`
|
||||
Data *SignedBlindedBeaconBlockBellatrixContainerJson `json:"data"`
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
}
|
||||
|
||||
func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
|
||||
respContainer, ok := response.(*BlockV2ResponseJson)
|
||||
if !ok {
|
||||
@@ -485,6 +491,52 @@ func serializeV2Block(response interface{}) (apimiddleware.RunDefault, []byte, a
|
||||
return false, j, nil
|
||||
}
|
||||
|
||||
func serializeBlindedBlock(response interface{}) (apimiddleware.RunDefault, []byte, apimiddleware.ErrorJson) {
|
||||
respContainer, ok := response.(*BlindedBlockResponseJson)
|
||||
if !ok {
|
||||
return false, nil, apimiddleware.InternalServerError(errors.New("container is not of the correct type"))
|
||||
}
|
||||
|
||||
var actualRespContainer interface{}
|
||||
switch {
|
||||
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_PHASE0.String())):
|
||||
actualRespContainer = &phase0BlockResponseJson{
|
||||
Version: respContainer.Version,
|
||||
Data: &SignedBeaconBlockContainerJson{
|
||||
Message: respContainer.Data.Phase0Block,
|
||||
Signature: respContainer.Data.Signature,
|
||||
},
|
||||
ExecutionOptimistic: respContainer.ExecutionOptimistic,
|
||||
}
|
||||
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_ALTAIR.String())):
|
||||
actualRespContainer = &altairBlockResponseJson{
|
||||
Version: respContainer.Version,
|
||||
Data: &SignedBeaconBlockAltairContainerJson{
|
||||
Message: respContainer.Data.AltairBlock,
|
||||
Signature: respContainer.Data.Signature,
|
||||
},
|
||||
ExecutionOptimistic: respContainer.ExecutionOptimistic,
|
||||
}
|
||||
case strings.EqualFold(respContainer.Version, strings.ToLower(ethpbv2.Version_BELLATRIX.String())):
|
||||
actualRespContainer = &bellatrixBlindedBlockResponseJson{
|
||||
Version: respContainer.Version,
|
||||
Data: &SignedBlindedBeaconBlockBellatrixContainerJson{
|
||||
Message: respContainer.Data.BellatrixBlock,
|
||||
Signature: respContainer.Data.Signature,
|
||||
},
|
||||
ExecutionOptimistic: respContainer.ExecutionOptimistic,
|
||||
}
|
||||
default:
|
||||
return false, nil, apimiddleware.InternalServerError(fmt.Errorf("unsupported block version '%s'", respContainer.Version))
|
||||
}
|
||||
|
||||
j, err := json.Marshal(actualRespContainer)
|
||||
if err != nil {
|
||||
return false, nil, apimiddleware.InternalServerErrorWithMessage(err, "could not marshal response")
|
||||
}
|
||||
return false, j, nil
|
||||
}
|
||||
|
||||
type phase0StateResponseJson struct {
|
||||
Version string `json:"version"`
|
||||
Data *BeaconStateJson `json:"data"`
|
||||
|
||||
@@ -717,6 +717,124 @@ func TestSerializeV2Block(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestSerializeBlindedBlock(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
response := &BlindedBlockResponseJson{
|
||||
Version: ethpbv2.Version_PHASE0.String(),
|
||||
Data: &SignedBlindedBeaconBlockContainerJson{
|
||||
Phase0Block: &BeaconBlockJson{
|
||||
Slot: "1",
|
||||
ProposerIndex: "1",
|
||||
ParentRoot: "root",
|
||||
StateRoot: "root",
|
||||
Body: &BeaconBlockBodyJson{},
|
||||
},
|
||||
Signature: "sig",
|
||||
},
|
||||
ExecutionOptimistic: true,
|
||||
}
|
||||
runDefault, j, errJson := serializeBlindedBlock(response)
|
||||
require.Equal(t, nil, errJson)
|
||||
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
|
||||
require.NotNil(t, j)
|
||||
resp := &phase0BlockResponseJson{}
|
||||
require.NoError(t, json.Unmarshal(j, resp))
|
||||
require.NotNil(t, resp.Data)
|
||||
require.NotNil(t, resp.Data.Message)
|
||||
beaconBlock := resp.Data.Message
|
||||
assert.Equal(t, "1", beaconBlock.Slot)
|
||||
assert.Equal(t, "1", beaconBlock.ProposerIndex)
|
||||
assert.Equal(t, "root", beaconBlock.ParentRoot)
|
||||
assert.Equal(t, "root", beaconBlock.StateRoot)
|
||||
assert.NotNil(t, beaconBlock.Body)
|
||||
assert.Equal(t, true, resp.ExecutionOptimistic)
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
response := &BlindedBlockResponseJson{
|
||||
Version: ethpbv2.Version_ALTAIR.String(),
|
||||
Data: &SignedBlindedBeaconBlockContainerJson{
|
||||
AltairBlock: &BeaconBlockAltairJson{
|
||||
Slot: "1",
|
||||
ProposerIndex: "1",
|
||||
ParentRoot: "root",
|
||||
StateRoot: "root",
|
||||
Body: &BeaconBlockBodyAltairJson{},
|
||||
},
|
||||
Signature: "sig",
|
||||
},
|
||||
ExecutionOptimistic: true,
|
||||
}
|
||||
runDefault, j, errJson := serializeBlindedBlock(response)
|
||||
require.Equal(t, nil, errJson)
|
||||
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
|
||||
require.NotNil(t, j)
|
||||
resp := &altairBlockResponseJson{}
|
||||
require.NoError(t, json.Unmarshal(j, resp))
|
||||
require.NotNil(t, resp.Data)
|
||||
require.NotNil(t, resp.Data.Message)
|
||||
beaconBlock := resp.Data.Message
|
||||
assert.Equal(t, "1", beaconBlock.Slot)
|
||||
assert.Equal(t, "1", beaconBlock.ProposerIndex)
|
||||
assert.Equal(t, "root", beaconBlock.ParentRoot)
|
||||
assert.Equal(t, "root", beaconBlock.StateRoot)
|
||||
assert.NotNil(t, beaconBlock.Body)
|
||||
assert.Equal(t, true, resp.ExecutionOptimistic)
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
response := &BlindedBlockResponseJson{
|
||||
Version: ethpbv2.Version_BELLATRIX.String(),
|
||||
Data: &SignedBlindedBeaconBlockContainerJson{
|
||||
BellatrixBlock: &BlindedBeaconBlockBellatrixJson{
|
||||
Slot: "1",
|
||||
ProposerIndex: "1",
|
||||
ParentRoot: "root",
|
||||
StateRoot: "root",
|
||||
Body: &BlindedBeaconBlockBodyBellatrixJson{},
|
||||
},
|
||||
Signature: "sig",
|
||||
},
|
||||
ExecutionOptimistic: true,
|
||||
}
|
||||
runDefault, j, errJson := serializeBlindedBlock(response)
|
||||
require.Equal(t, nil, errJson)
|
||||
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
|
||||
require.NotNil(t, j)
|
||||
resp := &bellatrixBlindedBlockResponseJson{}
|
||||
require.NoError(t, json.Unmarshal(j, resp))
|
||||
require.NotNil(t, resp.Data)
|
||||
require.NotNil(t, resp.Data.Message)
|
||||
beaconBlock := resp.Data.Message
|
||||
assert.Equal(t, "1", beaconBlock.Slot)
|
||||
assert.Equal(t, "1", beaconBlock.ProposerIndex)
|
||||
assert.Equal(t, "root", beaconBlock.ParentRoot)
|
||||
assert.Equal(t, "root", beaconBlock.StateRoot)
|
||||
assert.NotNil(t, beaconBlock.Body)
|
||||
assert.Equal(t, true, resp.ExecutionOptimistic)
|
||||
})
|
||||
|
||||
t.Run("incorrect response type", func(t *testing.T) {
|
||||
response := &types.Empty{}
|
||||
runDefault, j, errJson := serializeBlindedBlock(response)
|
||||
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
|
||||
require.Equal(t, 0, len(j))
|
||||
require.NotNil(t, errJson)
|
||||
assert.Equal(t, true, strings.Contains(errJson.Msg(), "container is not of the correct type"))
|
||||
})
|
||||
|
||||
t.Run("unsupported block version", func(t *testing.T) {
|
||||
response := &BlindedBlockResponseJson{
|
||||
Version: "unsupported",
|
||||
}
|
||||
runDefault, j, errJson := serializeBlindedBlock(response)
|
||||
require.Equal(t, apimiddleware.RunDefault(false), runDefault)
|
||||
require.Equal(t, 0, len(j))
|
||||
require.NotNil(t, errJson)
|
||||
assert.Equal(t, true, strings.Contains(errJson.Msg(), "unsupported block version"))
|
||||
})
|
||||
}
|
||||
|
||||
func TestSerializeV2State(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
response := &BeaconStateV2ResponseJson{
|
||||
|
||||
@@ -33,6 +33,7 @@ func (_ *BeaconEndpointFactory) Paths() []string {
|
||||
"/eth/v2/beacon/blocks/{block_id}",
|
||||
"/eth/v1/beacon/blocks/{block_id}/root",
|
||||
"/eth/v1/beacon/blocks/{block_id}/attestations",
|
||||
"/eth/v1/beacon/blinded_blocks/{block_id}",
|
||||
"/eth/v1/beacon/pool/attestations",
|
||||
"/eth/v1/beacon/pool/attester_slashings",
|
||||
"/eth/v1/beacon/pool/proposer_slashings",
|
||||
@@ -132,6 +133,11 @@ func (_ *BeaconEndpointFactory) Create(path string) (*apimiddleware.Endpoint, er
|
||||
endpoint.GetResponse = &BlockRootResponseJson{}
|
||||
case "/eth/v1/beacon/blocks/{block_id}/attestations":
|
||||
endpoint.GetResponse = &BlockAttestationsResponseJson{}
|
||||
case "/eth/v1/beacon/blinded_blocks/{block_id}":
|
||||
endpoint.GetResponse = &BlindedBlockResponseJson{}
|
||||
endpoint.Hooks = apimiddleware.HookCollection{
|
||||
OnPreSerializeMiddlewareResponseIntoJson: serializeBlindedBlock,
|
||||
}
|
||||
case "/eth/v1/beacon/pool/attestations":
|
||||
endpoint.RequestQueryParams = []apimiddleware.QueryParam{{Name: "slot"}, {Name: "committee_index"}}
|
||||
endpoint.GetResponse = &AttestationsPoolResponseJson{}
|
||||
|
||||
@@ -105,6 +105,12 @@ type BlockV2ResponseJson struct {
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
}
|
||||
|
||||
type BlindedBlockResponseJson struct {
|
||||
Version string `json:"version" enum:"true"`
|
||||
Data *SignedBlindedBeaconBlockContainerJson `json:"data"`
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
}
|
||||
|
||||
type BlockRootResponseJson struct {
|
||||
Data *BlockRootContainerJson `json:"data"`
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
@@ -333,6 +339,13 @@ type SignedBeaconBlockContainerV2Json struct {
|
||||
Signature string `json:"signature" hex:"true"`
|
||||
}
|
||||
|
||||
type SignedBlindedBeaconBlockContainerJson struct {
|
||||
Phase0Block *BeaconBlockJson `json:"phase0_block"`
|
||||
AltairBlock *BeaconBlockAltairJson `json:"altair_block"`
|
||||
BellatrixBlock *BlindedBeaconBlockBellatrixJson `json:"bellatrix_block"`
|
||||
Signature string `json:"signature" hex:"true"`
|
||||
}
|
||||
|
||||
type BeaconBlockContainerV2Json struct {
|
||||
Phase0Block *BeaconBlockJson `json:"phase0_block"`
|
||||
AltairBlock *BeaconBlockAltairJson `json:"altair_block"`
|
||||
@@ -827,6 +840,7 @@ type SszRequestJson struct {
|
||||
// SszResponse is a common abstraction over all SSZ responses.
|
||||
type SszResponse interface {
|
||||
SSZVersion() string
|
||||
SSZOptimistic() bool
|
||||
SSZData() string
|
||||
}
|
||||
|
||||
@@ -842,9 +856,14 @@ func (*SszResponseJson) SSZVersion() string {
|
||||
return strings.ToLower(ethpbv2.Version_PHASE0.String())
|
||||
}
|
||||
|
||||
func (*SszResponseJson) SSZOptimistic() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type VersionedSSZResponseJson struct {
|
||||
Version string `json:"version"`
|
||||
Data string `json:"data"`
|
||||
Version string `json:"version"`
|
||||
ExecutionOptimistic bool `json:"execution_optimistic"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func (ssz *VersionedSSZResponseJson) SSZData() string {
|
||||
@@ -855,6 +874,10 @@ func (ssz *VersionedSSZResponseJson) SSZVersion() string {
|
||||
return ssz.Version
|
||||
}
|
||||
|
||||
func (ssz *VersionedSSZResponseJson) SSZOptimistic() bool {
|
||||
return ssz.ExecutionOptimistic
|
||||
}
|
||||
|
||||
// ---------------
|
||||
// Events.
|
||||
// ---------------
|
||||
|
||||
@@ -419,8 +419,11 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = blk.PbPhase0Block()
|
||||
phase0Blk, err := blk.PbPhase0Block()
|
||||
if err == nil {
|
||||
if phase0Blk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v1Blk, err := migration.SignedBeaconBlock(blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
@@ -442,7 +445,7 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (
|
||||
altairBlk, err := blk.PbAltairBlock()
|
||||
if err == nil {
|
||||
if altairBlk == nil {
|
||||
return nil, status.Errorf(codes.Internal, "Nil block")
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
|
||||
if err != nil {
|
||||
@@ -466,7 +469,7 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (
|
||||
bellatrixBlk, err := blk.PbBellatrixBlock()
|
||||
if err == nil {
|
||||
if bellatrixBlk == nil {
|
||||
return nil, status.Errorf(codes.Internal, "Nil block")
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBellatrixToV2(bellatrixBlk.Block)
|
||||
if err != nil {
|
||||
@@ -490,7 +493,15 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
}, nil
|
||||
}
|
||||
if _, err = blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
if blindedBellatrixBlk, err := blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
if blindedBellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
signedFullBlock, err := bs.ExecutionPayloadReconstructor.ReconstructFullBellatrixBlock(ctx, blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(
|
||||
@@ -544,8 +555,11 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = blk.PbPhase0Block()
|
||||
phase0Blk, err := blk.PbPhase0Block()
|
||||
if err == nil {
|
||||
if phase0Blk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
signedBeaconBlock, err := migration.SignedBeaconBlock(blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
@@ -554,7 +568,7 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_PHASE0, Data: sszBlock}, nil
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_PHASE0, ExecutionOptimistic: false, Data: sszBlock}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
@@ -564,7 +578,7 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
altairBlk, err := blk.PbAltairBlock()
|
||||
if err == nil {
|
||||
if altairBlk == nil {
|
||||
return nil, status.Errorf(codes.Internal, "Nil block")
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
|
||||
if err != nil {
|
||||
@@ -579,7 +593,7 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_ALTAIR, Data: sszData}, nil
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_ALTAIR, ExecutionOptimistic: false, Data: sszData}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
@@ -589,12 +603,20 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
bellatrixBlk, err := blk.PbBellatrixBlock()
|
||||
if err == nil {
|
||||
if bellatrixBlk == nil {
|
||||
return nil, status.Errorf(codes.Internal, "Nil block")
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBellatrixToV2(bellatrixBlk.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
data := ðpbv2.SignedBeaconBlockBellatrix{
|
||||
Message: v2Blk,
|
||||
@@ -604,10 +626,17 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_BELLATRIX, Data: sszData}, nil
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_BELLATRIX, ExecutionOptimistic: isOptimistic, Data: sszData}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
if _, err = blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
if blindedBellatrixBlk, err := blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
if blindedBellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
signedFullBlock, err := bs.ExecutionPayloadReconstructor.ReconstructFullBellatrixBlock(ctx, blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(
|
||||
@@ -624,6 +653,14 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
data := ðpbv2.SignedBeaconBlockBellatrix{
|
||||
Message: v2Blk,
|
||||
@@ -634,8 +671,277 @@ func (bs *Server) GetBlockSSZV2(ctx context.Context, req *ethpbv2.BlockRequestV2
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{
|
||||
Version: ethpbv2.Version_BELLATRIX,
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
Data: sszData,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
return nil, status.Errorf(codes.Internal, "Unknown block type %T", blk)
|
||||
}
|
||||
|
||||
// GetBlindedBlock retrieves blinded block for given block id.
|
||||
func (bs *Server) GetBlindedBlock(ctx context.Context, req *ethpbv1.BlockRequest) (*ethpbv2.BlindedBlockResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "beacon.GetBlindedBlock")
|
||||
defer span.End()
|
||||
|
||||
blk, err := bs.blockFromBlockID(ctx, req.BlockId)
|
||||
err = handleGetBlockError(blk, err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
phase0Blk, err := blk.PbPhase0Block()
|
||||
if err == nil {
|
||||
if phase0Blk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v1Blk, err := migration.SignedBeaconBlock(blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
return ðpbv2.BlindedBlockResponse{
|
||||
Version: ethpbv2.Version_PHASE0,
|
||||
Data: ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_Phase0Block{Phase0Block: v1Blk.Block},
|
||||
Signature: v1Blk.Signature,
|
||||
},
|
||||
ExecutionOptimistic: false,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
altairBlk, err := blk.PbAltairBlock()
|
||||
if err == nil {
|
||||
if altairBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
return ðpbv2.BlindedBlockResponse{
|
||||
Version: ethpbv2.Version_ALTAIR,
|
||||
Data: ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_AltairBlock{AltairBlock: v2Blk},
|
||||
Signature: sig[:],
|
||||
},
|
||||
ExecutionOptimistic: false,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
bellatrixBlk, err := blk.PbBellatrixBlock()
|
||||
if err == nil {
|
||||
if bellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
blindedBlkInterface, err := blk.ToBlinded()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not convert block to blinded block: %v", err)
|
||||
}
|
||||
blindedBellatrixBlock, err := blindedBlkInterface.PbBlindedBellatrixBlock()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(blindedBellatrixBlock.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
return ðpbv2.BlindedBlockResponse{
|
||||
Version: ethpbv2.Version_BELLATRIX,
|
||||
Data: sszData,
|
||||
Data: ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_BellatrixBlock{BellatrixBlock: v2Blk},
|
||||
Signature: sig[:],
|
||||
},
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
if blindedBellatrixBlk, err := blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
if blindedBellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(blindedBellatrixBlk.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
return ðpbv2.BlindedBlockResponse{
|
||||
Version: ethpbv2.Version_BELLATRIX,
|
||||
Data: ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_BellatrixBlock{BellatrixBlock: v2Blk},
|
||||
Signature: sig[:],
|
||||
},
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
return nil, status.Errorf(codes.Internal, "Unknown block type %T", blk)
|
||||
}
|
||||
|
||||
// GetBlindedBlockSSZ returns the SSZ-serialized version of the blinded beacon block for given block id.
|
||||
func (bs *Server) GetBlindedBlockSSZ(ctx context.Context, req *ethpbv1.BlockRequest) (*ethpbv2.SSZContainer, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "beacon.GetBlindedBlockSSZ")
|
||||
defer span.End()
|
||||
|
||||
blk, err := bs.blockFromBlockID(ctx, req.BlockId)
|
||||
err = handleGetBlockError(blk, err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
phase0Blk, err := blk.PbPhase0Block()
|
||||
if err == nil {
|
||||
if phase0Blk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
signedBeaconBlock, err := migration.SignedBeaconBlock(blk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
sszBlock, err := signedBeaconBlock.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_PHASE0, ExecutionOptimistic: false, Data: sszBlock}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
altairBlk, err := blk.PbAltairBlock()
|
||||
if err == nil {
|
||||
if altairBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockAltairToV2(altairBlk.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
data := ðpbv2.SignedBeaconBlockAltair{
|
||||
Message: v2Blk,
|
||||
Signature: sig[:],
|
||||
}
|
||||
sszData, err := data.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_ALTAIR, ExecutionOptimistic: false, Data: sszData}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
bellatrixBlk, err := blk.PbBellatrixBlock()
|
||||
if err == nil {
|
||||
if bellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
blindedBlkInterface, err := blk.ToBlinded()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not convert block to blinded block: %v", err)
|
||||
}
|
||||
blindedBellatrixBlock, err := blindedBlkInterface.PbBlindedBellatrixBlock()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(blindedBellatrixBlock.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
data := ðpbv2.SignedBlindedBeaconBlockBellatrix{
|
||||
Message: v2Blk,
|
||||
Signature: sig[:],
|
||||
}
|
||||
sszData, err := data.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{Version: ethpbv2.Version_BELLATRIX, ExecutionOptimistic: isOptimistic, Data: sszData}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
if blindedBellatrixBlk, err := blk.PbBlindedBellatrixBlock(); err == nil {
|
||||
if blindedBellatrixBlk == nil {
|
||||
return nil, status.Error(codes.Internal, "Nil block")
|
||||
}
|
||||
v2Blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(blindedBellatrixBlk.Block)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
root, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get block root: %v", err)
|
||||
}
|
||||
isOptimistic, err := bs.OptimisticModeFetcher.IsOptimisticForRoot(ctx, root)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if block is optimistic: %v", err)
|
||||
}
|
||||
sig := blk.Signature()
|
||||
data := ðpbv2.SignedBlindedBeaconBlockBellatrix{
|
||||
Message: v2Blk,
|
||||
Signature: sig[:],
|
||||
}
|
||||
sszData, err := data.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not marshal block into SSZ: %v", err)
|
||||
}
|
||||
return ðpbv2.SSZContainer{
|
||||
Version: ethpbv2.Version_BELLATRIX,
|
||||
ExecutionOptimistic: isOptimistic,
|
||||
Data: sszData,
|
||||
}, nil
|
||||
}
|
||||
// ErrUnsupportedGetter means that we have another block type
|
||||
|
||||
@@ -158,6 +158,48 @@ func fillDBTestBlocksBellatrix(ctx context.Context, t *testing.T, beaconDB db.Da
|
||||
return genBlk, blkContainers
|
||||
}
|
||||
|
||||
func fillDBTestBlocksBellatrixBlinded(ctx context.Context, t *testing.T, beaconDB db.Database) (*ethpbalpha.SignedBlindedBeaconBlockBellatrix, []*ethpbalpha.BeaconBlockContainer) {
|
||||
parentRoot := [32]byte{1, 2, 3}
|
||||
genBlk := util.NewBlindedBeaconBlockBellatrix()
|
||||
genBlk.Block.ParentRoot = parentRoot[:]
|
||||
root, err := genBlk.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
util.SaveBlock(t, ctx, beaconDB, genBlk)
|
||||
require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, root))
|
||||
|
||||
count := types.Slot(100)
|
||||
blks := make([]interfaces.SignedBeaconBlock, count)
|
||||
blkContainers := make([]*ethpbalpha.BeaconBlockContainer, count)
|
||||
for i := types.Slot(0); i < count; i++ {
|
||||
b := util.NewBlindedBeaconBlockBellatrix()
|
||||
b.Block.Slot = i
|
||||
b.Block.ParentRoot = bytesutil.PadTo([]byte{uint8(i)}, 32)
|
||||
att1 := util.NewAttestation()
|
||||
att1.Data.Slot = i
|
||||
att1.Data.CommitteeIndex = types.CommitteeIndex(i)
|
||||
att2 := util.NewAttestation()
|
||||
att2.Data.Slot = i
|
||||
att2.Data.CommitteeIndex = types.CommitteeIndex(i + 1)
|
||||
b.Block.Body.Attestations = []*ethpbalpha.Attestation{att1, att2}
|
||||
root, err := b.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
signedB, err := blocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
blks[i] = signedB
|
||||
blkContainers[i] = ðpbalpha.BeaconBlockContainer{
|
||||
Block: ðpbalpha.BeaconBlockContainer_BlindedBellatrixBlock{BlindedBellatrixBlock: b}, BlockRoot: root[:]}
|
||||
}
|
||||
require.NoError(t, beaconDB.SaveBlocks(ctx, blks))
|
||||
headRoot := bytesutil.ToBytes32(blkContainers[len(blks)-1].BlockRoot)
|
||||
summary := ðpbalpha.StateSummary{
|
||||
Root: headRoot[:],
|
||||
Slot: blkContainers[len(blks)-1].Block.(*ethpbalpha.BeaconBlockContainer_BlindedBellatrixBlock).BlindedBellatrixBlock.Block.Slot,
|
||||
}
|
||||
require.NoError(t, beaconDB.SaveStateSummary(ctx, summary))
|
||||
require.NoError(t, beaconDB.SaveHeadBlockRoot(ctx, headRoot))
|
||||
return genBlk, blkContainers
|
||||
}
|
||||
|
||||
func TestServer_GetBlockHeader(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
@@ -1500,6 +1542,444 @@ func TestServer_GetBlockV2(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_GetBlindedBlock(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genBlk, blkContainers := fillDBTestBlocks(ctx, t, beaconDB)
|
||||
canonicalRoots := make(map[[32]byte]bool)
|
||||
|
||||
for _, bContr := range blkContainers {
|
||||
canonicalRoots[bytesutil.ToBytes32(bContr.BlockRoot)] = true
|
||||
}
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
nextSlot := headBlock.GetPhase0Block().Block.Slot + 1
|
||||
|
||||
b2 := util.NewBeaconBlock()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
b3 := util.NewBeaconBlock()
|
||||
b3.Block.Slot = 30
|
||||
b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b3)
|
||||
b4 := util.NewBeaconBlock()
|
||||
b4.Block.Slot = nextSlot
|
||||
b4.Block.ParentRoot = bytesutil.PadTo([]byte{8}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b4)
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(headBlock.Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
mockChainService := &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: wsb,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
CanonicalRoots: canonicalRoots,
|
||||
}
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: mockChainService,
|
||||
HeadFetcher: mockChainService,
|
||||
OptimisticModeFetcher: mockChainService,
|
||||
}
|
||||
|
||||
root, err := genBlk.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
blockID []byte
|
||||
want *ethpbalpha.SignedBeaconBlock
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "slot",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block,
|
||||
},
|
||||
{
|
||||
name: "bad formatting",
|
||||
blockID: []byte("3bad0"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "canonical",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block,
|
||||
},
|
||||
{
|
||||
name: "non canonical",
|
||||
blockID: []byte(fmt.Sprintf("%d", nextSlot)),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "head",
|
||||
blockID: []byte("head"),
|
||||
want: headBlock.Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block,
|
||||
},
|
||||
{
|
||||
name: "finalized",
|
||||
blockID: []byte("finalized"),
|
||||
want: blkContainers[64].Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block,
|
||||
},
|
||||
{
|
||||
name: "genesis",
|
||||
blockID: []byte("genesis"),
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "genesis root",
|
||||
blockID: root[:],
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "root",
|
||||
blockID: blkContainers[20].BlockRoot,
|
||||
want: blkContainers[20].Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block,
|
||||
},
|
||||
{
|
||||
name: "non-existent root",
|
||||
blockID: bytesutil.PadTo([]byte("hi there"), 32),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "no block",
|
||||
blockID: []byte("105"),
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
blk, err := bs.GetBlindedBlock(ctx, ðpbv1.BlockRequest{
|
||||
BlockId: tt.blockID,
|
||||
})
|
||||
if tt.wantErr {
|
||||
require.NotEqual(t, err, nil)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
v1Block, err := migration.V1Alpha1ToV1SignedBlock(tt.want)
|
||||
require.NoError(t, err)
|
||||
|
||||
phase0Block, ok := blk.Data.Message.(*ethpbv2.SignedBlindedBeaconBlockContainer_Phase0Block)
|
||||
require.Equal(t, true, ok)
|
||||
if !reflect.DeepEqual(phase0Block.Phase0Block, v1Block.Block) {
|
||||
t.Error("Expected blocks to equal")
|
||||
}
|
||||
assert.Equal(t, ethpbv2.Version_PHASE0, blk.Version)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genBlk, blkContainers := fillDBTestBlocksAltair(ctx, t, beaconDB)
|
||||
canonicalRoots := make(map[[32]byte]bool)
|
||||
|
||||
for _, bContr := range blkContainers {
|
||||
canonicalRoots[bytesutil.ToBytes32(bContr.BlockRoot)] = true
|
||||
}
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
nextSlot := headBlock.GetAltairBlock().Block.Slot + 1
|
||||
|
||||
b2 := util.NewBeaconBlockAltair()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
b3 := util.NewBeaconBlockAltair()
|
||||
b3.Block.Slot = 30
|
||||
b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b3)
|
||||
b4 := util.NewBeaconBlockAltair()
|
||||
b4.Block.Slot = nextSlot
|
||||
b4.Block.ParentRoot = bytesutil.PadTo([]byte{8}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b4)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetAltairBlock())
|
||||
require.NoError(t, err)
|
||||
mockChainService := &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
CanonicalRoots: canonicalRoots,
|
||||
}
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: mockChainService,
|
||||
HeadFetcher: mockChainService,
|
||||
OptimisticModeFetcher: mockChainService,
|
||||
}
|
||||
|
||||
root, err := genBlk.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
blockID []byte
|
||||
want *ethpbalpha.SignedBeaconBlockAltair
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "slot",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].GetAltairBlock(),
|
||||
},
|
||||
{
|
||||
name: "bad formatting",
|
||||
blockID: []byte("3bad0"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "canonical",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].GetAltairBlock(),
|
||||
},
|
||||
{
|
||||
name: "non canonical",
|
||||
blockID: []byte(fmt.Sprintf("%d", nextSlot)),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "head",
|
||||
blockID: []byte("head"),
|
||||
want: headBlock.GetAltairBlock(),
|
||||
},
|
||||
{
|
||||
name: "finalized",
|
||||
blockID: []byte("finalized"),
|
||||
want: blkContainers[64].GetAltairBlock(),
|
||||
},
|
||||
{
|
||||
name: "genesis",
|
||||
blockID: []byte("genesis"),
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "genesis root",
|
||||
blockID: root[:],
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "root",
|
||||
blockID: blkContainers[20].BlockRoot,
|
||||
want: blkContainers[20].GetAltairBlock(),
|
||||
},
|
||||
{
|
||||
name: "non-existent root",
|
||||
blockID: bytesutil.PadTo([]byte("hi there"), 32),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "no block",
|
||||
blockID: []byte("105"),
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
blk, err := bs.GetBlindedBlock(ctx, ðpbv1.BlockRequest{
|
||||
BlockId: tt.blockID,
|
||||
})
|
||||
if tt.wantErr {
|
||||
require.NotEqual(t, err, nil)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
v2Block, err := migration.V1Alpha1BeaconBlockAltairToV2(tt.want.Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
altairBlock, ok := blk.Data.Message.(*ethpbv2.SignedBlindedBeaconBlockContainer_AltairBlock)
|
||||
require.Equal(t, true, ok)
|
||||
if !reflect.DeepEqual(altairBlock.AltairBlock, v2Block) {
|
||||
t.Error("Expected blocks to equal")
|
||||
}
|
||||
assert.Equal(t, ethpbv2.Version_ALTAIR, blk.Version)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genBlk, blkContainers := fillDBTestBlocksBellatrixBlinded(ctx, t, beaconDB)
|
||||
canonicalRoots := make(map[[32]byte]bool)
|
||||
|
||||
for _, bContr := range blkContainers {
|
||||
canonicalRoots[bytesutil.ToBytes32(bContr.BlockRoot)] = true
|
||||
}
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
nextSlot := headBlock.GetBlindedBellatrixBlock().Block.Slot + 1
|
||||
|
||||
b2 := util.NewBlindedBeaconBlockBellatrix()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
b3 := util.NewBlindedBeaconBlockBellatrix()
|
||||
b3.Block.Slot = 30
|
||||
b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b3)
|
||||
b4 := util.NewBlindedBeaconBlockBellatrix()
|
||||
b4.Block.Slot = nextSlot
|
||||
b4.Block.ParentRoot = bytesutil.PadTo([]byte{8}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b4)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetBlindedBellatrixBlock())
|
||||
require.NoError(t, err)
|
||||
mockChainService := &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
CanonicalRoots: canonicalRoots,
|
||||
}
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: mockChainService,
|
||||
HeadFetcher: mockChainService,
|
||||
OptimisticModeFetcher: mockChainService,
|
||||
ExecutionPayloadReconstructor: &executionTest.EngineClient{
|
||||
ExecutionPayloadByBlockHash: map[[32]byte]*enginev1.ExecutionPayload{},
|
||||
},
|
||||
}
|
||||
|
||||
root, err := genBlk.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
blockID []byte
|
||||
want *ethpbalpha.SignedBlindedBeaconBlockBellatrix
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "slot",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].GetBlindedBellatrixBlock(),
|
||||
},
|
||||
{
|
||||
name: "bad formatting",
|
||||
blockID: []byte("3bad0"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "canonical",
|
||||
blockID: []byte("30"),
|
||||
want: blkContainers[30].GetBlindedBellatrixBlock(),
|
||||
},
|
||||
{
|
||||
name: "non canonical",
|
||||
blockID: []byte(fmt.Sprintf("%d", nextSlot)),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "head",
|
||||
blockID: []byte("head"),
|
||||
want: headBlock.GetBlindedBellatrixBlock(),
|
||||
},
|
||||
{
|
||||
name: "finalized",
|
||||
blockID: []byte("finalized"),
|
||||
want: blkContainers[64].GetBlindedBellatrixBlock(),
|
||||
},
|
||||
{
|
||||
name: "genesis",
|
||||
blockID: []byte("genesis"),
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "genesis root",
|
||||
blockID: root[:],
|
||||
want: genBlk,
|
||||
},
|
||||
{
|
||||
name: "root",
|
||||
blockID: blkContainers[20].BlockRoot,
|
||||
want: blkContainers[20].GetBlindedBellatrixBlock(),
|
||||
},
|
||||
{
|
||||
name: "non-existent root",
|
||||
blockID: bytesutil.PadTo([]byte("hi there"), 32),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "no block",
|
||||
blockID: []byte("105"),
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
blk, err := bs.GetBlindedBlock(ctx, ðpbv1.BlockRequest{
|
||||
BlockId: tt.blockID,
|
||||
})
|
||||
if tt.wantErr {
|
||||
require.NotEqual(t, err, nil)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
v2Block, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(tt.want.Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
b, ok := blk.Data.Message.(*ethpbv2.SignedBlindedBeaconBlockContainer_BellatrixBlock)
|
||||
require.Equal(t, true, ok)
|
||||
if !reflect.DeepEqual(b.BellatrixBlock, v2Block) {
|
||||
t.Error("Expected blocks to equal")
|
||||
}
|
||||
assert.Equal(t, ethpbv2.Version_BELLATRIX, blk.Version)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("execution optimistic", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksBellatrix(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBeaconBlockBellatrix()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
b3 := util.NewBeaconBlockBellatrix()
|
||||
b3.Block.Slot = 30
|
||||
b3.Block.ParentRoot = bytesutil.PadTo([]byte{4}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b3)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetBellatrixBlock())
|
||||
require.NoError(t, err)
|
||||
mockChainService := &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
Optimistic: true,
|
||||
}
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: mockChainService,
|
||||
HeadFetcher: mockChainService,
|
||||
OptimisticModeFetcher: mockChainService,
|
||||
}
|
||||
|
||||
blk, err := bs.GetBlindedBlock(ctx, ðpbv1.BlockRequest{
|
||||
BlockId: []byte("head"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, blk.ExecutionOptimistic)
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_GetBlockSSZ(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
@@ -1525,10 +2005,10 @@ func TestServer_GetBlockSSZ(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
blocks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blocks) > 0)
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blocks[0].MarshalSSZ()
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
@@ -1563,10 +2043,10 @@ func TestServer_GetBlockSSZV2(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
blocks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blocks) > 0)
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blocks[0].MarshalSSZ()
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlockSSZV2(ctx, ðpbv2.BlockRequestV2{BlockId: []byte("30")})
|
||||
@@ -1600,10 +2080,10 @@ func TestServer_GetBlockSSZV2(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
blocks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blocks) > 0)
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blocks[0].MarshalSSZ()
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlockSSZV2(ctx, ðpbv2.BlockRequestV2{BlockId: []byte("30")})
|
||||
@@ -1635,12 +2115,13 @@ func TestServer_GetBlockSSZV2(t *testing.T) {
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
OptimisticModeFetcher: &mock.ChainService{},
|
||||
}
|
||||
|
||||
blocks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blocks) > 0)
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blocks[0].MarshalSSZ()
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlockSSZV2(ctx, ðpbv2.BlockRequestV2{BlockId: []byte("30")})
|
||||
@@ -1651,6 +2132,121 @@ func TestServer_GetBlockSSZV2(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_GetBlindedBlockSSZ(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocks(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBeaconBlock()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(headBlock.Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: wsb,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_PHASE0, resp.Version)
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksAltair(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBeaconBlockAltair()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetAltairBlock())
|
||||
require.NoError(t, err)
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_ALTAIR, resp.Version)
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksBellatrixBlinded(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBlindedBeaconBlockBellatrix()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetBlindedBellatrixBlock())
|
||||
require.NoError(t, err)
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
OptimisticModeFetcher: &mock.ChainService{},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_BELLATRIX, resp.Version)
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_GetBlockRoot(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -183,6 +183,12 @@ func (vs *Server) GetProposerDuties(ctx context.Context, req *ethpbv1.ProposerDu
|
||||
return nil, status.Errorf(codes.Internal, "Could not get dependent root: %v", err)
|
||||
}
|
||||
|
||||
slot, err := slots.EpochStart(req.Epoch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vs.ProposerSlotIndexCache.PrunePayloadIDs(slot)
|
||||
|
||||
return ðpbv1.ProposerDutiesResponse{
|
||||
DependentRoot: root,
|
||||
Data: duties,
|
||||
@@ -673,7 +679,7 @@ func (vs *Server) ProduceAttestationData(ctx context.Context, req *ethpbv1.Produ
|
||||
|
||||
// GetAggregateAttestation aggregates all attestations matching the given attestation data root and slot, returning the aggregated result.
|
||||
func (vs *Server) GetAggregateAttestation(ctx context.Context, req *ethpbv1.AggregateAttestationRequest) (*ethpbv1.AggregateAttestationResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation")
|
||||
_, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation")
|
||||
defer span.End()
|
||||
|
||||
allAtts := vs.AttestationsPool.AggregatedAttestations()
|
||||
|
||||
@@ -322,6 +322,28 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
assert.DeepEqual(t, pubKeys[9982], expectedDuty.Pubkey)
|
||||
})
|
||||
|
||||
t.Run("Prune payload ID cache ok", func(t *testing.T) {
|
||||
req := ðpbv1.ProposerDutiesRequest{
|
||||
Epoch: 1,
|
||||
}
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(1, 1, [8]byte{1}, [32]byte{2})
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(31, 2, [8]byte{2}, [32]byte{3})
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(32, 4309, [8]byte{3}, [32]byte{4})
|
||||
|
||||
_, err := vs.GetProposerDuties(ctx, req)
|
||||
require.NoError(t, err)
|
||||
|
||||
vid, _, has := vs.ProposerSlotIndexCache.GetProposerPayloadIDs(1, [32]byte{})
|
||||
require.Equal(t, false, has)
|
||||
require.Equal(t, types.ValidatorIndex(0), vid)
|
||||
vid, _, has = vs.ProposerSlotIndexCache.GetProposerPayloadIDs(2, [32]byte{})
|
||||
require.Equal(t, false, has)
|
||||
require.Equal(t, types.ValidatorIndex(0), vid)
|
||||
vid, _, has = vs.ProposerSlotIndexCache.GetProposerPayloadIDs(32, [32]byte{})
|
||||
require.Equal(t, true, has)
|
||||
require.Equal(t, types.ValidatorIndex(4309), vid)
|
||||
})
|
||||
|
||||
t.Run("Require slot processing", func(t *testing.T) {
|
||||
// We create local variables to not interfere with other tests.
|
||||
// Slot processing might have unexpected side-effects.
|
||||
|
||||
@@ -49,8 +49,8 @@ type ReadOnlyBeaconState interface {
|
||||
ReadOnlyBalances
|
||||
ReadOnlyCheckpoint
|
||||
ReadOnlyAttestations
|
||||
InnerStateUnsafe() interface{}
|
||||
CloneInnerState() interface{}
|
||||
ToProtoUnsafe() interface{}
|
||||
ToProto() interface{}
|
||||
GenesisTime() uint64
|
||||
GenesisValidatorsRoot() []byte
|
||||
Slot() types.Slot
|
||||
|
||||
@@ -86,6 +86,7 @@ go_test(
|
||||
"references_test.go",
|
||||
"setters_attestation_test.go",
|
||||
"setters_withdrawal_test.go",
|
||||
"state_fuzz_test.go",
|
||||
"state_test.go",
|
||||
"state_trie_test.go",
|
||||
"types_test.go",
|
||||
@@ -95,6 +96,7 @@ go_test(
|
||||
}),
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/core/transition:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native/types:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
@@ -104,6 +106,7 @@ go_test(
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//container/trie:go_default_library",
|
||||
"//crypto/rand:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
type BeaconState struct {
|
||||
version int
|
||||
genesisTime uint64 `ssz-gen:"true"`
|
||||
genesisValidatorsRoot customtypes.Byte32 `ssz-gen:"true" ssz-size:"32"`
|
||||
genesisValidatorsRoot [32]byte `ssz-gen:"true" ssz-size:"32"`
|
||||
slot eth2types.Slot `ssz-gen:"true"`
|
||||
fork *ethpb.Fork `ssz-gen:"true"`
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader `ssz-gen:"true"`
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
type BeaconState struct {
|
||||
version int
|
||||
genesisTime uint64 `ssz-gen:"true"`
|
||||
genesisValidatorsRoot customtypes.Byte32 `ssz-gen:"true" ssz-size:"32"`
|
||||
genesisValidatorsRoot [32]byte `ssz-gen:"true" ssz-size:"32"`
|
||||
slot eth2types.Slot `ssz-gen:"true"`
|
||||
fork *ethpb.Fork `ssz-gen:"true"`
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader `ssz-gen:"true"`
|
||||
|
||||
@@ -4,7 +4,6 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"block_roots.go",
|
||||
"byte32.go",
|
||||
"historical_roots.go",
|
||||
"randao_mixes.go",
|
||||
"state_roots.go",
|
||||
@@ -21,7 +20,6 @@ go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"block_roots_test.go",
|
||||
"byte32_test.go",
|
||||
"historical_roots_test.go",
|
||||
"randao_mixes_test.go",
|
||||
"state_roots_test.go",
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package customtypes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
fssz "github.com/prysmaticlabs/fastssz"
|
||||
)
|
||||
|
||||
var _ fssz.HashRoot = (Byte32)([32]byte{})
|
||||
var _ fssz.Marshaler = (*Byte32)(nil)
|
||||
var _ fssz.Unmarshaler = (*Byte32)(nil)
|
||||
|
||||
// Byte32 represents a 32 bytes Byte32 object in Ethereum beacon chain consensus.
|
||||
type Byte32 [32]byte
|
||||
|
||||
// HashTreeRoot returns calculated hash root.
|
||||
func (e Byte32) HashTreeRoot() ([32]byte, error) {
|
||||
return fssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith hashes a Byte32 object with a Hasher from the default HasherPool.
|
||||
func (e Byte32) HashTreeRootWith(hh *fssz.Hasher) error {
|
||||
hh.PutBytes(e[:])
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalSSZ deserializes the provided bytes buffer into the Byte32 object.
|
||||
func (e *Byte32) UnmarshalSSZ(buf []byte) error {
|
||||
if len(buf) != e.SizeSSZ() {
|
||||
return fmt.Errorf("expected buffer of length %d received %d", e.SizeSSZ(), len(buf))
|
||||
}
|
||||
|
||||
var b Byte32
|
||||
copy(b[:], buf)
|
||||
*e = b
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalSSZTo marshals Byte32 with the provided byte slice.
|
||||
func (e *Byte32) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalled, err := e.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append(dst, marshalled...), nil
|
||||
}
|
||||
|
||||
// MarshalSSZ marshals Byte32 into a serialized object.
|
||||
func (e *Byte32) MarshalSSZ() ([]byte, error) {
|
||||
return e[:], nil
|
||||
}
|
||||
|
||||
// SizeSSZ returns the size of the serialized object.
|
||||
func (_ *Byte32) SizeSSZ() int {
|
||||
return 32
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package customtypes
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestByte32_Casting(t *testing.T) {
|
||||
var b [32]byte
|
||||
d := Byte32(b)
|
||||
if !reflect.DeepEqual([32]byte(d), b) {
|
||||
t.Errorf("Unequal: %v = %v", d, b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestByte32_UnmarshalSSZ(t *testing.T) {
|
||||
t.Run("Ok", func(t *testing.T) {
|
||||
d := Byte32{}
|
||||
var b = [32]byte{'f', 'o', 'o'}
|
||||
err := d.UnmarshalSSZ(b[:])
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(b, [32]byte(d)) {
|
||||
t.Errorf("Unequal: %v = %v", b, [32]byte(d))
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Wrong slice length", func(t *testing.T) {
|
||||
d := Byte32{}
|
||||
var b = [16]byte{'f', 'o', 'o'}
|
||||
err := d.UnmarshalSSZ(b[:])
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestByte32_MarshalSSZTo(t *testing.T) {
|
||||
d := Byte32{'f', 'o', 'o'}
|
||||
dst := []byte("bar")
|
||||
b, err := d.MarshalSSZTo(dst)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
rest := [29]byte{}
|
||||
expected := append([]byte("barfoo"), rest[:]...)
|
||||
if !reflect.DeepEqual(expected, b) {
|
||||
t.Errorf("Unequal: %v = %v", expected, b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestByte32_MarshalSSZ(t *testing.T) {
|
||||
d := Byte32{'f', 'o', 'o'}
|
||||
b, err := d.MarshalSSZ()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
actual := [32]byte(d)
|
||||
if !reflect.DeepEqual(b, actual[:]) {
|
||||
t.Errorf("Unequal: %v = %v", b, [32]byte(d))
|
||||
}
|
||||
}
|
||||
|
||||
func TestByte32_SizeSSZ(t *testing.T) {
|
||||
d := Byte32{}
|
||||
if d.SizeSSZ() != 32 {
|
||||
t.Errorf("Wrong SSZ size. Expected %v vs actual %v", 32, d.SizeSSZ())
|
||||
}
|
||||
}
|
||||
@@ -338,14 +338,3 @@ func ProtobufBeaconStateCapella(s interface{}) (*ethpb.BeaconStateCapella, error
|
||||
}
|
||||
return pbState, nil
|
||||
}
|
||||
|
||||
// InnerStateUnsafe returns the pointer value of the underlying
|
||||
// beacon state proto object, bypassing immutability. Use with care.
|
||||
func (b *BeaconState) InnerStateUnsafe() interface{} {
|
||||
return b.ToProtoUnsafe()
|
||||
}
|
||||
|
||||
// CloneInnerState the beacon state into a protobuf for usage.
|
||||
func (b *BeaconState) CloneInnerState() interface{} {
|
||||
return b.ToProto()
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestComputeFieldRootsWithHasher_Phase0(t *testing.T) {
|
||||
|
||||
nativeState, ok := beaconState.(*statenative.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
protoState, ok := nativeState.InnerStateUnsafe().(*ethpb.BeaconState)
|
||||
protoState, ok := nativeState.ToProtoUnsafe().(*ethpb.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
initState, err := statenative.InitializeFromProtoPhase0(protoState)
|
||||
@@ -112,7 +112,7 @@ func TestComputeFieldRootsWithHasher_Altair(t *testing.T) {
|
||||
|
||||
nativeState, ok := beaconState.(*statenative.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
protoState, ok := nativeState.InnerStateUnsafe().(*ethpb.BeaconStateAltair)
|
||||
protoState, ok := nativeState.ToProtoUnsafe().(*ethpb.BeaconStateAltair)
|
||||
require.Equal(t, true, ok)
|
||||
initState, err := statenative.InitializeFromProtoAltair(protoState)
|
||||
require.NoError(t, err)
|
||||
@@ -185,7 +185,7 @@ func TestComputeFieldRootsWithHasher_Bellatrix(t *testing.T) {
|
||||
|
||||
nativeState, ok := beaconState.(*statenative.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
protoState, ok := nativeState.InnerStateUnsafe().(*ethpb.BeaconStateBellatrix)
|
||||
protoState, ok := nativeState.ToProtoUnsafe().(*ethpb.BeaconStateBellatrix)
|
||||
require.Equal(t, true, ok)
|
||||
initState, err := statenative.InitializeFromProtoBellatrix(protoState)
|
||||
require.NoError(t, err)
|
||||
@@ -262,7 +262,7 @@ func TestComputeFieldRootsWithHasher_Capella(t *testing.T) {
|
||||
|
||||
nativeState, ok := beaconState.(*statenative.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
protoState, ok := nativeState.InnerStateUnsafe().(*ethpb.BeaconStateCapella)
|
||||
protoState, ok := nativeState.ToProtoUnsafe().(*ethpb.BeaconStateCapella)
|
||||
require.Equal(t, true, ok)
|
||||
initState, err := statenative.InitializeFromProtoCapella(protoState)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package state_native
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
)
|
||||
|
||||
@@ -22,3 +26,51 @@ func TestBeaconState_RotateAttestations(t *testing.T) {
|
||||
require.Equal(t, 0, len(s.currentEpochAttestationsVal()))
|
||||
require.Equal(t, types.Slot(456), s.previousEpochAttestationsVal()[0].Data.Slot)
|
||||
}
|
||||
|
||||
func TestAppendBeyondIndicesLimit(t *testing.T) {
|
||||
zeroHash := params.BeaconConfig().ZeroHash
|
||||
mockblockRoots := make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot)
|
||||
for i := 0; i < len(mockblockRoots); i++ {
|
||||
mockblockRoots[i] = zeroHash[:]
|
||||
}
|
||||
|
||||
mockstateRoots := make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot)
|
||||
for i := 0; i < len(mockstateRoots); i++ {
|
||||
mockstateRoots[i] = zeroHash[:]
|
||||
}
|
||||
mockrandaoMixes := make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector)
|
||||
for i := 0; i < len(mockrandaoMixes); i++ {
|
||||
mockrandaoMixes[i] = zeroHash[:]
|
||||
}
|
||||
st, err := InitializeFromProtoPhase0(ðpb.BeaconState{
|
||||
Slot: 1,
|
||||
CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 456}}},
|
||||
PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: ðpb.AttestationData{Slot: 123}}},
|
||||
Validators: []*ethpb.Validator{},
|
||||
Eth1Data: ðpb.Eth1Data{},
|
||||
BlockRoots: mockblockRoots,
|
||||
StateRoots: mockstateRoots,
|
||||
RandaoMixes: mockrandaoMixes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = st.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
s, ok := st.(*BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
for i := nativetypes.FieldIndex(0); i < nativetypes.FieldIndex(params.BeaconConfig().BeaconStateFieldCount); i++ {
|
||||
s.dirtyFields[i] = true
|
||||
}
|
||||
_, err = st.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
for i := 0; i < 10; i++ {
|
||||
assert.NoError(t, st.AppendValidator(ðpb.Validator{}))
|
||||
}
|
||||
assert.Equal(t, false, s.rebuildTrie[nativetypes.Validators])
|
||||
assert.NotEqual(t, len(s.dirtyIndices[nativetypes.Validators]), 0)
|
||||
|
||||
for i := 0; i < indicesLimit; i++ {
|
||||
assert.NoError(t, st.AppendValidator(ðpb.Validator{}))
|
||||
}
|
||||
assert.Equal(t, true, s.rebuildTrie[nativetypes.Validators])
|
||||
assert.Equal(t, len(s.dirtyIndices[nativetypes.Validators]), 0)
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
||||
return errNotSupported("SetNextWithdrawalIndex", b.version)
|
||||
}
|
||||
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
b.nextWithdrawalIndex = i
|
||||
return nil
|
||||
@@ -78,8 +78,8 @@ func (b *BeaconState) SetNextPartialWithdrawalValidatorIndex(i types.ValidatorIn
|
||||
return errNotSupported("SetNextPartialWithdrawalValidatorIndex", b.version)
|
||||
}
|
||||
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
b.nextPartialWithdrawalValidatorIndex = i
|
||||
return nil
|
||||
|
||||
@@ -18,11 +18,13 @@ func TestSetWithdrawalQueue(t *testing.T) {
|
||||
WithdrawalIndex: 0,
|
||||
ExecutionAddress: []byte("address1"),
|
||||
Amount: 1,
|
||||
ValidatorIndex: 2,
|
||||
},
|
||||
{
|
||||
WithdrawalIndex: 1,
|
||||
ExecutionAddress: []byte("address2"),
|
||||
Amount: 2,
|
||||
ValidatorIndex: 3,
|
||||
},
|
||||
}
|
||||
newQ := []*enginev1.Withdrawal{
|
||||
@@ -30,11 +32,13 @@ func TestSetWithdrawalQueue(t *testing.T) {
|
||||
WithdrawalIndex: 2,
|
||||
ExecutionAddress: []byte("address3"),
|
||||
Amount: 3,
|
||||
ValidatorIndex: 4,
|
||||
},
|
||||
{
|
||||
WithdrawalIndex: 3,
|
||||
ExecutionAddress: []byte("address4"),
|
||||
Amount: 4,
|
||||
ValidatorIndex: 5,
|
||||
},
|
||||
}
|
||||
s := BeaconState{
|
||||
@@ -61,11 +65,13 @@ func TestAppendWithdrawal(t *testing.T) {
|
||||
WithdrawalIndex: 0,
|
||||
ExecutionAddress: []byte("address1"),
|
||||
Amount: 1,
|
||||
ValidatorIndex: 2,
|
||||
}
|
||||
oldWithdrawal2 := &enginev1.Withdrawal{
|
||||
WithdrawalIndex: 1,
|
||||
ExecutionAddress: []byte("address2"),
|
||||
Amount: 2,
|
||||
ValidatorIndex: 3,
|
||||
}
|
||||
q := []*enginev1.Withdrawal{oldWithdrawal1, oldWithdrawal2}
|
||||
s := BeaconState{
|
||||
@@ -80,6 +86,7 @@ func TestAppendWithdrawal(t *testing.T) {
|
||||
WithdrawalIndex: 2,
|
||||
ExecutionAddress: []byte("address3"),
|
||||
Amount: 3,
|
||||
ValidatorIndex: 4,
|
||||
}
|
||||
err := s.AppendWithdrawal(newWithdrawal)
|
||||
require.NoError(t, err)
|
||||
|
||||
294
beacon-chain/state/state-native/state_fuzz_test.go
Normal file
294
beacon-chain/state/state-native/state_fuzz_test.go
Normal file
@@ -0,0 +1,294 @@
|
||||
package state_native_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
coreState "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/rand"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
)
|
||||
|
||||
func FuzzPhase0StateHashTreeRoot(f *testing.F) {
|
||||
gState, _ := util.DeterministicGenesisState(f, 100)
|
||||
output, err := gState.MarshalSSZ()
|
||||
assert.NoError(f, err)
|
||||
randPool := make([]byte, 100)
|
||||
_, err = rand.NewDeterministicGenerator().Read(randPool)
|
||||
assert.NoError(f, err)
|
||||
f.Add(randPool, uint64(10))
|
||||
f.Fuzz(func(t *testing.T, diffBuffer []byte, slotsToTransition uint64) {
|
||||
stateSSZ := bytesutil.SafeCopyBytes(output)
|
||||
for i := 0; i < len(diffBuffer); i += 9 {
|
||||
if i+8 >= len(diffBuffer) {
|
||||
return
|
||||
}
|
||||
num := bytesutil.BytesToUint64BigEndian(diffBuffer[i : i+8])
|
||||
num %= uint64(len(diffBuffer))
|
||||
// Perform a XOR on the byte of the selected index.
|
||||
stateSSZ[num] ^= diffBuffer[i+8]
|
||||
}
|
||||
pbState := ðpb.BeaconState{}
|
||||
err := pbState.UnmarshalSSZ(stateSSZ)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nativeState, err := native.InitializeFromProtoPhase0(pbState)
|
||||
assert.NoError(t, err)
|
||||
|
||||
slotsToTransition %= 100
|
||||
stateObj, err := native.InitializeFromProtoUnsafePhase0(pbState)
|
||||
assert.NoError(t, err)
|
||||
for stateObj.Slot() < types.Slot(slotsToTransition) {
|
||||
stateObj, err = coreState.ProcessSlots(context.Background(), stateObj, stateObj.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
stateObj.Copy()
|
||||
|
||||
nativeState, err = coreState.ProcessSlots(context.Background(), nativeState, nativeState.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
nativeState.Copy()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
// Perform a cold HTR calculation by initializing a new state.
|
||||
innerState, ok := stateObj.ToProtoUnsafe().(*ethpb.BeaconState)
|
||||
assert.Equal(t, true, ok, "inner state is a not a beacon state proto")
|
||||
newState, err := native.InitializeFromProtoUnsafePhase0(innerState)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newRt, newErr := newState.HashTreeRoot(context.Background())
|
||||
rt, err := stateObj.HashTreeRoot(context.Background())
|
||||
nativeRt, nativeErr := nativeState.HashTreeRoot(context.Background())
|
||||
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.Equal(t, rt, newRt)
|
||||
assert.Equal(t, rt, nativeRt)
|
||||
}
|
||||
|
||||
newSSZ, newErr := newState.MarshalSSZ()
|
||||
stateObjSSZ, err := stateObj.MarshalSSZ()
|
||||
nativeSSZ, nativeErr := nativeState.MarshalSSZ()
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.DeepEqual(t, newSSZ, stateObjSSZ)
|
||||
assert.DeepEqual(t, newSSZ, nativeSSZ)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzAltairStateHashTreeRoot(f *testing.F) {
|
||||
gState, _ := util.DeterministicGenesisStateAltair(f, 100)
|
||||
output, err := gState.MarshalSSZ()
|
||||
assert.NoError(f, err)
|
||||
randPool := make([]byte, 100)
|
||||
_, err = rand.NewDeterministicGenerator().Read(randPool)
|
||||
assert.NoError(f, err)
|
||||
f.Add(randPool, uint64(10))
|
||||
f.Fuzz(func(t *testing.T, diffBuffer []byte, slotsToTransition uint64) {
|
||||
stateSSZ := bytesutil.SafeCopyBytes(output)
|
||||
for i := 0; i < len(diffBuffer); i += 9 {
|
||||
if i+8 >= len(diffBuffer) {
|
||||
return
|
||||
}
|
||||
num := bytesutil.BytesToUint64BigEndian(diffBuffer[i : i+8])
|
||||
num %= uint64(len(diffBuffer))
|
||||
// Perform a XOR on the byte of the selected index.
|
||||
stateSSZ[num] ^= diffBuffer[i+8]
|
||||
}
|
||||
pbState := ðpb.BeaconStateAltair{}
|
||||
err := pbState.UnmarshalSSZ(stateSSZ)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nativeState, err := native.InitializeFromProtoAltair(pbState)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
slotsToTransition %= 100
|
||||
stateObj, err := native.InitializeFromProtoUnsafeAltair(pbState)
|
||||
assert.NoError(t, err)
|
||||
for stateObj.Slot() < types.Slot(slotsToTransition) {
|
||||
stateObj, err = coreState.ProcessSlots(context.Background(), stateObj, stateObj.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
stateObj.Copy()
|
||||
|
||||
nativeState, err = coreState.ProcessSlots(context.Background(), nativeState, nativeState.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
nativeState.Copy()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
// Perform a cold HTR calculation by initializing a new state.
|
||||
innerState, ok := stateObj.ToProtoUnsafe().(*ethpb.BeaconStateAltair)
|
||||
assert.Equal(t, true, ok, "inner state is a not a beacon state altair proto")
|
||||
newState, err := native.InitializeFromProtoUnsafeAltair(innerState)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newRt, newErr := newState.HashTreeRoot(context.Background())
|
||||
rt, err := stateObj.HashTreeRoot(context.Background())
|
||||
nativeRt, nativeErr := nativeState.HashTreeRoot(context.Background())
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.Equal(t, rt, newRt)
|
||||
assert.Equal(t, rt, nativeRt)
|
||||
}
|
||||
|
||||
newSSZ, newErr := newState.MarshalSSZ()
|
||||
stateObjSSZ, err := stateObj.MarshalSSZ()
|
||||
nativeSSZ, nativeErr := nativeState.MarshalSSZ()
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.DeepEqual(t, newSSZ, stateObjSSZ)
|
||||
assert.DeepEqual(t, newSSZ, nativeSSZ)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzBellatrixStateHashTreeRoot(f *testing.F) {
|
||||
gState, _ := util.DeterministicGenesisStateBellatrix(f, 100)
|
||||
output, err := gState.MarshalSSZ()
|
||||
assert.NoError(f, err)
|
||||
randPool := make([]byte, 100)
|
||||
_, err = rand.NewDeterministicGenerator().Read(randPool)
|
||||
assert.NoError(f, err)
|
||||
f.Add(randPool, uint64(10))
|
||||
f.Fuzz(func(t *testing.T, diffBuffer []byte, slotsToTransition uint64) {
|
||||
stateSSZ := bytesutil.SafeCopyBytes(output)
|
||||
for i := 0; i < len(diffBuffer); i += 9 {
|
||||
if i+8 >= len(diffBuffer) {
|
||||
return
|
||||
}
|
||||
num := bytesutil.BytesToUint64BigEndian(diffBuffer[i : i+8])
|
||||
num %= uint64(len(diffBuffer))
|
||||
// Perform a XOR on the byte of the selected index.
|
||||
stateSSZ[num] ^= diffBuffer[i+8]
|
||||
}
|
||||
pbState := ðpb.BeaconStateBellatrix{}
|
||||
err := pbState.UnmarshalSSZ(stateSSZ)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nativeState, err := native.InitializeFromProtoBellatrix(pbState)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
slotsToTransition %= 100
|
||||
stateObj, err := native.InitializeFromProtoUnsafeBellatrix(pbState)
|
||||
assert.NoError(t, err)
|
||||
for stateObj.Slot() < types.Slot(slotsToTransition) {
|
||||
stateObj, err = coreState.ProcessSlots(context.Background(), stateObj, stateObj.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
stateObj.Copy()
|
||||
|
||||
nativeState, err = coreState.ProcessSlots(context.Background(), nativeState, nativeState.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
nativeState.Copy()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
// Perform a cold HTR calculation by initializing a new state.
|
||||
innerState, ok := stateObj.ToProtoUnsafe().(*ethpb.BeaconStateBellatrix)
|
||||
assert.Equal(t, true, ok, "inner state is a not a beacon state bellatrix proto")
|
||||
newState, err := native.InitializeFromProtoUnsafeBellatrix(innerState)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newRt, newErr := newState.HashTreeRoot(context.Background())
|
||||
rt, err := stateObj.HashTreeRoot(context.Background())
|
||||
nativeRt, nativeErr := nativeState.HashTreeRoot(context.Background())
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.Equal(t, rt, newRt)
|
||||
assert.Equal(t, rt, nativeRt)
|
||||
}
|
||||
|
||||
newSSZ, newErr := newState.MarshalSSZ()
|
||||
stateObjSSZ, err := stateObj.MarshalSSZ()
|
||||
nativeSSZ, nativeErr := nativeState.MarshalSSZ()
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.DeepEqual(t, newSSZ, stateObjSSZ)
|
||||
assert.DeepEqual(t, newSSZ, nativeSSZ)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func FuzzCapellaStateHashTreeRoot(f *testing.F) {
|
||||
gState, _ := util.DeterministicGenesisStateCapella(f, 100)
|
||||
output, err := gState.MarshalSSZ()
|
||||
assert.NoError(f, err)
|
||||
randPool := make([]byte, 100)
|
||||
_, err = rand.NewDeterministicGenerator().Read(randPool)
|
||||
assert.NoError(f, err)
|
||||
f.Add(randPool, uint64(10))
|
||||
f.Fuzz(func(t *testing.T, diffBuffer []byte, slotsToTransition uint64) {
|
||||
stateSSZ := bytesutil.SafeCopyBytes(output)
|
||||
for i := 0; i < len(diffBuffer); i += 9 {
|
||||
if i+8 >= len(diffBuffer) {
|
||||
return
|
||||
}
|
||||
num := bytesutil.BytesToUint64BigEndian(diffBuffer[i : i+8])
|
||||
num %= uint64(len(diffBuffer))
|
||||
// Perform a XOR on the byte of the selected index.
|
||||
stateSSZ[num] ^= diffBuffer[i+8]
|
||||
}
|
||||
pbState := ðpb.BeaconStateCapella{}
|
||||
err := pbState.UnmarshalSSZ(stateSSZ)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nativeState, err := native.InitializeFromProtoCapella(pbState)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
slotsToTransition %= 100
|
||||
stateObj, err := native.InitializeFromProtoUnsafeCapella(pbState)
|
||||
assert.NoError(t, err)
|
||||
for stateObj.Slot() < types.Slot(slotsToTransition) {
|
||||
stateObj, err = coreState.ProcessSlots(context.Background(), stateObj, stateObj.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
stateObj.Copy()
|
||||
|
||||
nativeState, err = coreState.ProcessSlots(context.Background(), nativeState, nativeState.Slot()+1)
|
||||
assert.NoError(t, err)
|
||||
nativeState.Copy()
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
// Perform a cold HTR calculation by initializing a new state.
|
||||
innerState, ok := stateObj.ToProtoUnsafe().(*ethpb.BeaconStateCapella)
|
||||
assert.Equal(t, true, ok, "inner state is a not a beacon state bellatrix proto")
|
||||
newState, err := native.InitializeFromProtoUnsafeCapella(innerState)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newRt, newErr := newState.HashTreeRoot(context.Background())
|
||||
rt, err := stateObj.HashTreeRoot(context.Background())
|
||||
nativeRt, nativeErr := nativeState.HashTreeRoot(context.Background())
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.Equal(t, rt, newRt)
|
||||
assert.Equal(t, rt, nativeRt)
|
||||
}
|
||||
|
||||
newSSZ, newErr := newState.MarshalSSZ()
|
||||
stateObjSSZ, err := stateObj.MarshalSSZ()
|
||||
nativeSSZ, nativeErr := nativeState.MarshalSSZ()
|
||||
assert.Equal(t, newErr != nil, err != nil)
|
||||
assert.Equal(t, newErr != nil, nativeErr != nil)
|
||||
if err == nil {
|
||||
assert.DeepEqual(t, newSSZ, stateObjSSZ)
|
||||
assert.DeepEqual(t, newSSZ, nativeSSZ)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
func TestInitializeFromProto_Phase0(t *testing.T) {
|
||||
testState, _ := util.DeterministicGenesisState(t, 64)
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
type test struct {
|
||||
name string
|
||||
@@ -168,7 +168,7 @@ func TestInitializeFromProto_Capella(t *testing.T) {
|
||||
|
||||
func TestInitializeFromProtoUnsafe_Phase0(t *testing.T) {
|
||||
testState, _ := util.DeterministicGenesisState(t, 64)
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
type test struct {
|
||||
name string
|
||||
@@ -350,7 +350,7 @@ func TestBeaconState_HashTreeRoot(t *testing.T) {
|
||||
if err == nil && tt.error != "" {
|
||||
t.Errorf("Expected error, expected %v, recevied %v", tt.error, err)
|
||||
}
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
genericHTR, err := pbState.HashTreeRoot()
|
||||
if err == nil && tt.error != "" {
|
||||
@@ -368,7 +368,7 @@ func TestBeaconState_HashTreeRoot(t *testing.T) {
|
||||
|
||||
func BenchmarkBeaconState(b *testing.B) {
|
||||
testState, _ := util.DeterministicGenesisState(b, 16000)
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(b, err)
|
||||
|
||||
b.Run("Vectorized SHA256", func(b *testing.B) {
|
||||
@@ -437,7 +437,7 @@ func TestBeaconState_HashTreeRoot_FieldTrie(t *testing.T) {
|
||||
if err == nil && tt.error != "" {
|
||||
t.Errorf("Expected error, expected %v, recevied %v", tt.error, err)
|
||||
}
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
genericHTR, err := pbState.HashTreeRoot()
|
||||
if err == nil && tt.error != "" {
|
||||
@@ -468,7 +468,7 @@ func TestBeaconState_AppendValidator_DoesntMutateCopy(t *testing.T) {
|
||||
|
||||
func TestBeaconState_ValidatorMutation_Phase0(t *testing.T) {
|
||||
testState, _ := util.DeterministicGenesisState(t, 400)
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
testState, err = statenative.InitializeFromProtoPhase0(pbState)
|
||||
require.NoError(t, err)
|
||||
@@ -497,7 +497,7 @@ func TestBeaconState_ValidatorMutation_Phase0(t *testing.T) {
|
||||
|
||||
rt, err := testState.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStatePhase0(testState.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStatePhase0(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err := statenative.InitializeFromProtoPhase0(pbState)
|
||||
@@ -521,7 +521,7 @@ func TestBeaconState_ValidatorMutation_Phase0(t *testing.T) {
|
||||
|
||||
rt, err = newState1.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStatePhase0(newState1.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStatePhase0(newState1.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err = statenative.InitializeFromProtoPhase0(pbState)
|
||||
@@ -535,7 +535,7 @@ func TestBeaconState_ValidatorMutation_Phase0(t *testing.T) {
|
||||
|
||||
func TestBeaconState_ValidatorMutation_Altair(t *testing.T) {
|
||||
testState, _ := util.DeterministicGenesisStateAltair(t, 400)
|
||||
pbState, err := statenative.ProtobufBeaconStateAltair(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStateAltair(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
testState, err = statenative.InitializeFromProtoAltair(pbState)
|
||||
require.NoError(t, err)
|
||||
@@ -564,7 +564,7 @@ func TestBeaconState_ValidatorMutation_Altair(t *testing.T) {
|
||||
|
||||
rt, err := testState.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStateAltair(testState.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStateAltair(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err := statenative.InitializeFromProtoAltair(pbState)
|
||||
@@ -588,7 +588,7 @@ func TestBeaconState_ValidatorMutation_Altair(t *testing.T) {
|
||||
|
||||
rt, err = newState1.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStateAltair(newState1.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStateAltair(newState1.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err = statenative.InitializeFromProtoAltair(pbState)
|
||||
@@ -602,7 +602,7 @@ func TestBeaconState_ValidatorMutation_Altair(t *testing.T) {
|
||||
|
||||
func TestBeaconState_ValidatorMutation_Bellatrix(t *testing.T) {
|
||||
testState, _ := util.DeterministicGenesisStateBellatrix(t, 400)
|
||||
pbState, err := statenative.ProtobufBeaconStateBellatrix(testState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStateBellatrix(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
testState, err = statenative.InitializeFromProtoBellatrix(pbState)
|
||||
require.NoError(t, err)
|
||||
@@ -631,7 +631,7 @@ func TestBeaconState_ValidatorMutation_Bellatrix(t *testing.T) {
|
||||
|
||||
rt, err := testState.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStateBellatrix(testState.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStateBellatrix(testState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err := statenative.InitializeFromProtoBellatrix(pbState)
|
||||
@@ -655,7 +655,7 @@ func TestBeaconState_ValidatorMutation_Bellatrix(t *testing.T) {
|
||||
|
||||
rt, err = newState1.HashTreeRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
pbState, err = statenative.ProtobufBeaconStateBellatrix(newState1.InnerStateUnsafe())
|
||||
pbState, err = statenative.ProtobufBeaconStateBellatrix(newState1.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
|
||||
copiedTestState, err = statenative.InitializeFromProtoBellatrix(pbState)
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
cloned, ok := proto.Clone(genesis).(*ethpb.BeaconState)
|
||||
assert.Equal(t, true, ok, "Object is not of type *ethpb.BeaconState")
|
||||
custom := customState.CloneInnerState()
|
||||
custom := customState.ToProto()
|
||||
assert.DeepSSZEqual(t, cloned, custom)
|
||||
|
||||
r1, err := customState.HashTreeRoot(ctx)
|
||||
@@ -141,7 +141,7 @@ func BenchmarkStateClone_Manual(b *testing.B) {
|
||||
require.NoError(b, err)
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = st.CloneInnerState()
|
||||
_ = st.ToProto()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ func TestForkManualCopy_OK(t *testing.T) {
|
||||
}
|
||||
require.NoError(t, a.SetFork(wantedFork))
|
||||
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(a.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(a.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, pbState.Fork, wantedFork)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestEpochBoundaryStateCache_CanSaveAndDelete(t *testing.T) {
|
||||
got, exists, err = e.getByBlockRoot([32]byte{'a'})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, exists, "Should exist")
|
||||
assert.DeepSSZEqual(t, s.InnerStateUnsafe(), got.state.InnerStateUnsafe(), "Should have the same state")
|
||||
assert.DeepSSZEqual(t, s.ToProtoUnsafe(), got.state.ToProtoUnsafe(), "Should have the same state")
|
||||
|
||||
got, exists, err = e.getBySlot(2)
|
||||
require.NoError(t, err)
|
||||
@@ -45,7 +45,7 @@ func TestEpochBoundaryStateCache_CanSaveAndDelete(t *testing.T) {
|
||||
got, exists, err = e.getBySlot(1)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, exists, "Should exist")
|
||||
assert.DeepSSZEqual(t, s.InnerStateUnsafe(), got.state.InnerStateUnsafe(), "Should have the same state")
|
||||
assert.DeepSSZEqual(t, s.ToProtoUnsafe(), got.state.ToProtoUnsafe(), "Should have the same state")
|
||||
|
||||
require.NoError(t, e.delete(r))
|
||||
got, exists, err = e.getByBlockRoot([32]byte{'b'})
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestStateByRoot_GenesisState(t *testing.T) {
|
||||
require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, bRoot))
|
||||
loadedState, err := service.StateByRoot(ctx, params.BeaconConfig().ZeroHash) // Zero hash is genesis state root.
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestStateByRoot_ColdState(t *testing.T) {
|
||||
@@ -53,7 +53,7 @@ func TestStateByRoot_ColdState(t *testing.T) {
|
||||
require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, bRoot))
|
||||
loadedState, err := service.StateByRoot(ctx, bRoot)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
|
||||
bal, err := service.BalancesByRoot(ctx, bRoot)
|
||||
require.NoError(t, err)
|
||||
@@ -75,7 +75,7 @@ func TestStateByRootIfCachedNoCopy_HotState(t *testing.T) {
|
||||
service.hotStateCache.put(r, beaconState)
|
||||
|
||||
loadedState := service.StateByRootIfCachedNoCopy(r)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestStateByRootIfCachedNoCopy_ColdState(t *testing.T) {
|
||||
@@ -157,7 +157,7 @@ func TestStateByRoot_HotStateCached(t *testing.T) {
|
||||
|
||||
loadedState, err := service.StateByRoot(ctx, r)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestDeleteStateFromCaches(t *testing.T) {
|
||||
@@ -203,7 +203,7 @@ func TestStateByRoot_StateByRootInitialSync(t *testing.T) {
|
||||
require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, bRoot))
|
||||
loadedState, err := service.StateByRootInitialSync(ctx, params.BeaconConfig().ZeroHash) // Zero hash is genesis state root.
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestStateByRootInitialSync_UseEpochStateCache(t *testing.T) {
|
||||
@@ -237,7 +237,7 @@ func TestStateByRootInitialSync_UseCache(t *testing.T) {
|
||||
|
||||
loadedState, err := service.StateByRootInitialSync(ctx, r)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
if service.hotStateCache.has(r) {
|
||||
t.Error("Hot state cache was not invalidated")
|
||||
}
|
||||
@@ -279,7 +279,7 @@ func TestLoadeStateByRoot_Cached(t *testing.T) {
|
||||
// This tests where hot state was already cached.
|
||||
loadedState, err := service.loadStateByRoot(ctx, r)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestLoadeStateByRoot_FinalizedState(t *testing.T) {
|
||||
@@ -303,7 +303,7 @@ func TestLoadeStateByRoot_FinalizedState(t *testing.T) {
|
||||
// This tests where hot state was already cached.
|
||||
loadedState, err := service.loadStateByRoot(ctx, gRoot)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, loadedState.InnerStateUnsafe(), beaconState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, loadedState.ToProtoUnsafe(), beaconState.ToProtoUnsafe())
|
||||
}
|
||||
|
||||
func TestLoadeStateByRoot_EpochBoundaryStateCanProcess(t *testing.T) {
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestHotStateCache_RoundTrip(t *testing.T) {
|
||||
|
||||
res := c.get(root)
|
||||
assert.NotNil(t, s)
|
||||
assert.DeepEqual(t, res.CloneInnerState(), s.CloneInnerState(), "Expected equal protos to return from cache")
|
||||
assert.DeepEqual(t, res.ToProto(), s.ToProto(), "Expected equal protos to return from cache")
|
||||
|
||||
c.delete(root)
|
||||
assert.Equal(t, false, c.has(root), "Cache not supposed to have the object")
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestMigrateToCold_HappyPath(t *testing.T) {
|
||||
|
||||
gotState, err := service.beaconDB.State(ctx, fRoot)
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, beaconState.InnerStateUnsafe(), gotState.InnerStateUnsafe(), "Did not save state")
|
||||
assert.DeepSSZEqual(t, beaconState.ToProtoUnsafe(), gotState.ToProtoUnsafe(), "Did not save state")
|
||||
gotRoot := service.beaconDB.ArchivedPointRoot(ctx, stateSlot/service.slotsPerArchivedPoint)
|
||||
assert.Equal(t, fRoot, gotRoot, "Did not save archived root")
|
||||
lastIndex, err := service.beaconDB.LastArchivedSlot(ctx)
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestResume(t *testing.T) {
|
||||
|
||||
resumeState, err := service.Resume(ctx, beaconState)
|
||||
require.NoError(t, err)
|
||||
require.DeepSSZEqual(t, beaconState.InnerStateUnsafe(), resumeState.InnerStateUnsafe())
|
||||
require.DeepSSZEqual(t, beaconState.ToProtoUnsafe(), resumeState.ToProtoUnsafe())
|
||||
assert.Equal(t, params.BeaconConfig().SlotsPerEpoch, service.finalizedInfo.slot, "Did not get watned slot")
|
||||
assert.Equal(t, service.finalizedInfo.root, root, "Did not get wanted root")
|
||||
assert.NotNil(t, service.finalizedState(), "Wanted a non nil finalized state")
|
||||
|
||||
@@ -88,6 +88,7 @@ go_library(
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/wrapper:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//container/slice:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/rand:go_default_library",
|
||||
@@ -105,7 +106,6 @@ go_library(
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_hashicorp_golang_lru//:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/host:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
@@ -204,6 +204,7 @@ go_test(
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/wrapper:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/rand:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
@@ -223,7 +224,6 @@ go_test(
|
||||
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
|
||||
@@ -31,13 +31,13 @@ go_library(
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//crypto/rand:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
"@com_github_paulbellamy_ratecounter//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
@@ -83,7 +83,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
@@ -126,6 +125,7 @@ go_test(
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//container/leaky-bucket:go_default_library",
|
||||
"//container/slice:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
@@ -136,7 +136,6 @@ go_test(
|
||||
"//time:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db"
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/rand"
|
||||
p2ppb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -54,6 +54,9 @@ var (
|
||||
errNoPeersWithAltBlocks = errors.New("no peers with alternative blocks found")
|
||||
)
|
||||
|
||||
// Period to calculate expected limit for a single peer.
|
||||
var blockLimiterPeriod = 30 * time.Second
|
||||
|
||||
// blocksFetcherConfig is a config to setup the block fetcher.
|
||||
type blocksFetcherConfig struct {
|
||||
chain blockchainService
|
||||
@@ -114,7 +117,7 @@ func newBlocksFetcher(ctx context.Context, cfg *blocksFetcherConfig) *blocksFetc
|
||||
// Allow fetcher to go almost to the full burst capacity (less a single batch).
|
||||
rateLimiter := leakybucket.NewCollector(
|
||||
float64(blocksPerSecond), int64(allowedBlocksBurst-blocksPerSecond),
|
||||
false /* deleteEmptyBuckets */)
|
||||
blockLimiterPeriod, false /* deleteEmptyBuckets */)
|
||||
|
||||
capacityWeight := cfg.peerFilterCapacityWeight
|
||||
if capacityWeight >= 1 {
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/peers/scorers"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
prysmTime "github.com/prysmaticlabs/prysm/v3/time"
|
||||
@@ -237,7 +237,7 @@ func TestBlocksFetcher_filterPeers(t *testing.T) {
|
||||
peerFilterCapacityWeight: tt.args.capacityWeight,
|
||||
})
|
||||
// Non-leaking bucket, with initial capacity of 10000.
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(0.000001, 10000, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(0.000001, 10000, 1*time.Second, false)
|
||||
peerIDs := make([]peer.ID, 0)
|
||||
for _, pid := range tt.args.peers {
|
||||
peerIDs = append(peerIDs, pid.ID)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
libp2pcore "github.com/libp2p/go-libp2p/core"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/container/slice"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
@@ -547,7 +547,7 @@ func TestBlocksFetcher_RequestBlocksRateLimitingLocks(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
fetcher := newBlocksFetcher(ctx, &blocksFetcherConfig{p2p: p1})
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(float64(req.Count), int64(req.Count*burstFactor), false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(float64(req.Count), int64(req.Count*burstFactor), 1*time.Second, false)
|
||||
fetcher.chain = &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
|
||||
hook := logTest.NewGlobal()
|
||||
wg := new(sync.WaitGroup)
|
||||
@@ -842,7 +842,7 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
fetcher := newBlocksFetcher(ctx, &blocksFetcherConfig{p2p: p1, chain: &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}})
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(0.000001, 640, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(0.000001, 640, 1*time.Second, false)
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
@@ -59,7 +59,7 @@ func TestBlocksFetcher_nonSkippedSlotAfter(t *testing.T) {
|
||||
p2p: p2p,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
seekSlots := map[types.Slot]types.Slot{
|
||||
0: 1,
|
||||
10: 11,
|
||||
@@ -191,7 +191,7 @@ func TestBlocksFetcher_findFork(t *testing.T) {
|
||||
db: beaconDB,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
|
||||
// Consume all chain1 blocks from many peers (alternative fork will be featured by a single peer,
|
||||
// and should still be enough to explore alternative paths).
|
||||
@@ -339,7 +339,7 @@ func TestBlocksFetcher_findForkWithPeer(t *testing.T) {
|
||||
db: beaconDB,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
|
||||
for _, blk := range knownBlocks {
|
||||
util.SaveBlock(t, ctx, beaconDB, blk)
|
||||
@@ -455,7 +455,7 @@ func TestBlocksFetcher_findAncestor(t *testing.T) {
|
||||
db: beaconDB,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
pcl := fmt.Sprintf("%s/ssz_snappy", p2pm.RPCBlocksByRootTopicV1)
|
||||
|
||||
t.Run("error on request", func(t *testing.T) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
dbtest "github.com/prysmaticlabs/prysm/v3/beacon-chain/db/testing"
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/container/slice"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
@@ -134,6 +134,11 @@ func TestBlocksQueue_InitStartStop(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlocksQueue_Loop(t *testing.T) {
|
||||
currentPeriod := blockLimiterPeriod
|
||||
blockLimiterPeriod = 1 * time.Second
|
||||
defer func() {
|
||||
blockLimiterPeriod = currentPeriod
|
||||
}()
|
||||
tests := []struct {
|
||||
name string
|
||||
highestExpectedSlot types.Slot
|
||||
@@ -1075,7 +1080,7 @@ func TestBlocksQueue_stuckInUnfavourableFork(t *testing.T) {
|
||||
db: beaconDB,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
|
||||
queue := newBlocksQueue(ctx, &blocksQueueConfig{
|
||||
blocksFetcher: fetcher,
|
||||
@@ -1295,7 +1300,7 @@ func TestBlocksQueue_stuckWhenHeadIsSetToOrphanedBlock(t *testing.T) {
|
||||
db: beaconDB,
|
||||
},
|
||||
)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, false)
|
||||
fetcher.rateLimiter = leakybucket.NewCollector(6400, 6400, 1*time.Second, false)
|
||||
|
||||
// Connect peer that has all the blocks available.
|
||||
allBlocksPeer := connectPeerHavingBlocks(t, p2p, chain, finalizedSlot, p2p.Peers())
|
||||
|
||||
@@ -22,6 +22,11 @@ import (
|
||||
)
|
||||
|
||||
func TestService_roundRobinSync(t *testing.T) {
|
||||
currentPeriod := blockLimiterPeriod
|
||||
blockLimiterPeriod = 1 * time.Second
|
||||
defer func() {
|
||||
blockLimiterPeriod = currentPeriod
|
||||
}()
|
||||
tests := []struct {
|
||||
name string
|
||||
currentSlot types.Slot
|
||||
@@ -488,6 +493,11 @@ func TestService_processBlockBatch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestService_blockProviderScoring(t *testing.T) {
|
||||
currentPeriod := blockLimiterPeriod
|
||||
blockLimiterPeriod = 1 * time.Second
|
||||
defer func() {
|
||||
blockLimiterPeriod = currentPeriod
|
||||
}()
|
||||
cache.initializeRootCache(makeSequence(1, 640), t)
|
||||
|
||||
p := p2pt.NewTestP2P(t)
|
||||
|
||||
@@ -3,19 +3,25 @@ package sync
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p"
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/trailofbits/go-mutexasserts"
|
||||
)
|
||||
|
||||
const defaultBurstLimit = 5
|
||||
|
||||
const leakyBucketPeriod = 1 * time.Second
|
||||
|
||||
// Only allow in 2 batches per minute.
|
||||
const blockBucketPeriod = 30 * time.Second
|
||||
|
||||
// Dummy topic to validate all incoming rpc requests.
|
||||
const rpcLimiterTopic = "rpc-limiter-topic"
|
||||
|
||||
@@ -39,19 +45,19 @@ func newRateLimiter(p2pProvider p2p.P2P) *limiter {
|
||||
// Set topic map for all rpc topics.
|
||||
topicMap := make(map[string]*leakybucket.Collector, len(p2p.RPCTopicMappings))
|
||||
// Goodbye Message
|
||||
topicMap[addEncoding(p2p.RPCGoodByeTopicV1)] = leakybucket.NewCollector(1, 1, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCGoodByeTopicV1)] = leakybucket.NewCollector(1, 1, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
// MetadataV0 Message
|
||||
topicMap[addEncoding(p2p.RPCMetaDataTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCMetaDataTopicV2)] = leakybucket.NewCollector(1, defaultBurstLimit, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCMetaDataTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCMetaDataTopicV2)] = leakybucket.NewCollector(1, defaultBurstLimit, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
// Ping Message
|
||||
topicMap[addEncoding(p2p.RPCPingTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCPingTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
// Status Message
|
||||
topicMap[addEncoding(p2p.RPCStatusTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, false /* deleteEmptyBuckets */)
|
||||
topicMap[addEncoding(p2p.RPCStatusTopicV1)] = leakybucket.NewCollector(1, defaultBurstLimit, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
|
||||
// Use a single collector for block requests
|
||||
blockCollector := leakybucket.NewCollector(allowedBlocksPerSecond, allowedBlocksBurst, false /* deleteEmptyBuckets */)
|
||||
blockCollector := leakybucket.NewCollector(allowedBlocksPerSecond, allowedBlocksBurst, blockBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
// Collector for V2
|
||||
blockCollectorV2 := leakybucket.NewCollector(allowedBlocksPerSecond, allowedBlocksBurst, false /* deleteEmptyBuckets */)
|
||||
blockCollectorV2 := leakybucket.NewCollector(allowedBlocksPerSecond, allowedBlocksBurst, blockBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
|
||||
// BlocksByRoots requests
|
||||
topicMap[addEncoding(p2p.RPCBlocksByRootTopicV1)] = blockCollector
|
||||
@@ -62,7 +68,7 @@ func newRateLimiter(p2pProvider p2p.P2P) *limiter {
|
||||
topicMap[addEncoding(p2p.RPCBlocksByRangeTopicV2)] = blockCollectorV2
|
||||
|
||||
// General topic for all rpc requests.
|
||||
topicMap[rpcLimiterTopic] = leakybucket.NewCollector(5, defaultBurstLimit*2, false /* deleteEmptyBuckets */)
|
||||
topicMap[rpcLimiterTopic] = leakybucket.NewCollector(5, defaultBurstLimit*2, leakyBucketPeriod, false /* deleteEmptyBuckets */)
|
||||
|
||||
return &limiter{limiterMap: topicMap, p2p: p2pProvider}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
chainMock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -28,6 +27,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
@@ -67,7 +67,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsBlocks(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -129,7 +129,7 @@ func TestRPCBeaconBlocksByRange_ReturnCorrectNumberBack(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -246,7 +246,7 @@ func TestRPCBeaconBlocksByRange_ReconstructsPayloads(t *testing.T) {
|
||||
}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -314,7 +314,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerReturnsSortedBlocks(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, int64(req.Count*10), time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -379,7 +379,7 @@ func TestRPCBeaconBlocksByRange_ReturnsGenesisBlock(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -471,7 +471,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) {
|
||||
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 100,
|
||||
Step: 5,
|
||||
@@ -497,7 +497,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) {
|
||||
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, time.Second, false)
|
||||
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 100,
|
||||
@@ -526,7 +526,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRangeTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(0.000001, capacity, time.Second, false)
|
||||
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 100,
|
||||
@@ -723,7 +723,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 448,
|
||||
Step: 1,
|
||||
@@ -891,7 +891,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 1,
|
||||
Step: 1,
|
||||
@@ -922,7 +922,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 1,
|
||||
Step: 1,
|
||||
@@ -957,7 +957,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 1,
|
||||
Step: 1,
|
||||
@@ -992,7 +992,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 1,
|
||||
Step: 1,
|
||||
@@ -1032,7 +1032,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
|
||||
assert.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected")
|
||||
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d, chain: &chainMock.ChainService{}}, rateLimiter: newRateLimiter(p1)}
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, false)
|
||||
r.rateLimiter.limiterMap[string(pcl)] = leakybucket.NewCollector(0.000001, 640, time.Second, false)
|
||||
req := ðpb.BeaconBlocksByRangeRequest{
|
||||
StartSlot: 1,
|
||||
Step: 1,
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
gcache "github.com/patrickmn/go-cache"
|
||||
@@ -24,6 +23,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
@@ -54,7 +54,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks(t *testing.T) {
|
||||
r.cfg.chain = &mock.ChainService{ValidatorsRoot: [32]byte{}}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRootTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -152,7 +152,7 @@ func TestRecentBeaconBlocksRPCHandler_ReturnsBlocks_ReconstructsPayload(t *testi
|
||||
r.cfg.chain = &mock.ChainService{ValidatorsRoot: [32]byte{}}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRootTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -224,7 +224,7 @@ func TestRecentBeaconBlocks_RPCRequestSent(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/beacon_blocks_by_root/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(10000, 10000, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -261,7 +261,7 @@ func TestRecentBeaconBlocksRPCHandler_HandleZeroBlocks(t *testing.T) {
|
||||
r := &Service{cfg: &config{p2p: p1, beaconDB: d}, rateLimiter: newRateLimiter(p1)}
|
||||
pcl := protocol.ID(p2p.RPCBlocksByRootTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
||||
@@ -44,7 +44,7 @@ func TestGoodByeRPCHandler_Disconnects_With_Peer(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/testing")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -89,7 +89,7 @@ func TestGoodByeRPCHandler_BackOffPeer(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/testing")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -166,7 +166,7 @@ func TestSendGoodbye_SendsMessage(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/goodbye/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -211,7 +211,7 @@ func TestSendGoodbye_DisconnectWithPeer(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/goodbye/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
p2ptest "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/testing"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/wrapper"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz/equality"
|
||||
pb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/metadata"
|
||||
@@ -53,7 +53,7 @@ func TestMetaDataRPCHandler_ReceivesMetadata(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID(p2p.RPCMetaDataTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -112,8 +112,8 @@ func TestMetadataRPCHandler_SendsMetadata(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID(p2p.RPCMetaDataTopicV1 + r.cfg.p2p.Encoding().ProtocolSuffix())
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -179,8 +179,8 @@ func TestMetadataRPCHandler_SendsMetadataAltair(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID(p2p.RPCMetaDataTopicV2 + r.cfg.p2p.Encoding().ProtocolSuffix())
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(2, 2, false)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(2, 2, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(2, 2, time.Second, false)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(2, 2, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p/types"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/wrapper"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
pb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
@@ -54,7 +54,7 @@ func TestPingRPCHandler_ReceivesPing(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID(p2p.RPCPingTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -123,7 +123,7 @@ func TestPingRPCHandler_SendsPing(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/ping/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -183,7 +183,7 @@ func TestPingRPCHandler_BadSequenceNumber(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/testing")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/kevinms/leakybucket-go"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
@@ -25,6 +24,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/wrapper"
|
||||
leakybucket "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
@@ -62,7 +62,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) {
|
||||
}
|
||||
pcl := protocol.ID(p2p.RPCStatusTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -77,7 +77,7 @@ func TestStatusRPCHandler_Disconnects_OnForkVersionMismatch(t *testing.T) {
|
||||
|
||||
pcl2 := protocol.ID("/eth2/beacon_chain/req/goodbye/1/ssz_snappy")
|
||||
topic = string(pcl2)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg2 sync.WaitGroup
|
||||
wg2.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl2, func(stream network.Stream) {
|
||||
@@ -130,7 +130,7 @@ func TestStatusRPCHandler_ConnectsOnGenesis(t *testing.T) {
|
||||
}
|
||||
pcl := protocol.ID(p2p.RPCStatusTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
@@ -214,7 +214,7 @@ func TestStatusRPCHandler_ReturnsHelloMessage(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID(p2p.RPCStatusTopicV1)
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -317,7 +317,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/status/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -339,7 +339,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) {
|
||||
|
||||
pcl = "/eth2/beacon_chain/req/ping/1/ssz_snappy"
|
||||
topic = string(pcl)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r2.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg2 sync.WaitGroup
|
||||
wg2.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -434,7 +434,7 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/status/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -542,7 +542,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/status/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -726,7 +726,7 @@ func TestStatusRPCRequest_FinalizedBlockSkippedSlots(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/status/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
@@ -795,7 +795,7 @@ func TestStatusRPCRequest_BadPeerHandshake(t *testing.T) {
|
||||
// Setup streams
|
||||
pcl := protocol.ID("/eth2/beacon_chain/req/status/1/ssz_snappy")
|
||||
topic := string(pcl)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, false)
|
||||
r.rateLimiter.limiterMap[topic] = leakybucket.NewCollector(1, 1, time.Second, false)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
p2.BHost.SetStreamHandler(pcl, func(stream network.Stream) {
|
||||
|
||||
@@ -165,7 +165,7 @@ var (
|
||||
BlockBatchLimitBurstFactor = &cli.IntFlag{
|
||||
Name: "block-batch-limit-burst-factor",
|
||||
Usage: "The factor by which block batch limit may increase on burst.",
|
||||
Value: 10,
|
||||
Value: 2,
|
||||
}
|
||||
// EnableDebugRPCEndpoints as /v1/beacon/state.
|
||||
EnableDebugRPCEndpoints = &cli.BoolFlag{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/validator/flags"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||
@@ -148,5 +150,47 @@ var Commands = &cli.Command{
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "voluntary-exit",
|
||||
Description: "Performs a voluntary exit on selected accounts",
|
||||
Flags: cmd.WrapFlags([]cli.Flag{
|
||||
flags.WalletDirFlag,
|
||||
flags.WalletPasswordFileFlag,
|
||||
flags.AccountPasswordFileFlag,
|
||||
flags.VoluntaryExitPublicKeysFlag,
|
||||
flags.BeaconRPCProviderFlag,
|
||||
flags.Web3SignerURLFlag,
|
||||
flags.Web3SignerPublicValidatorKeysFlag,
|
||||
flags.InteropNumValidators,
|
||||
flags.InteropStartIndex,
|
||||
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
||||
flags.CertFlag,
|
||||
flags.GrpcHeadersFlag,
|
||||
flags.GrpcRetriesFlag,
|
||||
flags.GrpcRetryDelayFlag,
|
||||
flags.ExitAllFlag,
|
||||
features.Mainnet,
|
||||
features.PraterTestnet,
|
||||
features.RopstenTestnet,
|
||||
features.SepoliaTestnet,
|
||||
cmd.AcceptTosFlag,
|
||||
}),
|
||||
Before: func(cliCtx *cli.Context) error {
|
||||
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tos.VerifyTosAcceptedOrPrompt(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
return features.ConfigureValidator(cliCtx)
|
||||
},
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
log.Info("This command will be deprecated in the future in favor of `prysmctl sign validator-exit`")
|
||||
if err := AccountsExit(cliCtx, os.Stdin); err != nil {
|
||||
log.WithError(err).Fatal("Could not perform voluntary exit")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
22
container/leaky-bucket/BUILD.bazel
Normal file
22
container/leaky-bucket/BUILD.bazel
Normal file
@@ -0,0 +1,22 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"collector.go",
|
||||
"heap.go",
|
||||
"leakybucket.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/container/leaky-bucket",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"collector_test.go",
|
||||
"heap_test.go",
|
||||
"leakybucket_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
21
container/leaky-bucket/LICENSE
Normal file
21
container/leaky-bucket/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 kevinms
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
202
container/leaky-bucket/collector.go
Normal file
202
container/leaky-bucket/collector.go
Normal file
@@ -0,0 +1,202 @@
|
||||
package leakybucket
|
||||
|
||||
import (
|
||||
"container/heap"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
//TODO: Finer grained locking.
|
||||
|
||||
type bucketMap map[string]*LeakyBucket
|
||||
|
||||
// A Collector can keep track of multiple LeakyBucket's. The caller does not
|
||||
// directly interact with the buckets, but instead addresses them by a string
|
||||
// key (e.g. IP address, hostname, hash, etc.) that is passed to most Collector
|
||||
// methods.
|
||||
//
|
||||
// All Collector methods are goroutine safe.
|
||||
type Collector struct {
|
||||
buckets bucketMap
|
||||
heap priorityQueue
|
||||
rate float64
|
||||
capacity int64
|
||||
period time.Duration
|
||||
lock sync.Mutex
|
||||
quit chan bool
|
||||
}
|
||||
|
||||
// NewCollector creates a new Collector. When new buckets are created within
|
||||
// the Collector, they will be assigned the capacity and rate of the Collector.
|
||||
// A Collector does not provide a way to change the rate or capacity of
|
||||
// bucket's within it. If different rates or capacities are required, either
|
||||
// use multiple Collector's or manage your own LeakyBucket's.
|
||||
//
|
||||
// If deleteEmptyBuckets is true, a concurrent goroutine will be run that
|
||||
// watches for bucket's that become empty and automatically removes them,
|
||||
// freeing up memory resources.
|
||||
func NewCollector(rate float64, capacity int64, period time.Duration, deleteEmptyBuckets bool) *Collector {
|
||||
c := &Collector{
|
||||
buckets: make(bucketMap),
|
||||
heap: make(priorityQueue, 0, 4096),
|
||||
rate: rate,
|
||||
capacity: capacity,
|
||||
period: period,
|
||||
quit: make(chan bool),
|
||||
}
|
||||
|
||||
if deleteEmptyBuckets {
|
||||
c.PeriodicPrune()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// Free releases the collector's resources. If the collector was created with
|
||||
// deleteEmptyBuckets = true, then the goroutine looking for empty buckets,
|
||||
// will be stopped.
|
||||
func (c *Collector) Free() {
|
||||
c.Reset()
|
||||
close(c.quit)
|
||||
}
|
||||
|
||||
// Reset removes all internal buckets and resets the collector back to as if it
|
||||
// was just created.
|
||||
func (c *Collector) Reset() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// Let the garbage collector do all the work.
|
||||
c.buckets = make(bucketMap)
|
||||
c.heap = make(priorityQueue, 0, 4096)
|
||||
}
|
||||
|
||||
// Capacity returns the collector's capacity.
|
||||
func (c *Collector) Capacity() int64 {
|
||||
return c.capacity
|
||||
}
|
||||
|
||||
// Rate returns the collector's rate.
|
||||
func (c *Collector) Rate() float64 {
|
||||
return c.rate
|
||||
}
|
||||
|
||||
// Remaining returns the remaining capacity of the internal bucket associated
|
||||
// with key. If key is not associated with a bucket internally, it is treated
|
||||
// as being empty.
|
||||
func (c *Collector) Remaining(key string) int64 {
|
||||
return c.capacity - c.Count(key)
|
||||
}
|
||||
|
||||
// Count returns the count of the internal bucket associated with key. If key
|
||||
// is not associated with a bucket internally, it is treated as being empty.
|
||||
func (c *Collector) Count(key string) int64 {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
b, ok := c.buckets[key]
|
||||
if !ok || b == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return b.Count()
|
||||
}
|
||||
|
||||
// TillEmpty returns how much time must pass until the internal bucket
|
||||
// associated with key is empty. If key is not associated with a bucket
|
||||
// internally, it is treated as being empty.
|
||||
func (c *Collector) TillEmpty(key string) time.Duration {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
b, ok := c.buckets[key]
|
||||
if !ok || b == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return b.TillEmpty()
|
||||
}
|
||||
|
||||
// Remove deletes the internal bucket associated with key. If key is not
|
||||
// associated with a bucket internally, nothing is done.
|
||||
func (c *Collector) Remove(key string) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
b, ok := c.buckets[key]
|
||||
if !ok || b == nil {
|
||||
return
|
||||
}
|
||||
|
||||
delete(c.buckets, b.key)
|
||||
heap.Remove(&c.heap, b.index)
|
||||
}
|
||||
|
||||
// Add 'amount' to the internal bucket associated with key, up to it's
|
||||
// capacity. Returns how much was added to the bucket. If the return is less
|
||||
// than 'amount', then the bucket's capacity was reached.
|
||||
//
|
||||
// If key is not associated with a bucket internally, a new bucket is created
|
||||
// and amount is added to it.
|
||||
func (c *Collector) Add(key string, amount int64) int64 {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
b, ok := c.buckets[key]
|
||||
|
||||
if !ok || b == nil {
|
||||
// Create a new bucket.
|
||||
b = &LeakyBucket{
|
||||
key: key,
|
||||
capacity: c.capacity,
|
||||
rate: c.rate,
|
||||
period: c.period,
|
||||
p: now(),
|
||||
}
|
||||
c.heap.Push(b)
|
||||
c.buckets[key] = b
|
||||
}
|
||||
|
||||
n := b.Add(amount)
|
||||
|
||||
if n > 0 {
|
||||
heap.Fix(&c.heap, b.index)
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
// Prune removes all empty buckets in the collector.
|
||||
func (c *Collector) Prune() {
|
||||
c.lock.Lock()
|
||||
for c.heap.Peak() != nil {
|
||||
b := c.heap.Peak()
|
||||
|
||||
if now().Before(b.p) {
|
||||
// The bucket isn't empty.
|
||||
break
|
||||
}
|
||||
|
||||
// The bucket should be empty.
|
||||
delete(c.buckets, b.key)
|
||||
heap.Remove(&c.heap, b.index)
|
||||
}
|
||||
c.lock.Unlock()
|
||||
}
|
||||
|
||||
// PeriodicPrune runs a concurrent goroutine that calls Prune() at the given
|
||||
// time interval.
|
||||
func (c *Collector) PeriodicPrune() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(c.period)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
c.Prune()
|
||||
case <-c.quit:
|
||||
ticker.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
210
container/leaky-bucket/collector_test.go
Normal file
210
container/leaky-bucket/collector_test.go
Normal file
@@ -0,0 +1,210 @@
|
||||
package leakybucket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNewCollector(t *testing.T) {
|
||||
rate := 1.0
|
||||
capacity := int64(2)
|
||||
c := NewCollector(rate, capacity, time.Second, true)
|
||||
|
||||
if c.buckets == nil {
|
||||
t.Fatal("Didn't initialize priority?!")
|
||||
}
|
||||
if c.heap == nil {
|
||||
t.Fatal("Didn't initialize priority?!")
|
||||
}
|
||||
if c.rate != rate || c.Rate() != rate {
|
||||
t.Fatal("Wrong rate?!")
|
||||
}
|
||||
if c.capacity != capacity || c.Capacity() != capacity {
|
||||
t.Fatal("Wrong capacity?!")
|
||||
}
|
||||
|
||||
c.Free()
|
||||
}
|
||||
|
||||
func TestNewCollector_LargerPeriod(t *testing.T) {
|
||||
testNow := now
|
||||
now = time.Now
|
||||
defer func() {
|
||||
now = testNow
|
||||
}()
|
||||
rate := 10.0
|
||||
capacity := int64(20)
|
||||
c := NewCollector(rate, capacity, 5*time.Second, true)
|
||||
|
||||
c.Add("test", 10)
|
||||
c.Add("test", 10)
|
||||
|
||||
if c.Remaining("test") != 0 {
|
||||
t.Errorf("Excess capacity exists of: %d", c.Remaining("test"))
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
if c.Remaining("test") >= 20 {
|
||||
t.Errorf("Excess capacity exists in: %d", c.Remaining("test"))
|
||||
}
|
||||
time.Sleep(4 * time.Second)
|
||||
|
||||
if c.Add("test", 10) != 10 {
|
||||
t.Errorf("Internal counter not refreshed: %d", c.Count("test"))
|
||||
}
|
||||
c.Free()
|
||||
}
|
||||
|
||||
var collectorSimple = testSet{
|
||||
capacity: int64(5),
|
||||
rate: 1.0,
|
||||
set: []actionSet{
|
||||
{},
|
||||
{1, "add", 1},
|
||||
{1, "time-set", time.Nanosecond},
|
||||
{1, "till", time.Second - time.Nanosecond},
|
||||
{1, "time-set", time.Second - time.Nanosecond},
|
||||
{1, "till", time.Nanosecond},
|
||||
{0, "time-set", time.Second},
|
||||
{0, "till", time.Duration(0)},
|
||||
{1, "add", 1},
|
||||
{1, "time-add", time.Second / 2},
|
||||
{1, "till", time.Second / 2},
|
||||
{2, "add", 1},
|
||||
{2, "time-add", time.Second/2 - time.Nanosecond},
|
||||
{0, "time-add", time.Second * time.Duration(5)},
|
||||
{1, "add", 1},
|
||||
{2, "add", 1},
|
||||
{3, "add", 1},
|
||||
{4, "add", 1},
|
||||
{5, "add", 1},
|
||||
{5, "add", 1},
|
||||
{5, "till", time.Second * 5},
|
||||
},
|
||||
}
|
||||
|
||||
var collectorVaried = testSet{
|
||||
capacity: 1000,
|
||||
rate: 60.0,
|
||||
set: []actionSet{
|
||||
{},
|
||||
{100, "add", 100},
|
||||
{100, "time-set", time.Nanosecond},
|
||||
{1000, "add", 1000},
|
||||
{1000, "add", 1},
|
||||
{940, "time-set", time.Second},
|
||||
},
|
||||
}
|
||||
|
||||
func runKey(t *testing.T, c *Collector, key string, test *testSet) {
|
||||
setElapsed(0)
|
||||
capacity := c.Capacity()
|
||||
|
||||
for i, v := range test.set {
|
||||
switch v.action {
|
||||
case "add":
|
||||
count := c.Count(key)
|
||||
remaining := test.capacity - count
|
||||
amount := int64(v.value.(int))
|
||||
n := c.Add(key, amount)
|
||||
if n < amount {
|
||||
// The bucket should be full now.
|
||||
if n < remaining {
|
||||
t.Fatalf("Test %d: Bucket should have been filled by this Add()?!", i)
|
||||
}
|
||||
}
|
||||
case "time-set":
|
||||
setElapsed(v.value.(time.Duration))
|
||||
case "time-add":
|
||||
addToElapsed(v.value.(time.Duration))
|
||||
case "till":
|
||||
dt := c.TillEmpty(key)
|
||||
if dt != v.value.(time.Duration) {
|
||||
t.Fatalf("%s -> Test %d: Bad TillEmpty(). Expected %v, got %v", key, i, v.value, dt)
|
||||
}
|
||||
}
|
||||
count := c.Count(key)
|
||||
if count != v.count {
|
||||
t.Fatalf("%s -> Test %d: Bad count. Expected %d, got %d", key, i, v.count, count)
|
||||
}
|
||||
if count > capacity {
|
||||
t.Fatalf("%s -> Test %d: Went over capacity?!", key, i)
|
||||
}
|
||||
if c.Remaining(key) != test.capacity-v.count {
|
||||
t.Fatalf("Test %d: Expected remaining value %d, got %d",
|
||||
i, test.capacity-v.count, c.Remaining(key))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
setElapsed(0)
|
||||
|
||||
tests := []testSet{
|
||||
collectorSimple,
|
||||
collectorSimple,
|
||||
collectorVaried,
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
fmt.Println("Running testSet:", i)
|
||||
|
||||
key := "127.0.0.1"
|
||||
|
||||
c := NewCollector(test.rate, test.capacity, time.Second, false)
|
||||
|
||||
// Run and test Remove()
|
||||
runKey(t, c, key, &test)
|
||||
c.Remove(key)
|
||||
if c.Count(key) > 0 {
|
||||
t.Fatal("Key still has a count after removal?!")
|
||||
}
|
||||
|
||||
// Run again and test Prune()
|
||||
runKey(t, c, "127.0.0.1", &test)
|
||||
c.Prune()
|
||||
setElapsed(time.Hour)
|
||||
c.Prune()
|
||||
|
||||
// Run again and test Reset().
|
||||
runKey(t, c, "127.0.0.1", &test)
|
||||
c.Reset()
|
||||
if c.Count(key) != 0 {
|
||||
t.Fatal("Key still has a count after removal?!")
|
||||
}
|
||||
if c.TillEmpty(key) != 0 {
|
||||
t.Fatal("Key still has time till empty?!")
|
||||
}
|
||||
|
||||
// Try to remove a non-exist bucket.
|
||||
c.Remove("fake")
|
||||
if c.Count("fake") != 0 {
|
||||
t.Fatal("Key still has a count after removal?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeriodicPrune(t *testing.T) {
|
||||
setElapsed(0)
|
||||
key := "localhost"
|
||||
c := NewCollector(1e7, 8, time.Second, false)
|
||||
c.PeriodicPrune()
|
||||
n := c.Add(key, 100)
|
||||
if n != 8 {
|
||||
t.Fatal("Didn't fill bucket?!")
|
||||
}
|
||||
|
||||
fmt.Printf("TillEmpty(): %v\n", c.TillEmpty(key))
|
||||
|
||||
// Wait for the periodic prune.
|
||||
wait := time.Millisecond
|
||||
time.Sleep(wait)
|
||||
setElapsed(wait)
|
||||
|
||||
count := c.Count(key)
|
||||
if count != 0 {
|
||||
t.Fatalf("Key's bucket is not empty: %d?!", count)
|
||||
}
|
||||
|
||||
c.Free()
|
||||
}
|
||||
47
container/leaky-bucket/heap.go
Normal file
47
container/leaky-bucket/heap.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package leakybucket
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Based on the example implementation of priority queue found in the
|
||||
// container/heap package docs: https://golang.org/pkg/container/heap/
|
||||
type priorityQueue []*LeakyBucket
|
||||
|
||||
func (pq priorityQueue) Len() int {
|
||||
return len(pq)
|
||||
}
|
||||
|
||||
func (pq priorityQueue) Peak() *LeakyBucket {
|
||||
if len(pq) <= 0 {
|
||||
return nil
|
||||
}
|
||||
return pq[0]
|
||||
}
|
||||
|
||||
func (pq priorityQueue) Less(i, j int) bool {
|
||||
return pq[i].p.Before(pq[j].p)
|
||||
}
|
||||
|
||||
func (pq priorityQueue) Swap(i, j int) {
|
||||
pq[i], pq[j] = pq[j], pq[i]
|
||||
pq[i].index = i
|
||||
pq[j].index = j
|
||||
}
|
||||
|
||||
func (pq *priorityQueue) Push(x interface{}) {
|
||||
n := len(*pq)
|
||||
b, ok := x.(*LeakyBucket)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("%T", x))
|
||||
}
|
||||
b.index = n
|
||||
*pq = append(*pq, b)
|
||||
}
|
||||
|
||||
func (pq *priorityQueue) Pop() interface{} {
|
||||
old := *pq
|
||||
n := len(old)
|
||||
b := old[n-1]
|
||||
b.index = -1 // for safety
|
||||
*pq = old[0 : n-1]
|
||||
return b
|
||||
}
|
||||
107
container/leaky-bucket/heap_test.go
Normal file
107
container/leaky-bucket/heap_test.go
Normal file
@@ -0,0 +1,107 @@
|
||||
package leakybucket
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLen(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
if q.Len() != 0 {
|
||||
t.Fatal("Queue should be empty?!")
|
||||
}
|
||||
|
||||
for i := 1; i <= 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
q.Push(b)
|
||||
|
||||
l := q.Len()
|
||||
if l != i {
|
||||
t.Fatalf("Expected length %d, got %d", i, l)
|
||||
}
|
||||
}
|
||||
for i := 4; i >= 0; i-- {
|
||||
q.Pop()
|
||||
|
||||
l := q.Len()
|
||||
if l != i {
|
||||
t.Fatalf("Expected length %d, got %d", i, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeak(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
q.Push(b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLess(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
b.p = now().Add(time.Duration(i))
|
||||
q.Push(b)
|
||||
}
|
||||
|
||||
for i, j := 0, 4; i < 5; i, j = i+1, j-1 {
|
||||
if i < j && !q.Less(i, j) {
|
||||
t.Fatal("Less is more?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwap(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
q.Push(b)
|
||||
}
|
||||
|
||||
i := 2
|
||||
j := 4
|
||||
|
||||
bi := q[i]
|
||||
bj := q[j]
|
||||
|
||||
q.Swap(i, j)
|
||||
|
||||
if bi != q[j] || bj != q[i] {
|
||||
t.Fatal("Element weren't swapped?!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPush(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
q.Push(b)
|
||||
|
||||
if b != q[len(q)-1] {
|
||||
t.Fatal("Push should append to queue.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPop(t *testing.T) {
|
||||
q := make(priorityQueue, 0, 4096)
|
||||
|
||||
for i := 1; i <= 5; i++ {
|
||||
b := NewLeakyBucket(1.0, 5, time.Second)
|
||||
q.Push(b)
|
||||
}
|
||||
|
||||
for i := 1; i <= 5; i++ {
|
||||
b := q[len(q)-1]
|
||||
if b != q.Pop() {
|
||||
t.Fatal("Pop should remove from end of queue.")
|
||||
}
|
||||
}
|
||||
}
|
||||
155
container/leaky-bucket/leakybucket.go
Normal file
155
container/leaky-bucket/leakybucket.go
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
Package leakybucket implements a scalable leaky bucket algorithm.
|
||||
|
||||
There are at least two different definitions of the leaky bucket algorithm.
|
||||
This package implements the leaky bucket as a meter. For more details see:
|
||||
|
||||
https://en.wikipedia.org/wiki/Leaky_bucket#As_a_meter
|
||||
|
||||
This means it is the exact mirror of a token bucket.
|
||||
|
||||
// New LeakyBucket that leaks at the rate of 0.5/sec and a total capacity of 10.
|
||||
b := NewLeakyBucket(0.5, 10)
|
||||
|
||||
b.Add(5)
|
||||
b.Add(5)
|
||||
// Bucket is now full!
|
||||
|
||||
n := b.Add(1)
|
||||
// n == 0
|
||||
|
||||
|
||||
A Collector is a convenient way to keep track of multiple LeakyBucket's.
|
||||
Buckets are associated with string keys for fast lookup. It can dynamically
|
||||
add new buckets and automatically remove them as they become empty, freeing
|
||||
up resources.
|
||||
|
||||
// New Collector that leaks at 1 MiB/sec, a total capacity of 10 MiB and
|
||||
// automatic removal of bucket's when they become empty.
|
||||
const megabyte = 1<<20
|
||||
c := NewCollector(megabyte, megabyte*10, true)
|
||||
|
||||
// Attempt to add 100 MiB to a bucket associated with an IP.
|
||||
n := c.Add("192.168.0.42", megabyte*100)
|
||||
|
||||
// 100 MiB is over the capacity, so only 10 MiB is actually added.
|
||||
// n equals 10 MiB.
|
||||
*/
|
||||
package leakybucket
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Makes it easy to test time based things.
|
||||
var now = time.Now
|
||||
|
||||
// LeakyBucket represents a bucket that leaks at a constant rate.
|
||||
type LeakyBucket struct {
|
||||
// The identifying key, used for map lookups.
|
||||
key string
|
||||
|
||||
// How large the bucket is.
|
||||
capacity int64
|
||||
|
||||
// Amount the bucket leaks per time duration.
|
||||
rate float64
|
||||
|
||||
// The priority of the bucket in a min-heap priority queue, where p is the
|
||||
// exact time the bucket will have leaked enough to be empty. Buckets that
|
||||
// are empty or will be the soonest are at the top of the heap. This allows
|
||||
// for quick pruning of empty buckets that scales very well. p is adjusted
|
||||
// any time an amount is added to the Queue().
|
||||
p time.Time
|
||||
|
||||
// The time duration through which the leaky bucket is
|
||||
// assessed.
|
||||
period time.Duration
|
||||
|
||||
// The index is maintained by the heap.Interface methods.
|
||||
index int
|
||||
}
|
||||
|
||||
// NewLeakyBucket creates a new LeakyBucket with the give rate and capacity.
|
||||
func NewLeakyBucket(rate float64, capacity int64, period time.Duration) *LeakyBucket {
|
||||
return &LeakyBucket{
|
||||
rate: rate,
|
||||
capacity: capacity,
|
||||
period: period,
|
||||
p: now(),
|
||||
}
|
||||
}
|
||||
|
||||
// Count returns the bucket's current count.
|
||||
func (b *LeakyBucket) Count() int64 {
|
||||
if !now().Before(b.p) {
|
||||
return 0
|
||||
}
|
||||
|
||||
nsRemaining := float64(b.p.Sub(now()))
|
||||
nsPerDrip := float64(b.period) / b.rate
|
||||
count := int64(math.Ceil(nsRemaining / nsPerDrip))
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
// Rate returns the amount the bucket leaks per second.
|
||||
func (b *LeakyBucket) Rate() float64 {
|
||||
return b.rate
|
||||
}
|
||||
|
||||
// Capacity returns the bucket's capacity.
|
||||
func (b *LeakyBucket) Capacity() int64 {
|
||||
return b.capacity
|
||||
}
|
||||
|
||||
// Remaining returns the bucket's remaining capacity.
|
||||
func (b *LeakyBucket) Remaining() int64 {
|
||||
return b.capacity - b.Count()
|
||||
}
|
||||
|
||||
// ChangeCapacity changes the bucket's capacity.
|
||||
//
|
||||
// If the bucket's current count is greater than the new capacity, the count
|
||||
// will be decreased to match the new capacity.
|
||||
func (b *LeakyBucket) ChangeCapacity(capacity int64) {
|
||||
diff := float64(capacity - b.capacity)
|
||||
|
||||
if diff < 0 && b.Count() > capacity {
|
||||
// We are shrinking the capacity and the new bucket size can't hold all
|
||||
// the current contents. Dump the extra and adjust the time till empty.
|
||||
nsPerDrip := float64(b.period) / b.rate
|
||||
b.p = now().Add(time.Duration(nsPerDrip * float64(capacity)))
|
||||
}
|
||||
b.capacity = capacity
|
||||
}
|
||||
|
||||
// TillEmpty returns how much time must pass until the bucket is empty.
|
||||
func (b *LeakyBucket) TillEmpty() time.Duration {
|
||||
return b.p.Sub(now())
|
||||
}
|
||||
|
||||
// Add 'amount' to the bucket's count, up to it's capacity. Returns how much
|
||||
// was added to the bucket. If the return is less than 'amount', then the
|
||||
// bucket's capacity was reached.
|
||||
func (b *LeakyBucket) Add(amount int64) int64 {
|
||||
count := b.Count()
|
||||
if count >= b.capacity {
|
||||
// The bucket is full.
|
||||
return 0
|
||||
}
|
||||
|
||||
if !now().Before(b.p) {
|
||||
// The bucket needs to be reset.
|
||||
b.p = now()
|
||||
}
|
||||
remaining := b.capacity - count
|
||||
if amount > remaining {
|
||||
amount = remaining
|
||||
}
|
||||
t := time.Duration(float64(b.period) * (float64(amount) / b.rate))
|
||||
b.p = b.p.Add(t)
|
||||
|
||||
return amount
|
||||
}
|
||||
181
container/leaky-bucket/leakybucket_test.go
Normal file
181
container/leaky-bucket/leakybucket_test.go
Normal file
@@ -0,0 +1,181 @@
|
||||
package leakybucket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Arbitrary start time.
|
||||
var start = time.Date(1990, 1, 2, 0, 0, 0, 0, time.UTC).Round(0)
|
||||
var elapsed int64
|
||||
|
||||
// We provide atomic access to elapsed to avoid data races between multiple
|
||||
// concurrent goroutines during the tests.
|
||||
func getElapsed() time.Duration {
|
||||
return time.Duration(atomic.LoadInt64(&elapsed))
|
||||
}
|
||||
func setElapsed(v time.Duration) {
|
||||
atomic.StoreInt64(&elapsed, int64(v))
|
||||
}
|
||||
func addToElapsed(v time.Duration) {
|
||||
atomic.AddInt64(&elapsed, int64(v))
|
||||
}
|
||||
|
||||
func reset(t *testing.T, c *Collector) {
|
||||
c.Reset()
|
||||
setElapsed(0)
|
||||
}
|
||||
|
||||
func TestNewLeakyBucket(t *testing.T) {
|
||||
rate := 1.0
|
||||
capacity := int64(5)
|
||||
b := NewLeakyBucket(rate, capacity, time.Second)
|
||||
|
||||
if b.p != now() {
|
||||
t.Fatal("Didn't initialize priority?!")
|
||||
}
|
||||
if b.rate != rate || b.Rate() != rate {
|
||||
t.Fatal("Wrong rate?!")
|
||||
}
|
||||
if b.capacity != capacity || b.Capacity() != capacity {
|
||||
t.Fatal("Wrong capacity?!")
|
||||
}
|
||||
}
|
||||
|
||||
type actionSet struct {
|
||||
count int64
|
||||
action string
|
||||
value interface{}
|
||||
}
|
||||
|
||||
type testSet struct {
|
||||
capacity int64
|
||||
rate float64
|
||||
set []actionSet
|
||||
}
|
||||
|
||||
var oneAtaTime = testSet{
|
||||
capacity: 5,
|
||||
rate: 1.0,
|
||||
set: []actionSet{
|
||||
{},
|
||||
{1, "add", 1},
|
||||
{1, "time-set", time.Nanosecond},
|
||||
{1, "till", time.Second - time.Nanosecond},
|
||||
{1, "time-set", time.Second - time.Nanosecond},
|
||||
{1, "till", time.Nanosecond},
|
||||
{0, "time-set", time.Second},
|
||||
{0, "till", time.Duration(0)},
|
||||
|
||||
// Add a couple.
|
||||
{1, "add", 1},
|
||||
{1, "time-add", time.Second / 2},
|
||||
{1, "till", time.Second / 2},
|
||||
{2, "add", 1},
|
||||
{2, "time-add", time.Second/2 - time.Nanosecond},
|
||||
|
||||
// Monkey with the capacity and make sure Count()/TillEmpty() are
|
||||
// adjusted as needed.
|
||||
{2, "cap", 5 + 1},
|
||||
{2, "till", time.Second + time.Nanosecond},
|
||||
{2, "cap", 5 - 1},
|
||||
{2, "till", time.Second + time.Nanosecond},
|
||||
{1, "cap", 1},
|
||||
{1, "till", time.Second},
|
||||
{1, "cap", 4},
|
||||
{1, "till", time.Second},
|
||||
|
||||
// Test the full cases.
|
||||
{0, "time-add", time.Second * time.Duration(5)},
|
||||
{1, "add", 1},
|
||||
{2, "add", 1},
|
||||
{3, "add", 1},
|
||||
{4, "add", 1},
|
||||
{4, "add", 1},
|
||||
{4, "till", time.Second * 4},
|
||||
},
|
||||
}
|
||||
|
||||
var varied = testSet{
|
||||
capacity: 1000,
|
||||
rate: 60.0,
|
||||
set: []actionSet{
|
||||
{},
|
||||
{100, "add", 100},
|
||||
{100, "time-set", time.Nanosecond},
|
||||
{1000, "add", 1000},
|
||||
{1000, "add", 1},
|
||||
{940, "time-set", time.Second},
|
||||
},
|
||||
}
|
||||
|
||||
func runTest(t *testing.T, test *testSet) {
|
||||
setElapsed(0)
|
||||
b := NewLeakyBucket(test.rate, test.capacity, time.Second)
|
||||
|
||||
for i, v := range test.set {
|
||||
switch v.action {
|
||||
case "add":
|
||||
count := b.Count()
|
||||
remaining := test.capacity - count
|
||||
amount := int64(v.value.(int))
|
||||
n := b.Add(amount)
|
||||
if n < amount {
|
||||
// The bucket should be full now.
|
||||
if n < remaining {
|
||||
t.Fatalf("Test %d: Bucket should have been filled by this Add()?!", i)
|
||||
}
|
||||
}
|
||||
case "time-set":
|
||||
setElapsed(v.value.(time.Duration))
|
||||
case "cap":
|
||||
b.ChangeCapacity(int64(v.value.(int)))
|
||||
test.capacity = b.Capacity()
|
||||
case "time-add":
|
||||
addToElapsed(v.value.(time.Duration))
|
||||
case "till":
|
||||
dt := b.TillEmpty()
|
||||
if dt != v.value.(time.Duration) {
|
||||
t.Fatalf("Test %d: Bad TillEmpty(). Expected %v, got %v", i, v.value, dt)
|
||||
}
|
||||
case "debug":
|
||||
fmt.Println("elapsed:", getElapsed())
|
||||
fmt.Println("tillEmpty:", b.TillEmpty())
|
||||
fmt.Println("count:", b.Count())
|
||||
}
|
||||
c := b.Count()
|
||||
if c != v.count {
|
||||
t.Fatalf("Test %d: Bad count. Expected %d, got %d", i, v.count, c)
|
||||
}
|
||||
if c > test.capacity {
|
||||
t.Fatalf("Test %d: Went over capacity?!", i)
|
||||
}
|
||||
if b.Remaining() != test.capacity-v.count {
|
||||
t.Fatalf("Test %d: Expected remaining value %d, got %d",
|
||||
i, test.capacity-v.count, b.Remaining())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeakyBucket(t *testing.T) {
|
||||
tests := []testSet{
|
||||
oneAtaTime,
|
||||
varied,
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
fmt.Println("Running testSet:", i)
|
||||
runTest(t, &test)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// Override what now() function the leakybucket library uses.
|
||||
// This greatly increases testability!
|
||||
now = func() time.Time { return start.Add(getElapsed()) }
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
7
deps.bzl
7
deps.bzl
@@ -1883,13 +1883,6 @@ def prysm_deps():
|
||||
version = "v0.0.2",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_kevinms_leakybucket_go",
|
||||
importpath = "github.com/kevinms/leakybucket-go",
|
||||
sum = "h1:qNtd6alRqd3qOdPrKXMZImV192ngQ0WSh1briEO33Tk=",
|
||||
version = "v0.0.0-20200115003610-082473db97ca",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_kisielk_errcheck",
|
||||
importpath = "github.com/kisielk/errcheck",
|
||||
|
||||
1
go.mod
1
go.mod
@@ -39,7 +39,6 @@ require (
|
||||
github.com/joonix/log v0.0.0-20200409080653-9c1d2ceb5f1d
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
|
||||
github.com/kevinms/leakybucket-go v0.0.0-20200115003610-082473db97ca
|
||||
github.com/kr/pretty v0.3.0
|
||||
github.com/libp2p/go-libp2p v0.22.0
|
||||
github.com/libp2p/go-libp2p-pubsub v0.8.0
|
||||
|
||||
2
go.sum
2
go.sum
@@ -609,8 +609,6 @@ github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 h1:qGQQKEcAR99REcM
|
||||
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
|
||||
github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4=
|
||||
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/kevinms/leakybucket-go v0.0.0-20200115003610-082473db97ca h1:qNtd6alRqd3qOdPrKXMZImV192ngQ0WSh1briEO33Tk=
|
||||
github.com/kevinms/leakybucket-go v0.0.0-20200115003610-082473db97ca/go.mod h1:ph+C5vpnCcQvKBwJwKLTK3JLNGnBXYlG7m7JjoC/zYA=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
|
||||
@@ -31,6 +31,9 @@ proto_library(
|
||||
ssz_gen_marshal(
|
||||
name = "ssz_generated_files",
|
||||
go_proto = ":go_proto",
|
||||
includes = [
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
],
|
||||
objs = [
|
||||
"ExecutionPayload",
|
||||
"ExecutionPayloadCapella",
|
||||
|
||||
58
proto/engine/v1/execution_engine.pb.go
generated
58
proto/engine/v1/execution_engine.pb.go
generated
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.15.8
|
||||
// source: proto/engine/v1/execution_engine.proto
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
_ "github.com/prysmaticlabs/prysm/v3/proto/eth/ext"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
@@ -957,9 +958,10 @@ type Withdrawal struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
WithdrawalIndex uint64 `protobuf:"varint,1,opt,name=withdrawal_index,json=withdrawalIndex,proto3" json:"withdrawal_index,omitempty"`
|
||||
ExecutionAddress []byte `protobuf:"bytes,2,opt,name=execution_address,json=executionAddress,proto3" json:"execution_address,omitempty" ssz-size:"20"`
|
||||
Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"`
|
||||
WithdrawalIndex uint64 `protobuf:"varint,1,opt,name=withdrawal_index,json=withdrawalIndex,proto3" json:"withdrawal_index,omitempty"`
|
||||
ValidatorIndex github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex `protobuf:"varint,2,opt,name=validator_index,json=validatorIndex,proto3" json:"validator_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"`
|
||||
ExecutionAddress []byte `protobuf:"bytes,3,opt,name=execution_address,json=executionAddress,proto3" json:"execution_address,omitempty" ssz-size:"20"`
|
||||
Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Withdrawal) Reset() {
|
||||
@@ -1001,6 +1003,13 @@ func (x *Withdrawal) GetWithdrawalIndex() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Withdrawal) GetValidatorIndex() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex {
|
||||
if x != nil {
|
||||
return x.ValidatorIndex
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(0)
|
||||
}
|
||||
|
||||
func (x *Withdrawal) GetExecutionAddress() []byte {
|
||||
if x != nil {
|
||||
return x.ExecutionAddress
|
||||
@@ -1227,26 +1236,33 @@ var file_proto_engine_v1_execution_engine_proto_rawDesc = []byte{
|
||||
0x73, 0x68, 0x12, 0x38, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x12, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69,
|
||||
0x7a, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x22, 0x84, 0x01, 0x0a,
|
||||
0x7a, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x22, 0xfe, 0x01, 0x0a,
|
||||
0x0a, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x12, 0x29, 0x0a, 0x10, 0x77,
|
||||
0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61,
|
||||
0x6c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x33, 0x0a, 0x11, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61,
|
||||
0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x42, 0x96, 0x01, 0x0a, 0x16, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x14,
|
||||
0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73,
|
||||
0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
|
||||
0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65,
|
||||
0x76, 0x31, 0xaa, 0x02, 0x12, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x6e,
|
||||
0x67, 0x69, 0x6e, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x5c, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x78, 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42,
|
||||
0x4f, 0x82, 0xb5, 0x18, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72,
|
||||
0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73,
|
||||
0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65,
|
||||
0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78,
|
||||
0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78,
|
||||
0x12, 0x33, 0x0a, 0x11, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18,
|
||||
0x02, 0x32, 0x30, 0x52, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64,
|
||||
0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x96, 0x01,
|
||||
0x0a, 0x16, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x14, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
|
||||
0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65,
|
||||
0x2f, 0x76, 0x31, 0x3b, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x76, 0x31, 0xaa, 0x02, 0x12, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x56,
|
||||
0x31, 0xca, 0x02, 0x12, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x6e, 0x67,
|
||||
0x69, 0x6e, 0x65, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -132,10 +132,13 @@ message Withdrawal {
|
||||
// Withdrawal index for accounting purposes
|
||||
uint64 withdrawal_index = 1;
|
||||
|
||||
// Validator index for the withdrawal
|
||||
uint64 validator_index = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"];
|
||||
|
||||
// The execution address receiving the funds
|
||||
bytes execution_address = 2 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
bytes execution_address = 3 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
|
||||
// The withdrawn amount in Gwei
|
||||
uint64 amount = 3;
|
||||
uint64 amount = 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 8ff411ee7233e56f3e3ec85ef6fc9db47b6afae7e56ba24797e67208cdc309c9
|
||||
// Hash: 31e013ad8172683b80becdea6758152590fde462f910057764c6505bc7ea8a00
|
||||
package enginev1
|
||||
|
||||
import (
|
||||
ssz "github.com/prysmaticlabs/fastssz"
|
||||
github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
)
|
||||
|
||||
// MarshalSSZ ssz marshals the ExecutionPayload object
|
||||
@@ -486,7 +487,7 @@ func (e *ExecutionPayloadCapella) MarshalSSZTo(buf []byte) (dst []byte, err erro
|
||||
|
||||
// Offset (14) 'Withdrawals'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(e.Withdrawals) * 36
|
||||
offset += len(e.Withdrawals) * 44
|
||||
|
||||
// Field (10) 'ExtraData'
|
||||
if size := len(e.ExtraData); size > 32 {
|
||||
@@ -657,7 +658,7 @@ func (e *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error {
|
||||
// Field (14) 'Withdrawals'
|
||||
{
|
||||
buf = tail[o14:]
|
||||
num, err := ssz.DivideInt2(len(buf), 36, 16)
|
||||
num, err := ssz.DivideInt2(len(buf), 44, 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -666,7 +667,7 @@ func (e *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error {
|
||||
if e.Withdrawals[ii] == nil {
|
||||
e.Withdrawals[ii] = new(Withdrawal)
|
||||
}
|
||||
if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*36 : (ii+1)*36]); err != nil {
|
||||
if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -688,7 +689,7 @@ func (e *ExecutionPayloadCapella) SizeSSZ() (size int) {
|
||||
}
|
||||
|
||||
// Field (14) 'Withdrawals'
|
||||
size += len(e.Withdrawals) * 36
|
||||
size += len(e.Withdrawals) * 44
|
||||
|
||||
return
|
||||
}
|
||||
@@ -1511,14 +1512,17 @@ func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
// Field (0) 'WithdrawalIndex'
|
||||
dst = ssz.MarshalUint64(dst, w.WithdrawalIndex)
|
||||
|
||||
// Field (1) 'ExecutionAddress'
|
||||
// Field (1) 'ValidatorIndex'
|
||||
dst = ssz.MarshalUint64(dst, uint64(w.ValidatorIndex))
|
||||
|
||||
// Field (2) 'ExecutionAddress'
|
||||
if size := len(w.ExecutionAddress); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20)
|
||||
return
|
||||
}
|
||||
dst = append(dst, w.ExecutionAddress...)
|
||||
|
||||
// Field (2) 'Amount'
|
||||
// Field (3) 'Amount'
|
||||
dst = ssz.MarshalUint64(dst, w.Amount)
|
||||
|
||||
return
|
||||
@@ -1528,28 +1532,31 @@ func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
func (w *Withdrawal) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 36 {
|
||||
if size != 44 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'WithdrawalIndex'
|
||||
w.WithdrawalIndex = ssz.UnmarshallUint64(buf[0:8])
|
||||
|
||||
// Field (1) 'ExecutionAddress'
|
||||
if cap(w.ExecutionAddress) == 0 {
|
||||
w.ExecutionAddress = make([]byte, 0, len(buf[8:28]))
|
||||
}
|
||||
w.ExecutionAddress = append(w.ExecutionAddress, buf[8:28]...)
|
||||
// Field (1) 'ValidatorIndex'
|
||||
w.ValidatorIndex = github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
||||
|
||||
// Field (2) 'Amount'
|
||||
w.Amount = ssz.UnmarshallUint64(buf[28:36])
|
||||
// Field (2) 'ExecutionAddress'
|
||||
if cap(w.ExecutionAddress) == 0 {
|
||||
w.ExecutionAddress = make([]byte, 0, len(buf[16:36]))
|
||||
}
|
||||
w.ExecutionAddress = append(w.ExecutionAddress, buf[16:36]...)
|
||||
|
||||
// Field (3) 'Amount'
|
||||
w.Amount = ssz.UnmarshallUint64(buf[36:44])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the Withdrawal object
|
||||
func (w *Withdrawal) SizeSSZ() (size int) {
|
||||
size = 36
|
||||
size = 44
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1565,14 +1572,17 @@ func (w *Withdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
// Field (0) 'WithdrawalIndex'
|
||||
hh.PutUint64(w.WithdrawalIndex)
|
||||
|
||||
// Field (1) 'ExecutionAddress'
|
||||
// Field (1) 'ValidatorIndex'
|
||||
hh.PutUint64(uint64(w.ValidatorIndex))
|
||||
|
||||
// Field (2) 'ExecutionAddress'
|
||||
if size := len(w.ExecutionAddress); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20)
|
||||
return
|
||||
}
|
||||
hh.PutBytes(w.ExecutionAddress)
|
||||
|
||||
// Field (2) 'Amount'
|
||||
// Field (3) 'Amount'
|
||||
hh.PutUint64(w.Amount)
|
||||
|
||||
if ssz.EnableVectorizedHTR {
|
||||
|
||||
485
proto/eth/service/beacon_chain_service.pb.go
generated
485
proto/eth/service/beacon_chain_service.pb.go
generated
@@ -8,6 +8,8 @@ package service
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
_ "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1"
|
||||
@@ -18,7 +20,6 @@ import (
|
||||
status "google.golang.org/grpc/status"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -51,7 +52,7 @@ var file_proto_eth_service_beacon_chain_service_proto_rawDesc = []byte{
|
||||
0x76, 0x32, 0x2f, 0x73, 0x73, 0x7a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x5f,
|
||||
0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
|
||||
0x84, 0x27, 0x0a, 0x0b, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12,
|
||||
0xad, 0x29, 0x0a, 0x0b, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12,
|
||||
0x6f, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x16, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
@@ -235,145 +236,164 @@ var file_proto_eth_service_beacon_chain_service_proto_rawDesc = []byte{
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64,
|
||||
0x7d, 0x12, 0x86, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x53,
|
||||
0x5a, 0x56, 0x32, 0x12, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x56, 0x32, 0x1a, 0x1d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x53, 0x5a, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69,
|
||||
0x6e, 0x65, 0x72, 0x22, 0x35, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x69, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x62, 0x65,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x73, 0x73, 0x7a, 0x12, 0xa2, 0x01, 0x0a, 0x15, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||
0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x38, 0x12, 0x36, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e,
|
||||
0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69,
|
||||
0x64, 0x7d, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12,
|
||||
0x9e, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x41, 0x74, 0x74, 0x65,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70,
|
||||
0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x12, 0x8e, 0x01, 0x0a, 0x12, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74,
|
||||
0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x34, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x2e, 0x22, 0x29, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f,
|
||||
0x6c, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x01,
|
||||
0x2a, 0x12, 0x9c, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12,
|
||||
0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74,
|
||||
0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12,
|
||||
0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76,
|
||||
0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73,
|
||||
0x12, 0x8f, 0x01, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x65, 0x74,
|
||||
0x7d, 0x12, 0x92, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64,
|
||||
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x39, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x33, 0x12, 0x31, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x62, 0x6c, 0x69,
|
||||
0x6e, 0x64, 0x65, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x91, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x42, 0x6c,
|
||||
0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x53, 0x5a, 0x12, 0x1d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53,
|
||||
0x53, 0x5a, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x3d, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x37, 0x12, 0x35, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x62, 0x6c, 0x69,
|
||||
0x6e, 0x64, 0x65, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x73, 0x73, 0x7a, 0x12, 0x86, 0x01, 0x0a, 0x0d, 0x47,
|
||||
0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x53, 0x5a, 0x56, 0x32, 0x12, 0x1f, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x56, 0x32, 0x1a, 0x1d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x53, 0x53, 0x5a, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x35, 0x82, 0xd3,
|
||||
0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f,
|
||||
0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x62, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x7d, 0x2f,
|
||||
0x73, 0x73, 0x7a, 0x12, 0xa2, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x38,
|
||||
0x12, 0x36, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73,
|
||||
0x2f, 0x7b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x61, 0x74, 0x74, 0x65,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x9e, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73,
|
||||
0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x12, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x34, 0x22, 0x2f,
|
||||
0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29,
|
||||
0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74, 0x74,
|
||||
0x65, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x3a,
|
||||
0x01, 0x2a, 0x12, 0x9b, 0x01, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x50,
|
||||
0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73,
|
||||
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f,
|
||||
0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6f, 0x6c, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12,
|
||||
0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76,
|
||||
0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x70, 0x72,
|
||||
0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73,
|
||||
0x12, 0x8f, 0x01, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f,
|
||||
0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72,
|
||||
0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x34, 0x22, 0x2f,
|
||||
0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x3a,
|
||||
0x01, 0x2a, 0x12, 0x93, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x56,
|
||||
0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x73, 0x12, 0x16, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72,
|
||||
0x79, 0x45, 0x78, 0x69, 0x74, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x34, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x12, 0x2c, 0x2f, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x8e, 0x01, 0x0a, 0x12, 0x53, 0x75,
|
||||
0x62, 0x6d, 0x69, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x12, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45,
|
||||
0x6d, 0x70, 0x74, 0x79, 0x22, 0x34, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x22, 0x29, 0x2f, 0x69,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62,
|
||||
0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x9c, 0x01, 0x0a, 0x19, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x1a, 0x2e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68,
|
||||
0x69, 0x6e, 0x67, 0x73, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12, 0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f,
|
||||
0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x5f,
|
||||
0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x8f, 0x01, 0x0a, 0x16, 0x53, 0x75,
|
||||
0x62, 0x6d, 0x69, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,
|
||||
0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x34, 0x22, 0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e,
|
||||
0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x73,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x9b, 0x01, 0x0a, 0x19,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
|
||||
0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74,
|
||||
0x79, 0x1a, 0x2d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12, 0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f,
|
||||
0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f,
|
||||
0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x8f, 0x01, 0x0a, 0x16, 0x53, 0x75,
|
||||
0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,
|
||||
0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x34, 0x22, 0x2f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e,
|
||||
0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x73,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x93, 0x01, 0x0a, 0x16,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72,
|
||||
0x79, 0x45, 0x78, 0x69, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2b,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x73, 0x50,
|
||||
0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x2e, 0x12, 0x2c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f,
|
||||
0x6c, 0x2f, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x69, 0x74,
|
||||
0x73, 0x12, 0x8c, 0x01, 0x0a, 0x13, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75,
|
||||
0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x12, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e,
|
||||
0x65, 0x64, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x1a,
|
||||
0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22,
|
||||
0x2c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76,
|
||||
0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x6f,
|
||||
0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x73, 0x3a, 0x01, 0x2a,
|
||||
0x12, 0xa8, 0x01, 0x0a, 0x21, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x53,
|
||||
0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x53, 0x69, 0x67, 0x6e,
|
||||
0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x32, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50,
|
||||
0x6f, 0x6f, 0x6c, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65,
|
||||
0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22, 0x2c, 0x2f, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61,
|
||||
0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61,
|
||||
0x72, 0x79, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x73, 0x12, 0x8c, 0x01, 0x0a, 0x13, 0x53, 0x75, 0x62,
|
||||
0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x45, 0x78, 0x69, 0x74,
|
||||
0x12, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x56, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61,
|
||||
0x72, 0x79, 0x45, 0x78, 0x69, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x37,
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22, 0x2c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f,
|
||||
0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x6f, 0x6c, 0x75, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x5f, 0x65,
|
||||
0x78, 0x69, 0x74, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0xa8, 0x01, 0x0a, 0x21, 0x53, 0x75, 0x62, 0x6d,
|
||||
0x69, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
|
||||
0x74, 0x65, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x32, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f,
|
||||
0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65,
|
||||
0x73, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
||||
0x31, 0x22, 0x2c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68,
|
||||
0x2f, 0x76, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f,
|
||||
0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x73, 0x3a,
|
||||
0x01, 0x2a, 0x12, 0x7f, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x63, 0x68,
|
||||
0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x25, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x46, 0x6f, 0x72, 0x6b, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x69,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x64,
|
||||
0x75, 0x6c, 0x65, 0x12, 0x66, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x12, 0x16,
|
||||
0x63, 0x6f, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f,
|
||||
0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x7f, 0x0a, 0x0f, 0x47,
|
||||
0x65, 0x74, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x16,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x12, 0x88, 0x01, 0x0a, 0x12,
|
||||
0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61,
|
||||
0x63, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x28, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70,
|
||||
0x6f, 0x73, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x69,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x42, 0x98, 0x01, 0x0a, 0x18, 0x6f, 0x72, 0x67, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x42, 0x17, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e,
|
||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76,
|
||||
0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0xaa, 0x02, 0x14, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45,
|
||||
0x74, 0x68, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0xca, 0x02, 0x14, 0x45, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x25, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x63, 0x68,
|
||||
0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x66,
|
||||
0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x66, 0x0a, 0x07,
|
||||
0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a,
|
||||
0x1d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24,
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f,
|
||||
0x73, 0x70, 0x65, 0x63, 0x12, 0x88, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6f,
|
||||
0x73, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x1a, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6f, 0x6e,
|
||||
0x74, 0x72, 0x61, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x64,
|
||||
0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x42,
|
||||
0x98, 0x01, 0x0a, 0x18, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x17, 0x42, 0x65,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62,
|
||||
0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0xaa, 0x02, 0x14, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x53, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0xca, 0x02, 0x14, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45,
|
||||
0x74, 0x68, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var file_proto_eth_service_beacon_chain_service_proto_goTypes = []interface{}{
|
||||
@@ -412,14 +432,15 @@ var file_proto_eth_service_beacon_chain_service_proto_goTypes = []interface{}{
|
||||
(*v1.BlockResponse)(nil), // 32: ethereum.eth.v1.BlockResponse
|
||||
(*v1.BlockSSZResponse)(nil), // 33: ethereum.eth.v1.BlockSSZResponse
|
||||
(*v2.BlockResponseV2)(nil), // 34: ethereum.eth.v2.BlockResponseV2
|
||||
(*v1.BlockAttestationsResponse)(nil), // 35: ethereum.eth.v1.BlockAttestationsResponse
|
||||
(*v1.AttestationsPoolResponse)(nil), // 36: ethereum.eth.v1.AttestationsPoolResponse
|
||||
(*v1.AttesterSlashingsPoolResponse)(nil), // 37: ethereum.eth.v1.AttesterSlashingsPoolResponse
|
||||
(*v1.ProposerSlashingPoolResponse)(nil), // 38: ethereum.eth.v1.ProposerSlashingPoolResponse
|
||||
(*v1.VoluntaryExitsPoolResponse)(nil), // 39: ethereum.eth.v1.VoluntaryExitsPoolResponse
|
||||
(*v1.ForkScheduleResponse)(nil), // 40: ethereum.eth.v1.ForkScheduleResponse
|
||||
(*v1.SpecResponse)(nil), // 41: ethereum.eth.v1.SpecResponse
|
||||
(*v1.DepositContractResponse)(nil), // 42: ethereum.eth.v1.DepositContractResponse
|
||||
(*v2.BlindedBlockResponse)(nil), // 35: ethereum.eth.v2.BlindedBlockResponse
|
||||
(*v1.BlockAttestationsResponse)(nil), // 36: ethereum.eth.v1.BlockAttestationsResponse
|
||||
(*v1.AttestationsPoolResponse)(nil), // 37: ethereum.eth.v1.AttestationsPoolResponse
|
||||
(*v1.AttesterSlashingsPoolResponse)(nil), // 38: ethereum.eth.v1.AttesterSlashingsPoolResponse
|
||||
(*v1.ProposerSlashingPoolResponse)(nil), // 39: ethereum.eth.v1.ProposerSlashingPoolResponse
|
||||
(*v1.VoluntaryExitsPoolResponse)(nil), // 40: ethereum.eth.v1.VoluntaryExitsPoolResponse
|
||||
(*v1.ForkScheduleResponse)(nil), // 41: ethereum.eth.v1.ForkScheduleResponse
|
||||
(*v1.SpecResponse)(nil), // 42: ethereum.eth.v1.SpecResponse
|
||||
(*v1.DepositContractResponse)(nil), // 43: ethereum.eth.v1.DepositContractResponse
|
||||
}
|
||||
var file_proto_eth_service_beacon_chain_service_proto_depIdxs = []int32{
|
||||
0, // 0: ethereum.eth.service.BeaconChain.GetGenesis:input_type -> google.protobuf.Empty
|
||||
@@ -442,56 +463,60 @@ var file_proto_eth_service_beacon_chain_service_proto_depIdxs = []int32{
|
||||
8, // 17: ethereum.eth.service.BeaconChain.GetBlock:input_type -> ethereum.eth.v1.BlockRequest
|
||||
8, // 18: ethereum.eth.service.BeaconChain.GetBlockSSZ:input_type -> ethereum.eth.v1.BlockRequest
|
||||
12, // 19: ethereum.eth.service.BeaconChain.GetBlockV2:input_type -> ethereum.eth.v2.BlockRequestV2
|
||||
12, // 20: ethereum.eth.service.BeaconChain.GetBlockSSZV2:input_type -> ethereum.eth.v2.BlockRequestV2
|
||||
8, // 21: ethereum.eth.service.BeaconChain.ListBlockAttestations:input_type -> ethereum.eth.v1.BlockRequest
|
||||
13, // 22: ethereum.eth.service.BeaconChain.ListPoolAttestations:input_type -> ethereum.eth.v1.AttestationsPoolRequest
|
||||
14, // 23: ethereum.eth.service.BeaconChain.SubmitAttestations:input_type -> ethereum.eth.v1.SubmitAttestationsRequest
|
||||
0, // 24: ethereum.eth.service.BeaconChain.ListPoolAttesterSlashings:input_type -> google.protobuf.Empty
|
||||
15, // 25: ethereum.eth.service.BeaconChain.SubmitAttesterSlashing:input_type -> ethereum.eth.v1.AttesterSlashing
|
||||
0, // 26: ethereum.eth.service.BeaconChain.ListPoolProposerSlashings:input_type -> google.protobuf.Empty
|
||||
16, // 27: ethereum.eth.service.BeaconChain.SubmitProposerSlashing:input_type -> ethereum.eth.v1.ProposerSlashing
|
||||
0, // 28: ethereum.eth.service.BeaconChain.ListPoolVoluntaryExits:input_type -> google.protobuf.Empty
|
||||
17, // 29: ethereum.eth.service.BeaconChain.SubmitVoluntaryExit:input_type -> ethereum.eth.v1.SignedVoluntaryExit
|
||||
18, // 30: ethereum.eth.service.BeaconChain.SubmitPoolSyncCommitteeSignatures:input_type -> ethereum.eth.v2.SubmitPoolSyncCommitteeSignatures
|
||||
0, // 31: ethereum.eth.service.BeaconChain.GetForkSchedule:input_type -> google.protobuf.Empty
|
||||
0, // 32: ethereum.eth.service.BeaconChain.GetSpec:input_type -> google.protobuf.Empty
|
||||
0, // 33: ethereum.eth.service.BeaconChain.GetDepositContract:input_type -> google.protobuf.Empty
|
||||
19, // 34: ethereum.eth.service.BeaconChain.GetGenesis:output_type -> ethereum.eth.v1.GenesisResponse
|
||||
20, // 35: ethereum.eth.service.BeaconChain.GetWeakSubjectivity:output_type -> ethereum.eth.v1.WeakSubjectivityResponse
|
||||
21, // 36: ethereum.eth.service.BeaconChain.GetStateRoot:output_type -> ethereum.eth.v1.StateRootResponse
|
||||
22, // 37: ethereum.eth.service.BeaconChain.GetStateFork:output_type -> ethereum.eth.v1.StateForkResponse
|
||||
23, // 38: ethereum.eth.service.BeaconChain.GetFinalityCheckpoints:output_type -> ethereum.eth.v1.StateFinalityCheckpointResponse
|
||||
24, // 39: ethereum.eth.service.BeaconChain.ListValidators:output_type -> ethereum.eth.v1.StateValidatorsResponse
|
||||
25, // 40: ethereum.eth.service.BeaconChain.GetValidator:output_type -> ethereum.eth.v1.StateValidatorResponse
|
||||
26, // 41: ethereum.eth.service.BeaconChain.ListValidatorBalances:output_type -> ethereum.eth.v1.ValidatorBalancesResponse
|
||||
27, // 42: ethereum.eth.service.BeaconChain.ListCommittees:output_type -> ethereum.eth.v1.StateCommitteesResponse
|
||||
28, // 43: ethereum.eth.service.BeaconChain.ListSyncCommittees:output_type -> ethereum.eth.v2.StateSyncCommitteesResponse
|
||||
29, // 44: ethereum.eth.service.BeaconChain.ListBlockHeaders:output_type -> ethereum.eth.v1.BlockHeadersResponse
|
||||
30, // 45: ethereum.eth.service.BeaconChain.GetBlockHeader:output_type -> ethereum.eth.v1.BlockHeaderResponse
|
||||
0, // 46: ethereum.eth.service.BeaconChain.SubmitBlock:output_type -> google.protobuf.Empty
|
||||
0, // 47: ethereum.eth.service.BeaconChain.SubmitBlockSSZ:output_type -> google.protobuf.Empty
|
||||
0, // 48: ethereum.eth.service.BeaconChain.SubmitBlindedBlock:output_type -> google.protobuf.Empty
|
||||
0, // 49: ethereum.eth.service.BeaconChain.SubmitBlindedBlockSSZ:output_type -> google.protobuf.Empty
|
||||
31, // 50: ethereum.eth.service.BeaconChain.GetBlockRoot:output_type -> ethereum.eth.v1.BlockRootResponse
|
||||
32, // 51: ethereum.eth.service.BeaconChain.GetBlock:output_type -> ethereum.eth.v1.BlockResponse
|
||||
33, // 52: ethereum.eth.service.BeaconChain.GetBlockSSZ:output_type -> ethereum.eth.v1.BlockSSZResponse
|
||||
34, // 53: ethereum.eth.service.BeaconChain.GetBlockV2:output_type -> ethereum.eth.v2.BlockResponseV2
|
||||
10, // 54: ethereum.eth.service.BeaconChain.GetBlockSSZV2:output_type -> ethereum.eth.v2.SSZContainer
|
||||
35, // 55: ethereum.eth.service.BeaconChain.ListBlockAttestations:output_type -> ethereum.eth.v1.BlockAttestationsResponse
|
||||
36, // 56: ethereum.eth.service.BeaconChain.ListPoolAttestations:output_type -> ethereum.eth.v1.AttestationsPoolResponse
|
||||
0, // 57: ethereum.eth.service.BeaconChain.SubmitAttestations:output_type -> google.protobuf.Empty
|
||||
37, // 58: ethereum.eth.service.BeaconChain.ListPoolAttesterSlashings:output_type -> ethereum.eth.v1.AttesterSlashingsPoolResponse
|
||||
0, // 59: ethereum.eth.service.BeaconChain.SubmitAttesterSlashing:output_type -> google.protobuf.Empty
|
||||
38, // 60: ethereum.eth.service.BeaconChain.ListPoolProposerSlashings:output_type -> ethereum.eth.v1.ProposerSlashingPoolResponse
|
||||
0, // 61: ethereum.eth.service.BeaconChain.SubmitProposerSlashing:output_type -> google.protobuf.Empty
|
||||
39, // 62: ethereum.eth.service.BeaconChain.ListPoolVoluntaryExits:output_type -> ethereum.eth.v1.VoluntaryExitsPoolResponse
|
||||
0, // 63: ethereum.eth.service.BeaconChain.SubmitVoluntaryExit:output_type -> google.protobuf.Empty
|
||||
0, // 64: ethereum.eth.service.BeaconChain.SubmitPoolSyncCommitteeSignatures:output_type -> google.protobuf.Empty
|
||||
40, // 65: ethereum.eth.service.BeaconChain.GetForkSchedule:output_type -> ethereum.eth.v1.ForkScheduleResponse
|
||||
41, // 66: ethereum.eth.service.BeaconChain.GetSpec:output_type -> ethereum.eth.v1.SpecResponse
|
||||
42, // 67: ethereum.eth.service.BeaconChain.GetDepositContract:output_type -> ethereum.eth.v1.DepositContractResponse
|
||||
34, // [34:68] is the sub-list for method output_type
|
||||
0, // [0:34] is the sub-list for method input_type
|
||||
8, // 20: ethereum.eth.service.BeaconChain.GetBlindedBlock:input_type -> ethereum.eth.v1.BlockRequest
|
||||
8, // 21: ethereum.eth.service.BeaconChain.GetBlindedBlockSSZ:input_type -> ethereum.eth.v1.BlockRequest
|
||||
12, // 22: ethereum.eth.service.BeaconChain.GetBlockSSZV2:input_type -> ethereum.eth.v2.BlockRequestV2
|
||||
8, // 23: ethereum.eth.service.BeaconChain.ListBlockAttestations:input_type -> ethereum.eth.v1.BlockRequest
|
||||
13, // 24: ethereum.eth.service.BeaconChain.ListPoolAttestations:input_type -> ethereum.eth.v1.AttestationsPoolRequest
|
||||
14, // 25: ethereum.eth.service.BeaconChain.SubmitAttestations:input_type -> ethereum.eth.v1.SubmitAttestationsRequest
|
||||
0, // 26: ethereum.eth.service.BeaconChain.ListPoolAttesterSlashings:input_type -> google.protobuf.Empty
|
||||
15, // 27: ethereum.eth.service.BeaconChain.SubmitAttesterSlashing:input_type -> ethereum.eth.v1.AttesterSlashing
|
||||
0, // 28: ethereum.eth.service.BeaconChain.ListPoolProposerSlashings:input_type -> google.protobuf.Empty
|
||||
16, // 29: ethereum.eth.service.BeaconChain.SubmitProposerSlashing:input_type -> ethereum.eth.v1.ProposerSlashing
|
||||
0, // 30: ethereum.eth.service.BeaconChain.ListPoolVoluntaryExits:input_type -> google.protobuf.Empty
|
||||
17, // 31: ethereum.eth.service.BeaconChain.SubmitVoluntaryExit:input_type -> ethereum.eth.v1.SignedVoluntaryExit
|
||||
18, // 32: ethereum.eth.service.BeaconChain.SubmitPoolSyncCommitteeSignatures:input_type -> ethereum.eth.v2.SubmitPoolSyncCommitteeSignatures
|
||||
0, // 33: ethereum.eth.service.BeaconChain.GetForkSchedule:input_type -> google.protobuf.Empty
|
||||
0, // 34: ethereum.eth.service.BeaconChain.GetSpec:input_type -> google.protobuf.Empty
|
||||
0, // 35: ethereum.eth.service.BeaconChain.GetDepositContract:input_type -> google.protobuf.Empty
|
||||
19, // 36: ethereum.eth.service.BeaconChain.GetGenesis:output_type -> ethereum.eth.v1.GenesisResponse
|
||||
20, // 37: ethereum.eth.service.BeaconChain.GetWeakSubjectivity:output_type -> ethereum.eth.v1.WeakSubjectivityResponse
|
||||
21, // 38: ethereum.eth.service.BeaconChain.GetStateRoot:output_type -> ethereum.eth.v1.StateRootResponse
|
||||
22, // 39: ethereum.eth.service.BeaconChain.GetStateFork:output_type -> ethereum.eth.v1.StateForkResponse
|
||||
23, // 40: ethereum.eth.service.BeaconChain.GetFinalityCheckpoints:output_type -> ethereum.eth.v1.StateFinalityCheckpointResponse
|
||||
24, // 41: ethereum.eth.service.BeaconChain.ListValidators:output_type -> ethereum.eth.v1.StateValidatorsResponse
|
||||
25, // 42: ethereum.eth.service.BeaconChain.GetValidator:output_type -> ethereum.eth.v1.StateValidatorResponse
|
||||
26, // 43: ethereum.eth.service.BeaconChain.ListValidatorBalances:output_type -> ethereum.eth.v1.ValidatorBalancesResponse
|
||||
27, // 44: ethereum.eth.service.BeaconChain.ListCommittees:output_type -> ethereum.eth.v1.StateCommitteesResponse
|
||||
28, // 45: ethereum.eth.service.BeaconChain.ListSyncCommittees:output_type -> ethereum.eth.v2.StateSyncCommitteesResponse
|
||||
29, // 46: ethereum.eth.service.BeaconChain.ListBlockHeaders:output_type -> ethereum.eth.v1.BlockHeadersResponse
|
||||
30, // 47: ethereum.eth.service.BeaconChain.GetBlockHeader:output_type -> ethereum.eth.v1.BlockHeaderResponse
|
||||
0, // 48: ethereum.eth.service.BeaconChain.SubmitBlock:output_type -> google.protobuf.Empty
|
||||
0, // 49: ethereum.eth.service.BeaconChain.SubmitBlockSSZ:output_type -> google.protobuf.Empty
|
||||
0, // 50: ethereum.eth.service.BeaconChain.SubmitBlindedBlock:output_type -> google.protobuf.Empty
|
||||
0, // 51: ethereum.eth.service.BeaconChain.SubmitBlindedBlockSSZ:output_type -> google.protobuf.Empty
|
||||
31, // 52: ethereum.eth.service.BeaconChain.GetBlockRoot:output_type -> ethereum.eth.v1.BlockRootResponse
|
||||
32, // 53: ethereum.eth.service.BeaconChain.GetBlock:output_type -> ethereum.eth.v1.BlockResponse
|
||||
33, // 54: ethereum.eth.service.BeaconChain.GetBlockSSZ:output_type -> ethereum.eth.v1.BlockSSZResponse
|
||||
34, // 55: ethereum.eth.service.BeaconChain.GetBlockV2:output_type -> ethereum.eth.v2.BlockResponseV2
|
||||
35, // 56: ethereum.eth.service.BeaconChain.GetBlindedBlock:output_type -> ethereum.eth.v2.BlindedBlockResponse
|
||||
10, // 57: ethereum.eth.service.BeaconChain.GetBlindedBlockSSZ:output_type -> ethereum.eth.v2.SSZContainer
|
||||
10, // 58: ethereum.eth.service.BeaconChain.GetBlockSSZV2:output_type -> ethereum.eth.v2.SSZContainer
|
||||
36, // 59: ethereum.eth.service.BeaconChain.ListBlockAttestations:output_type -> ethereum.eth.v1.BlockAttestationsResponse
|
||||
37, // 60: ethereum.eth.service.BeaconChain.ListPoolAttestations:output_type -> ethereum.eth.v1.AttestationsPoolResponse
|
||||
0, // 61: ethereum.eth.service.BeaconChain.SubmitAttestations:output_type -> google.protobuf.Empty
|
||||
38, // 62: ethereum.eth.service.BeaconChain.ListPoolAttesterSlashings:output_type -> ethereum.eth.v1.AttesterSlashingsPoolResponse
|
||||
0, // 63: ethereum.eth.service.BeaconChain.SubmitAttesterSlashing:output_type -> google.protobuf.Empty
|
||||
39, // 64: ethereum.eth.service.BeaconChain.ListPoolProposerSlashings:output_type -> ethereum.eth.v1.ProposerSlashingPoolResponse
|
||||
0, // 65: ethereum.eth.service.BeaconChain.SubmitProposerSlashing:output_type -> google.protobuf.Empty
|
||||
40, // 66: ethereum.eth.service.BeaconChain.ListPoolVoluntaryExits:output_type -> ethereum.eth.v1.VoluntaryExitsPoolResponse
|
||||
0, // 67: ethereum.eth.service.BeaconChain.SubmitVoluntaryExit:output_type -> google.protobuf.Empty
|
||||
0, // 68: ethereum.eth.service.BeaconChain.SubmitPoolSyncCommitteeSignatures:output_type -> google.protobuf.Empty
|
||||
41, // 69: ethereum.eth.service.BeaconChain.GetForkSchedule:output_type -> ethereum.eth.v1.ForkScheduleResponse
|
||||
42, // 70: ethereum.eth.service.BeaconChain.GetSpec:output_type -> ethereum.eth.v1.SpecResponse
|
||||
43, // 71: ethereum.eth.service.BeaconChain.GetDepositContract:output_type -> ethereum.eth.v1.DepositContractResponse
|
||||
36, // [36:72] is the sub-list for method output_type
|
||||
0, // [0:36] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
@@ -553,6 +578,8 @@ type BeaconChainClient interface {
|
||||
GetBlock(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v1.BlockResponse, error)
|
||||
GetBlockSSZ(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v1.BlockSSZResponse, error)
|
||||
GetBlockV2(ctx context.Context, in *v2.BlockRequestV2, opts ...grpc.CallOption) (*v2.BlockResponseV2, error)
|
||||
GetBlindedBlock(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v2.BlindedBlockResponse, error)
|
||||
GetBlindedBlockSSZ(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v2.SSZContainer, error)
|
||||
GetBlockSSZV2(ctx context.Context, in *v2.BlockRequestV2, opts ...grpc.CallOption) (*v2.SSZContainer, error)
|
||||
ListBlockAttestations(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v1.BlockAttestationsResponse, error)
|
||||
ListPoolAttestations(ctx context.Context, in *v1.AttestationsPoolRequest, opts ...grpc.CallOption) (*v1.AttestationsPoolResponse, error)
|
||||
@@ -757,6 +784,24 @@ func (c *beaconChainClient) GetBlockV2(ctx context.Context, in *v2.BlockRequestV
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *beaconChainClient) GetBlindedBlock(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v2.BlindedBlockResponse, error) {
|
||||
out := new(v2.BlindedBlockResponse)
|
||||
err := c.cc.Invoke(ctx, "/ethereum.eth.service.BeaconChain/GetBlindedBlock", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *beaconChainClient) GetBlindedBlockSSZ(ctx context.Context, in *v1.BlockRequest, opts ...grpc.CallOption) (*v2.SSZContainer, error) {
|
||||
out := new(v2.SSZContainer)
|
||||
err := c.cc.Invoke(ctx, "/ethereum.eth.service.BeaconChain/GetBlindedBlockSSZ", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *beaconChainClient) GetBlockSSZV2(ctx context.Context, in *v2.BlockRequestV2, opts ...grpc.CallOption) (*v2.SSZContainer, error) {
|
||||
out := new(v2.SSZContainer)
|
||||
err := c.cc.Invoke(ctx, "/ethereum.eth.service.BeaconChain/GetBlockSSZV2", in, out, opts...)
|
||||
@@ -905,6 +950,8 @@ type BeaconChainServer interface {
|
||||
GetBlock(context.Context, *v1.BlockRequest) (*v1.BlockResponse, error)
|
||||
GetBlockSSZ(context.Context, *v1.BlockRequest) (*v1.BlockSSZResponse, error)
|
||||
GetBlockV2(context.Context, *v2.BlockRequestV2) (*v2.BlockResponseV2, error)
|
||||
GetBlindedBlock(context.Context, *v1.BlockRequest) (*v2.BlindedBlockResponse, error)
|
||||
GetBlindedBlockSSZ(context.Context, *v1.BlockRequest) (*v2.SSZContainer, error)
|
||||
GetBlockSSZV2(context.Context, *v2.BlockRequestV2) (*v2.SSZContainer, error)
|
||||
ListBlockAttestations(context.Context, *v1.BlockRequest) (*v1.BlockAttestationsResponse, error)
|
||||
ListPoolAttestations(context.Context, *v1.AttestationsPoolRequest) (*v1.AttestationsPoolResponse, error)
|
||||
@@ -985,6 +1032,12 @@ func (*UnimplementedBeaconChainServer) GetBlockSSZ(context.Context, *v1.BlockReq
|
||||
func (*UnimplementedBeaconChainServer) GetBlockV2(context.Context, *v2.BlockRequestV2) (*v2.BlockResponseV2, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBlockV2 not implemented")
|
||||
}
|
||||
func (*UnimplementedBeaconChainServer) GetBlindedBlock(context.Context, *v1.BlockRequest) (*v2.BlindedBlockResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBlindedBlock not implemented")
|
||||
}
|
||||
func (*UnimplementedBeaconChainServer) GetBlindedBlockSSZ(context.Context, *v1.BlockRequest) (*v2.SSZContainer, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBlindedBlockSSZ not implemented")
|
||||
}
|
||||
func (*UnimplementedBeaconChainServer) GetBlockSSZV2(context.Context, *v2.BlockRequestV2) (*v2.SSZContainer, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBlockSSZV2 not implemented")
|
||||
}
|
||||
@@ -1392,6 +1445,42 @@ func _BeaconChain_GetBlockV2_Handler(srv interface{}, ctx context.Context, dec f
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _BeaconChain_GetBlindedBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(v1.BlockRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(BeaconChainServer).GetBlindedBlock(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ethereum.eth.service.BeaconChain/GetBlindedBlock",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(BeaconChainServer).GetBlindedBlock(ctx, req.(*v1.BlockRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _BeaconChain_GetBlindedBlockSSZ_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(v1.BlockRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(BeaconChainServer).GetBlindedBlockSSZ(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ethereum.eth.service.BeaconChain/GetBlindedBlockSSZ",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(BeaconChainServer).GetBlindedBlockSSZ(ctx, req.(*v1.BlockRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _BeaconChain_GetBlockSSZV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(v2.BlockRequestV2)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -1728,6 +1817,14 @@ var _BeaconChain_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetBlockV2",
|
||||
Handler: _BeaconChain_GetBlockV2_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBlindedBlock",
|
||||
Handler: _BeaconChain_GetBlindedBlock_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBlindedBlockSSZ",
|
||||
Handler: _BeaconChain_GetBlindedBlockSSZ_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBlockSSZV2",
|
||||
Handler: _BeaconChain_GetBlockSSZV2_Handler,
|
||||
|
||||
@@ -10,12 +10,15 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
emptypb "github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
|
||||
github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/proto/eth/v1"
|
||||
v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1"
|
||||
"github.com/prysmaticlabs/prysm/v3/proto/eth/v2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -23,8 +26,6 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
@@ -1042,6 +1043,114 @@ func local_request_BeaconChain_GetBlockV2_0(ctx context.Context, marshaler runti
|
||||
|
||||
}
|
||||
|
||||
func request_BeaconChain_GetBlindedBlock_0(ctx context.Context, marshaler runtime.Marshaler, client BeaconChainClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq v1.BlockRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["block_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_id")
|
||||
}
|
||||
|
||||
block_id, err := runtime.Bytes(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_id", err)
|
||||
}
|
||||
protoReq.BlockId = (block_id)
|
||||
|
||||
msg, err := client.GetBlindedBlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_BeaconChain_GetBlindedBlock_0(ctx context.Context, marshaler runtime.Marshaler, server BeaconChainServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq v1.BlockRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["block_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_id")
|
||||
}
|
||||
|
||||
block_id, err := runtime.Bytes(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_id", err)
|
||||
}
|
||||
protoReq.BlockId = (block_id)
|
||||
|
||||
msg, err := server.GetBlindedBlock(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_BeaconChain_GetBlindedBlockSSZ_0(ctx context.Context, marshaler runtime.Marshaler, client BeaconChainClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq v1.BlockRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["block_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_id")
|
||||
}
|
||||
|
||||
block_id, err := runtime.Bytes(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_id", err)
|
||||
}
|
||||
protoReq.BlockId = (block_id)
|
||||
|
||||
msg, err := client.GetBlindedBlockSSZ(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_BeaconChain_GetBlindedBlockSSZ_0(ctx context.Context, marshaler runtime.Marshaler, server BeaconChainServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq v1.BlockRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["block_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_id")
|
||||
}
|
||||
|
||||
block_id, err := runtime.Bytes(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_id", err)
|
||||
}
|
||||
protoReq.BlockId = (block_id)
|
||||
|
||||
msg, err := server.GetBlindedBlockSSZ(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_BeaconChain_GetBlockSSZV2_0(ctx context.Context, marshaler runtime.Marshaler, client BeaconChainClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq eth.BlockRequestV2
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -1930,6 +2039,52 @@ func RegisterBeaconChainHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlindedBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ethereum.eth.service.BeaconChain/GetBlindedBlock")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_BeaconChain_GetBlindedBlock_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_GetBlindedBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlindedBlockSSZ_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ethereum.eth.service.BeaconChain/GetBlindedBlockSSZ")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_BeaconChain_GetBlindedBlockSSZ_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_GetBlindedBlockSSZ_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlockSSZV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -2693,6 +2848,46 @@ func RegisterBeaconChainHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlindedBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/ethereum.eth.service.BeaconChain/GetBlindedBlock")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_BeaconChain_GetBlindedBlock_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_GetBlindedBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlindedBlockSSZ_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/ethereum.eth.service.BeaconChain/GetBlindedBlockSSZ")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_BeaconChain_GetBlindedBlockSSZ_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_GetBlindedBlockSSZ_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_GetBlockSSZV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -3017,6 +3212,10 @@ var (
|
||||
|
||||
pattern_BeaconChain_GetBlockV2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"internal", "eth", "v2", "beacon", "blocks", "block_id"}, ""))
|
||||
|
||||
pattern_BeaconChain_GetBlindedBlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"internal", "eth", "v1", "beacon", "blinded_blocks", "block_id"}, ""))
|
||||
|
||||
pattern_BeaconChain_GetBlindedBlockSSZ_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"internal", "eth", "v1", "beacon", "blinded_blocks", "block_id", "ssz"}, ""))
|
||||
|
||||
pattern_BeaconChain_GetBlockSSZV2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"internal", "eth", "v2", "beacon", "blocks", "block_id", "ssz"}, ""))
|
||||
|
||||
pattern_BeaconChain_ListBlockAttestations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"internal", "eth", "v1", "beacon", "blocks", "block_id", "attestations"}, ""))
|
||||
@@ -3087,6 +3286,10 @@ var (
|
||||
|
||||
forward_BeaconChain_GetBlockV2_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_GetBlindedBlock_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_GetBlindedBlockSSZ_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_GetBlockSSZV2_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_ListBlockAttestations_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -249,6 +249,24 @@ service BeaconChain {
|
||||
};
|
||||
}
|
||||
|
||||
// GetBlindedBlock retrieves blinded block for given block id.
|
||||
//
|
||||
// https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlindedBlock
|
||||
rpc GetBlindedBlock(v1.BlockRequest) returns (v2.BlindedBlockResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/internal/eth/v1/beacon/blinded_blocks/{block_id}"
|
||||
};
|
||||
}
|
||||
|
||||
// GetBlindedBlockSSZ returns the SSZ-serialized version of blinded block details for given block id.
|
||||
//
|
||||
// Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlindedBlock
|
||||
rpc GetBlindedBlockSSZ(v1.BlockRequest) returns (v2.SSZContainer) {
|
||||
option (google.api.http) = {
|
||||
get: "/internal/eth/v1/beacon/blinded_blocks/{block_id}/ssz"
|
||||
};
|
||||
}
|
||||
|
||||
// GetBlockSSZV2 returns the SSZ-serialized version of block details for given block id.
|
||||
//
|
||||
// Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.3.0#/Beacon/getBlockV2
|
||||
|
||||
958
proto/eth/v2/beacon_block.pb.go
generated
958
proto/eth/v2/beacon_block.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -40,6 +40,12 @@ message BlockResponseV2 {
|
||||
bool execution_optimistic = 3;
|
||||
}
|
||||
|
||||
message BlindedBlockResponse {
|
||||
v2.Version version = 1;
|
||||
SignedBlindedBeaconBlockContainer data = 2;
|
||||
bool execution_optimistic = 3;
|
||||
}
|
||||
|
||||
message BeaconBlockContainerV2 {
|
||||
oneof block {
|
||||
v1.BeaconBlock phase0_block = 1;
|
||||
|
||||
44
proto/eth/v2/ssz.pb.go
generated
44
proto/eth/v2/ssz.pb.go
generated
@@ -26,8 +26,9 @@ type SSZContainer struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Version Version `protobuf:"varint,1,opt,name=version,proto3,enum=ethereum.eth.v2.Version" json:"version,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Version Version `protobuf:"varint,1,opt,name=version,proto3,enum=ethereum.eth.v2.Version" json:"version,omitempty"`
|
||||
ExecutionOptimistic bool `protobuf:"varint,2,opt,name=execution_optimistic,json=executionOptimistic,proto3" json:"execution_optimistic,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SSZContainer) Reset() {
|
||||
@@ -69,6 +70,13 @@ func (x *SSZContainer) GetVersion() Version {
|
||||
return Version_PHASE0
|
||||
}
|
||||
|
||||
func (x *SSZContainer) GetExecutionOptimistic() bool {
|
||||
if x != nil {
|
||||
return x.ExecutionOptimistic
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SSZContainer) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
@@ -83,20 +91,24 @@ var file_proto_eth_v2_ssz_proto_rawDesc = []byte{
|
||||
0x73, 0x7a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x1a, 0x1a, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x56, 0x0a, 0x0c, 0x53, 0x53, 0x5a, 0x43, 0x6f, 0x6e, 0x74,
|
||||
0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x79, 0x0a,
|
||||
0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x2e, 0x76, 0x32, 0x42, 0x08, 0x53, 0x73, 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
|
||||
0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32,
|
||||
0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x53, 0x53, 0x5a, 0x43, 0x6f, 0x6e,
|
||||
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x14, 0x65, 0x78,
|
||||
0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74,
|
||||
0x69, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x42, 0x79, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x08, 0x53, 0x73, 0x7a, 0x50, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70,
|
||||
0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74,
|
||||
0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -26,5 +26,6 @@ import "proto/eth/v2/version.proto";
|
||||
|
||||
message SSZContainer {
|
||||
Version version = 1;
|
||||
bytes data = 2;
|
||||
bool execution_optimistic = 2;
|
||||
bytes data = 3;
|
||||
}
|
||||
@@ -35,8 +35,8 @@ proto_library(
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//proto/eth/ext:proto",
|
||||
"//proto/engine/v1:proto",
|
||||
"//proto/eth/ext:proto",
|
||||
"@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_proto",
|
||||
"@com_google_protobuf//:any_proto",
|
||||
"@com_google_protobuf//:descriptor_proto",
|
||||
@@ -63,6 +63,15 @@ ssz_gen_marshal(
|
||||
"BeaconBlockBellatrix",
|
||||
"BeaconBlockBodyBellatrix",
|
||||
"SignedBeaconBlockBellatrix",
|
||||
"SignedBlindedBeaconBlockBellatrix",
|
||||
"BlindedBeaconBlockBellatrix",
|
||||
"BlindedBeaconBlockBodyBellatrix",
|
||||
"BeaconBlockCapella",
|
||||
"BeaconBlockBodyCapella",
|
||||
"SignedBeaconBlockCapella",
|
||||
"SignedBlindedBeaconBlockCapella",
|
||||
"BlindedBeaconBlockCapella",
|
||||
"BlindedBeaconBlockBodyCapella",
|
||||
"SyncAggregate",
|
||||
"SyncCommitteeMessage",
|
||||
"SyncCommitteeContribution",
|
||||
@@ -105,16 +114,13 @@ ssz_gen_marshal(
|
||||
"SyncCommittee",
|
||||
"SyncAggregatorSelectionData",
|
||||
"PowBlock",
|
||||
"SignedBlindedBeaconBlockBellatrix",
|
||||
"BlindedBeaconBlockBellatrix",
|
||||
"BlindedBeaconBlockBodyBellatrix",
|
||||
"SignedValidatorRegistrationV1",
|
||||
"ValidatorRegistrationV1",
|
||||
"Withdrawal",
|
||||
"Withdrawal",
|
||||
"BLSToExecutionChange",
|
||||
"SignedBLSToExecutionChange",
|
||||
"BuilderBid"
|
||||
],
|
||||
"BuilderBid",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
@@ -126,11 +132,11 @@ go_proto_library(
|
||||
proto = ":proto",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//proto/eth/ext:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/eth/ext:go_default_library",
|
||||
"@com_github_golang_protobuf//proto:go_default_library",
|
||||
"@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_go_proto",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@go_googleapis//google/api:annotations_go_proto",
|
||||
"@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
|
||||
@@ -152,8 +158,8 @@ go_proto_library(
|
||||
protos = [":proto"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//proto/eth/ext:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/eth/ext:go_default_library",
|
||||
"@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_go_proto",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@go_googleapis//google/api:annotations_go_proto",
|
||||
|
||||
@@ -558,6 +558,7 @@ func CopyWithdrawal(withdrawal *enginev1.Withdrawal) *enginev1.Withdrawal {
|
||||
|
||||
return &enginev1.Withdrawal{
|
||||
WithdrawalIndex: withdrawal.WithdrawalIndex,
|
||||
ValidatorIndex: withdrawal.ValidatorIndex,
|
||||
ExecutionAddress: bytesutil.SafeCopyBytes(withdrawal.ExecutionAddress),
|
||||
Amount: withdrawal.Amount,
|
||||
}
|
||||
|
||||
@@ -775,6 +775,7 @@ func genWithdrawals(num int) []*enginev1.Withdrawal {
|
||||
func genWithdrawal() *enginev1.Withdrawal {
|
||||
return &enginev1.Withdrawal{
|
||||
WithdrawalIndex: 123456,
|
||||
ValidatorIndex: 654321,
|
||||
ExecutionAddress: bytes(20),
|
||||
Amount: 55555,
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1214
proto/prysm/v1alpha1/validator.pb.go
generated
1214
proto/prysm/v1alpha1/validator.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -625,51 +625,6 @@ message Validator {
|
||||
uint64 withdrawable_epoch = 8 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
}
|
||||
|
||||
// An Ethereum validator after Capella fork.
|
||||
message ValidatorCapella {
|
||||
// 48 byte BLS public key used for the validator's activities.
|
||||
bytes public_key = 1 [(ethereum.eth.ext.ssz_size) = "48", (ethereum.eth.ext.spec_name) = "pubkey"];
|
||||
|
||||
// 32 byte hash of the withdrawal destination public key.
|
||||
bytes withdrawal_credentials = 2 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
|
||||
// The validators current effective balance in gwei.
|
||||
uint64 effective_balance = 3;
|
||||
|
||||
// Whether or not the validator has been slashed.
|
||||
bool slashed = 4;
|
||||
|
||||
// Epoch when the validator became eligible for activation. This field may
|
||||
// be zero if the validator was present in the Ethereum proof of stake genesis. This
|
||||
// field is FAR_FUTURE_EPOCH if the validator has not been activated.
|
||||
uint64 activation_eligibility_epoch = 5 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
|
||||
// Epoch when the validator was activated. This field may be zero if the
|
||||
// validator was present in the Ethereum proof of stake genesis. This field is
|
||||
// FAR_FUTURE_EPOCH if the validator has not been activated.
|
||||
uint64 activation_epoch = 6 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
|
||||
// Epoch when the validator was exited. This field is FAR_FUTURE_EPOCH if
|
||||
// the validator has not exited.
|
||||
// FAR_FUTURE_EPOCH is a constant defined by the official Ethereum Beacon Chain specification:
|
||||
// https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/beacon-chain.md#constants
|
||||
uint64 exit_epoch = 7 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
|
||||
// Epoch when the validator is eligible to withdraw their funds. This field
|
||||
// is FAR_FUTURE_EPOCH if the validator has not exited.
|
||||
// FAR_FUTURE_EPOCH is a constant defined by the official Ethereum Beacon Chain specification:
|
||||
// https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/beacon-chain.md#constants
|
||||
uint64 withdrawable_epoch = 8 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
|
||||
// New in Capella.
|
||||
//
|
||||
// Epoch when the validator's funds were withdrawn.
|
||||
// This field is FAR_FUTURE_EPOCH if the validator's withdrawal has not been processed.
|
||||
// FAR_FUTURE_EPOCH is a constant defined by the official Ethereum Beacon Chain specification:
|
||||
// https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/beacon-chain.md#constants
|
||||
uint64 fully_withdrawn_epoch = 9 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
}
|
||||
|
||||
// ValidatorParticipation stores participation metrics during a given epoch.
|
||||
message ValidatorParticipation {
|
||||
// Percentage of validator participation in the given epoch. This field
|
||||
|
||||
@@ -68,7 +68,7 @@ func GenerateGenesisStateFromDepositData(
|
||||
return nil, nil, errors.Wrap(err, "could not generate genesis state")
|
||||
}
|
||||
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(beaconState.InnerStateUnsafe())
|
||||
pbState, err := statenative.ProtobufBeaconStatePhase0(beaconState.ToProtoUnsafe())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ func RunEpochOperationTest(
|
||||
t.Fatalf("Failed to unmarshal: %v", err)
|
||||
}
|
||||
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(beaconState.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(beaconState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.InnerStateUnsafe(), postBeaconState)
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.ToProtoUnsafe(), postBeaconState)
|
||||
t.Log(diff)
|
||||
t.Fatal("Post state does not match expected")
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func RunFinalityTest(t *testing.T, config string) {
|
||||
require.NoError(t, err, "Failed to decompress")
|
||||
postBeaconState := ðpb.BeaconStateAltair{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal")
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(beaconState.InnerStateUnsafe())
|
||||
pbState, err := state_native.ProtobufBeaconStateAltair(beaconState.ToProtoUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
t.Fatal("Post state does not match expected")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user