mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
Compare commits
18 Commits
hot-state-
...
v3.0.0-rc.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6fa65f7b | ||
|
|
eaa2566e90 | ||
|
|
6957f0637f | ||
|
|
01b1f15bdf | ||
|
|
b787fd877a | ||
|
|
2c89ce810d | ||
|
|
e687fff922 | ||
|
|
5e2498be7e | ||
|
|
76f958710f | ||
|
|
1775cf89c6 | ||
|
|
8fecfaee48 | ||
|
|
f089405d2f | ||
|
|
029c81a2e4 | ||
|
|
56c48b4971 | ||
|
|
20ed47a107 | ||
|
|
e30471f1a0 | ||
|
|
3b38765a2d | ||
|
|
b60e508c89 |
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Run Gosec Security Scanner
|
||||
run: | # https://github.com/securego/gosec/issues/469
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||
go install github.com/securego/gosec/v2/cmd/gosec@v2.12.0
|
||||
gosec -exclude=G307 -exclude-dir=crypto/bls/herumi ./...
|
||||
|
||||
lint:
|
||||
|
||||
10
WORKSPACE
10
WORKSPACE
@@ -215,7 +215,7 @@ filegroup(
|
||||
url = "https://github.com/eth-clients/slashing-protection-interchange-tests/archive/b8413ca42dc92308019d0d4db52c87e9e125c4e9.tar.gz",
|
||||
)
|
||||
|
||||
consensus_spec_version = "v1.2.0-rc.2"
|
||||
consensus_spec_version = "v1.2.0-rc.3"
|
||||
|
||||
bls_test_version = "v0.1.1"
|
||||
|
||||
@@ -231,7 +231,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "eff52923eebbed6e37a5282db5290abe67c68d6aa54302e3db2b0718c3edf867",
|
||||
sha256 = "18ca21497f41042cdbe60e2333b100d218b2994fb514964b9deb23daf615a12f",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -247,7 +247,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "6183d39d40ae659347e8bcfa435cbbe6de8c19ab327b61d47f906bb087bc7a67",
|
||||
sha256 = "47b8f6fabe39b4a69f13054ba74e26ab51581ddbd359c18cf0f03317474e299c",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -263,7 +263,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "894d16608d7d37a8f6206165e6c2b6ffcc45b13152b5f411e9283b005ca9793f",
|
||||
sha256 = "a061efc05429b169393c32dc2633a948269461b0fe681f11d41e170a880dcc71",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -278,7 +278,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "006674e5d7eee613f1155e154ab97f6b57589ec92e6e3e5f7affd2b53581e907",
|
||||
sha256 = "753d51c6a6cc6df101c897e4bea77f73b271f50aeda74440f412514d4bd88a86",
|
||||
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
|
||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -87,7 +87,6 @@ func (s *Service) saveHead(ctx context.Context, newHeadRoot [32]byte, headBlock
|
||||
return nil
|
||||
}
|
||||
|
||||
// A chain re-org occurred, so we fire an event notifying the rest of the services.
|
||||
s.headLock.RLock()
|
||||
oldHeadBlock, err := s.headBlock()
|
||||
if err != nil {
|
||||
@@ -98,11 +97,21 @@ func (s *Service) saveHead(ctx context.Context, newHeadRoot [32]byte, headBlock
|
||||
headSlot := s.HeadSlot()
|
||||
newHeadSlot := headBlock.Block().Slot()
|
||||
newStateRoot := headBlock.Block().StateRoot()
|
||||
|
||||
// A chain re-org occurred, so we fire an event notifying the rest of the services.
|
||||
if bytesutil.ToBytes32(headBlock.Block().ParentRoot()) != oldHeadRoot {
|
||||
commonRoot, err := s.ForkChoicer().CommonAncestorRoot(ctx, oldHeadRoot, newHeadRoot)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not find common ancestor root")
|
||||
commonRoot = params.BeaconConfig().ZeroHash
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"newSlot": fmt.Sprintf("%d", newHeadSlot),
|
||||
"oldSlot": fmt.Sprintf("%d", headSlot),
|
||||
}).Debug("Chain reorg occurred")
|
||||
"newSlot": fmt.Sprintf("%d", newHeadSlot),
|
||||
"newRoot": fmt.Sprintf("%#x", newHeadRoot),
|
||||
"oldSlot": fmt.Sprintf("%d", headSlot),
|
||||
"oldRoot": fmt.Sprintf("%#x", oldHeadRoot),
|
||||
"commonAncestorRoot": fmt.Sprintf("%#x", commonRoot),
|
||||
}).Info("Chain reorg occurred")
|
||||
absoluteSlotDifference := slots.AbsoluteValueSlotDifference(newHeadSlot, headSlot)
|
||||
isOptimistic, err := s.IsOptimistic(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -139,6 +139,9 @@ func (s *Service) onBlock(ctx context.Context, signed interfaces.SignedBeaconBlo
|
||||
if err := s.insertBlockToForkchoiceStore(ctx, signed.Block(), blockRoot, postState); err != nil {
|
||||
return errors.Wrapf(err, "could not insert block %d to fork choice store", signed.Block().Slot())
|
||||
}
|
||||
if err := s.handleBlockAttestations(ctx, signed.Block(), postState); err != nil {
|
||||
return errors.Wrap(err, "could not handle block's attestations")
|
||||
}
|
||||
s.InsertSlashingsToForkChoiceStore(ctx, signed.Block().Body().AttesterSlashings())
|
||||
if isValidPayload {
|
||||
if err := s.cfg.ForkChoiceStore.SetOptimisticToValid(ctx, blockRoot); err != nil {
|
||||
@@ -516,6 +519,29 @@ func (s *Service) insertBlockToForkchoiceStore(ctx context.Context, blk interfac
|
||||
return nil
|
||||
}
|
||||
|
||||
// This feeds in the attestations included in the block to fork choice store. It's allows fork choice store
|
||||
// to gain information on the most current chain.
|
||||
func (s *Service) handleBlockAttestations(ctx context.Context, blk interfaces.BeaconBlock, st state.BeaconState) error {
|
||||
// Feed in block's attestations to fork choice store.
|
||||
for _, a := range blk.Body().Attestations() {
|
||||
committee, err := helpers.BeaconCommitteeFromState(ctx, st, a.Data.Slot, a.Data.CommitteeIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
indices, err := attestation.AttestingIndices(a.AggregationBits, committee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r := bytesutil.ToBytes32(a.Data.BeaconBlockRoot)
|
||||
if s.cfg.ForkChoiceStore.HasNode(r) {
|
||||
s.cfg.ForkChoiceStore.ProcessAttestation(ctx, indices, r, a.Data.Target.Epoch)
|
||||
} else if err := s.cfg.AttPool.SaveBlockAttestation(a); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InsertSlashingsToForkChoiceStore inserts attester slashing indices to fork choice store.
|
||||
// To call this function, it's caller's responsibility to ensure the slashing object is valid.
|
||||
func (s *Service) InsertSlashingsToForkChoiceStore(ctx context.Context, slashings []*ethpb.AttesterSlashing) {
|
||||
|
||||
@@ -3314,6 +3314,75 @@ func TestStore_NoViableHead_Reboot_Protoarray(t *testing.T) {
|
||||
require.Equal(t, false, service.ForkChoicer().AllTipsAreInvalid())
|
||||
}
|
||||
|
||||
func TestOnBlock_HandleBlockAttestations(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
beaconDB := testDB.SetupDB(t)
|
||||
opts := []Option{
|
||||
WithDatabase(beaconDB),
|
||||
WithAttestationPool(attestations.NewPool()),
|
||||
WithStateGen(stategen.New(beaconDB)),
|
||||
WithForkChoiceStore(doublylinkedtree.New()),
|
||||
WithStateNotifier(&mock.MockStateNotifier{}),
|
||||
}
|
||||
service, err := NewService(ctx, opts...)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, keys := util.DeterministicGenesisState(t, 64)
|
||||
stateRoot, err := st.HashTreeRoot(ctx)
|
||||
require.NoError(t, err, "Could not hash genesis state")
|
||||
|
||||
require.NoError(t, service.saveGenesisData(ctx, st))
|
||||
|
||||
genesis := blocks.NewGenesisBlock(stateRoot[:])
|
||||
wsb, err := consensusblocks.NewSignedBeaconBlock(genesis)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wsb), "Could not save genesis block")
|
||||
parentRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err, "Could not get signing root")
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st, parentRoot), "Could not save genesis state")
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveHeadBlockRoot(ctx, parentRoot), "Could not save genesis state")
|
||||
|
||||
st, err = service.HeadState(ctx)
|
||||
require.NoError(t, err)
|
||||
b, err := util.GenerateFullBlock(st, keys, util.DefaultBlockGenConfig(), 1)
|
||||
require.NoError(t, err)
|
||||
wsb, err = consensusblocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
root, err := b.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.onBlock(ctx, wsb, root))
|
||||
|
||||
st, err = service.HeadState(ctx)
|
||||
require.NoError(t, err)
|
||||
b, err = util.GenerateFullBlock(st, keys, util.DefaultBlockGenConfig(), 2)
|
||||
require.NoError(t, err)
|
||||
wsb, err = consensusblocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
|
||||
// prepare another block that is not inserted
|
||||
st3, err := transition.ExecuteStateTransition(ctx, st, wsb)
|
||||
require.NoError(t, err)
|
||||
b3, err := util.GenerateFullBlock(st3, keys, util.DefaultBlockGenConfig(), 3)
|
||||
require.NoError(t, err)
|
||||
wsb3, err := consensusblocks.NewSignedBeaconBlock(b3)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, 1, len(wsb.Block().Body().Attestations()))
|
||||
a := wsb.Block().Body().Attestations()[0]
|
||||
r := bytesutil.ToBytes32(a.Data.BeaconBlockRoot)
|
||||
require.Equal(t, true, service.cfg.ForkChoiceStore.HasNode(r))
|
||||
|
||||
require.Equal(t, 1, len(wsb.Block().Body().Attestations()))
|
||||
a3 := wsb3.Block().Body().Attestations()[0]
|
||||
r3 := bytesutil.ToBytes32(a3.Data.BeaconBlockRoot)
|
||||
require.Equal(t, false, service.cfg.ForkChoiceStore.HasNode(r3))
|
||||
|
||||
require.NoError(t, service.handleBlockAttestations(ctx, wsb.Block(), st)) // fine to use the same committe as st
|
||||
require.Equal(t, 0, service.cfg.AttPool.ForkchoiceAttestationCount())
|
||||
require.NoError(t, service.handleBlockAttestations(ctx, wsb3.Block(), st3)) // fine to use the same committe as st
|
||||
require.Equal(t, 1, len(service.cfg.AttPool.BlockAttestations()))
|
||||
}
|
||||
|
||||
// Helper function to simulate the block being on time or delayed for proposer
|
||||
// boost. It alters the genesisTime tracked by the store.
|
||||
func driftGenesisTime(s *Service, slot int64, delay int64) {
|
||||
|
||||
@@ -150,11 +150,6 @@ func (s *Service) handlePostBlockOperations(b interfaces.BeaconBlock) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add block attestations to the fork choice pool to compute head.
|
||||
if err := s.cfg.AttPool.SaveBlockAttestations(b.Body().Attestations()); err != nil {
|
||||
log.WithError(err).Error("Could not save block attestations for fork choice")
|
||||
return nil
|
||||
}
|
||||
// Mark block exits as seen so we don't include same ones in future blocks.
|
||||
for _, e := range b.Body().VoluntaryExits() {
|
||||
s.cfg.ExitPool.MarkIncluded(e)
|
||||
|
||||
@@ -76,9 +76,9 @@ func TestService_ReceiveBlock(t *testing.T) {
|
||||
),
|
||||
},
|
||||
check: func(t *testing.T, s *Service) {
|
||||
if baCount := len(s.cfg.AttPool.BlockAttestations()); baCount != 2 {
|
||||
if baCount := len(s.cfg.AttPool.BlockAttestations()); baCount != 0 {
|
||||
t.Errorf("Did not get the correct number of block attestations saved to the pool. "+
|
||||
"Got %d but wanted %d", baCount, 2)
|
||||
"Got %d but wanted %d", baCount, 0)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -65,7 +65,6 @@ func (s *Service) pollConnectionStatus(ctx context.Context) {
|
||||
currClient := s.rpcClient
|
||||
if err := s.setupExecutionClientConnections(ctx, s.cfg.currHttpEndpoint); err != nil {
|
||||
errorLogger(err, "Could not connect to execution client endpoint")
|
||||
s.retryExecutionClientConnection(ctx, err)
|
||||
continue
|
||||
}
|
||||
// Close previous client, if connection was successful.
|
||||
|
||||
@@ -183,11 +183,15 @@ func (f *ForkChoice) updateCheckpoints(ctx context.Context, jc, fc *ethpb.Checkp
|
||||
return err
|
||||
}
|
||||
jcRoot := bytesutil.ToBytes32(jc.Root)
|
||||
// Releasing here the checkpoints lock because
|
||||
// AncestorRoot acquires a lock on nodes and that can
|
||||
// cause a double lock.
|
||||
f.store.checkpointsLock.Unlock()
|
||||
root, err := f.AncestorRoot(ctx, jcRoot, jSlot)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
f.store.checkpointsLock.Lock()
|
||||
if root == currentRoot {
|
||||
f.store.prevJustifiedCheckpoint = f.store.justifiedCheckpoint
|
||||
f.store.justifiedCheckpoint = &forkchoicetypes.Checkpoint{Epoch: jc.Epoch,
|
||||
@@ -296,7 +300,8 @@ func (f *ForkChoice) AncestorRoot(ctx context.Context, root [32]byte, slot types
|
||||
}
|
||||
|
||||
// updateBalances updates the balances that directly voted for each block taking into account the
|
||||
// validators' latest votes. This function requires a lock in Store.nodesLock.
|
||||
// validators' latest votes. This function requires a lock in Store.nodesLock
|
||||
// and votesLock
|
||||
func (f *ForkChoice) updateBalances(newBalances []uint64) error {
|
||||
for index, vote := range f.votes {
|
||||
// Skip if validator has been slashed
|
||||
@@ -424,6 +429,9 @@ func (f *ForkChoice) SetOptimisticToInvalid(ctx context.Context, root, parentRoo
|
||||
// store-tracked list. Votes from these validators are not accounted for
|
||||
// in forkchoice.
|
||||
func (f *ForkChoice) InsertSlashedIndex(_ context.Context, index types.ValidatorIndex) {
|
||||
f.votesLock.RLock()
|
||||
defer f.votesLock.RUnlock()
|
||||
|
||||
f.store.nodesLock.Lock()
|
||||
defer f.store.nodesLock.Unlock()
|
||||
// return early if the index was already included:
|
||||
@@ -433,8 +441,6 @@ func (f *ForkChoice) InsertSlashedIndex(_ context.Context, index types.Validator
|
||||
f.store.slashedIndices[index] = true
|
||||
|
||||
// Subtract last vote from this equivocating validator
|
||||
f.votesLock.RLock()
|
||||
defer f.votesLock.RUnlock()
|
||||
|
||||
if index >= types.ValidatorIndex(len(f.balances)) {
|
||||
return
|
||||
|
||||
@@ -40,7 +40,8 @@ func (n *Node) applyWeightChanges(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// updateBestDescendant updates the best descendant of this node and its children.
|
||||
// updateBestDescendant updates the best descendant of this node and its
|
||||
// children. This function assumes the caller has a lock on Store.nodesLock
|
||||
func (n *Node) updateBestDescendant(ctx context.Context, justifiedEpoch, finalizedEpoch types.Epoch) error {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
|
||||
@@ -41,15 +41,14 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
|
||||
}
|
||||
|
||||
// Update store.justified_checkpoint if a better checkpoint on the store.finalized_checkpoint chain
|
||||
f.store.checkpointsLock.Lock()
|
||||
|
||||
f.store.checkpointsLock.RLock()
|
||||
bjcp := f.store.bestJustifiedCheckpoint
|
||||
jcp := f.store.justifiedCheckpoint
|
||||
fcp := f.store.finalizedCheckpoint
|
||||
f.store.checkpointsLock.RUnlock()
|
||||
if bjcp.Epoch > jcp.Epoch {
|
||||
finalizedSlot, err := slots.EpochStart(fcp.Epoch)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -59,15 +58,15 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
|
||||
// loop call here.
|
||||
r, err := f.AncestorRoot(ctx, bjcp.Root, finalizedSlot)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
if r == fcp.Root {
|
||||
f.store.checkpointsLock.Lock()
|
||||
f.store.prevJustifiedCheckpoint = jcp
|
||||
f.store.justifiedCheckpoint = bjcp
|
||||
f.store.checkpointsLock.Unlock()
|
||||
}
|
||||
}
|
||||
f.store.checkpointsLock.Unlock()
|
||||
if !features.Get().DisablePullTips {
|
||||
f.updateUnrealizedCheckpoints()
|
||||
}
|
||||
|
||||
@@ -170,8 +170,11 @@ func (s *Store) insert(ctx context.Context,
|
||||
}
|
||||
|
||||
// Update best descendants
|
||||
if err := s.treeRootNode.updateBestDescendant(ctx,
|
||||
s.justifiedCheckpoint.Epoch, s.finalizedCheckpoint.Epoch); err != nil {
|
||||
s.checkpointsLock.RLock()
|
||||
jEpoch := s.justifiedCheckpoint.Epoch
|
||||
fEpoch := s.finalizedCheckpoint.Epoch
|
||||
s.checkpointsLock.RUnlock()
|
||||
if err := s.treeRootNode.updateBestDescendant(ctx, jEpoch, fEpoch); err != nil {
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// This computes validator balance delta from validator votes.
|
||||
// It returns a list of deltas that represents the difference between old balances and new balances.
|
||||
// It returns a list of deltas that represents the difference between old
|
||||
// balances and new balances. This function assumes the caller holds a lock in
|
||||
// Store.nodesLock and Store.votesLock
|
||||
func computeDeltas(
|
||||
ctx context.Context,
|
||||
count int,
|
||||
|
||||
@@ -41,15 +41,14 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
|
||||
}
|
||||
|
||||
// Update store.justified_checkpoint if a better checkpoint on the store.finalized_checkpoint chain
|
||||
f.store.checkpointsLock.Lock()
|
||||
|
||||
f.store.checkpointsLock.RLock()
|
||||
bjcp := f.store.bestJustifiedCheckpoint
|
||||
jcp := f.store.justifiedCheckpoint
|
||||
fcp := f.store.finalizedCheckpoint
|
||||
f.store.checkpointsLock.RUnlock()
|
||||
if bjcp.Epoch > jcp.Epoch {
|
||||
finalizedSlot, err := slots.EpochStart(fcp.Epoch)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -59,15 +58,15 @@ func (f *ForkChoice) NewSlot(ctx context.Context, slot types.Slot) error {
|
||||
// loop call here.
|
||||
r, err := f.AncestorRoot(ctx, bjcp.Root, finalizedSlot)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
if r == fcp.Root {
|
||||
f.store.checkpointsLock.Lock()
|
||||
f.store.prevJustifiedCheckpoint = jcp
|
||||
f.store.justifiedCheckpoint = bjcp
|
||||
f.store.checkpointsLock.Unlock()
|
||||
}
|
||||
}
|
||||
f.store.checkpointsLock.Unlock()
|
||||
if !features.Get().DisablePullTips {
|
||||
f.updateUnrealizedCheckpoints()
|
||||
}
|
||||
|
||||
@@ -188,11 +188,15 @@ func (f *ForkChoice) updateCheckpoints(ctx context.Context, jc, fc *ethpb.Checkp
|
||||
return err
|
||||
}
|
||||
jcRoot := bytesutil.ToBytes32(jc.Root)
|
||||
// release the checkpoints lock here because
|
||||
// AncestorRoot takes a lock on nodes and that can lead
|
||||
// to double locks
|
||||
f.store.checkpointsLock.Unlock()
|
||||
root, err := f.AncestorRoot(ctx, jcRoot, jSlot)
|
||||
if err != nil {
|
||||
f.store.checkpointsLock.Unlock()
|
||||
return err
|
||||
}
|
||||
f.store.checkpointsLock.Lock()
|
||||
if root == currentRoot {
|
||||
f.store.prevJustifiedCheckpoint = f.store.justifiedCheckpoint
|
||||
f.store.justifiedCheckpoint = &forkchoicetypes.Checkpoint{Epoch: jc.Epoch,
|
||||
@@ -285,6 +289,8 @@ func (f *ForkChoice) CommonAncestorRoot(ctx context.Context, r1 [32]byte, r2 [32
|
||||
if r1 == r2 {
|
||||
return r1, nil
|
||||
}
|
||||
f.store.nodesLock.RLock()
|
||||
defer f.store.nodesLock.RUnlock()
|
||||
|
||||
i1, ok := f.store.nodesIndices[r1]
|
||||
if !ok || i1 >= uint64(len(f.store.nodes)) {
|
||||
@@ -406,8 +412,12 @@ func (s *Store) head(ctx context.Context) ([32]byte, error) {
|
||||
|
||||
if !s.viableForHead(bestNode) {
|
||||
s.allTipsAreInvalid = true
|
||||
s.checkpointsLock.RLock()
|
||||
jEpoch := s.justifiedCheckpoint.Epoch
|
||||
fEpoch := s.finalizedCheckpoint.Epoch
|
||||
s.checkpointsLock.RUnlock()
|
||||
return [32]byte{}, fmt.Errorf("head at slot %d with weight %d is not eligible, finalizedEpoch %d != %d, justifiedEpoch %d != %d",
|
||||
bestNode.slot, bestNode.weight/10e9, bestNode.finalizedEpoch, s.finalizedCheckpoint.Epoch, bestNode.justifiedEpoch, s.justifiedCheckpoint.Epoch)
|
||||
bestNode.slot, bestNode.weight/10e9, bestNode.finalizedEpoch, fEpoch, bestNode.justifiedEpoch, jEpoch)
|
||||
}
|
||||
s.allTipsAreInvalid = false
|
||||
|
||||
@@ -426,7 +436,8 @@ func (s *Store) head(ctx context.Context) ([32]byte, error) {
|
||||
return bestNode.root, nil
|
||||
}
|
||||
|
||||
// updateCanonicalNodes updates the canonical nodes mapping given the input block root.
|
||||
// updateCanonicalNodes updates the canonical nodes mapping given the input
|
||||
// block root. This function assumes the caller holds a lock in Store.nodesLock
|
||||
func (s *Store) updateCanonicalNodes(ctx context.Context, root [32]byte) error {
|
||||
ctx, span := trace.StartSpan(ctx, "protoArrayForkChoice.updateCanonicalNodes")
|
||||
defer span.End()
|
||||
@@ -548,14 +559,14 @@ func (s *Store) insert(ctx context.Context,
|
||||
if slot > s.highestReceivedSlot {
|
||||
s.highestReceivedSlot = slot
|
||||
}
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// applyWeightChanges iterates backwards through the nodes in store. It checks all nodes parent
|
||||
// and its best child. For each node, it updates the weight with input delta and
|
||||
// back propagate the nodes' delta to its parents' delta. After scoring changes,
|
||||
// the best child is then updated along with the best descendant.
|
||||
// the best child is then updated along with the best descendant. This function
|
||||
// assumes the caller holds a lock in Store.nodesLock
|
||||
func (s *Store) applyWeightChanges(
|
||||
ctx context.Context, newBalances []uint64, delta []int,
|
||||
) error {
|
||||
@@ -900,6 +911,8 @@ func (f *ForkChoice) Tips() ([][32]byte, []types.Slot) {
|
||||
// store-tracked list. Votes from these validators are not accounted for
|
||||
// in forkchoice.
|
||||
func (f *ForkChoice) InsertSlashedIndex(ctx context.Context, index types.ValidatorIndex) {
|
||||
f.votesLock.RLock()
|
||||
defer f.votesLock.RUnlock()
|
||||
f.store.nodesLock.Lock()
|
||||
defer f.store.nodesLock.Unlock()
|
||||
// return early if the index was already included:
|
||||
@@ -909,9 +922,6 @@ func (f *ForkChoice) InsertSlashedIndex(ctx context.Context, index types.Validat
|
||||
f.store.slashedIndices[index] = true
|
||||
|
||||
// Subtract last vote from this equivocating validator
|
||||
f.votesLock.RLock()
|
||||
defer f.votesLock.RUnlock()
|
||||
|
||||
if index >= types.ValidatorIndex(len(f.balances)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,12 +6,6 @@ datadir: /var/lib/prysm/beacon
|
||||
# http-web3provider: ETH1 API endpoint, eg. http://localhost:8545 for a local geth service on the default port
|
||||
http-web3provider: http://localhost:8545
|
||||
|
||||
# fallback-web3provider: List of backup ETH1 API endpoints, used if above is not working
|
||||
# For example:
|
||||
# fallback-web3provider:
|
||||
# - https://mainnet.infura.io/v3/YOUR-PROJECT-ID
|
||||
# - https://eth-mainnet.alchemyapi.io/v2/YOUR-PROJECT-ID
|
||||
|
||||
|
||||
# Optional tuning parameters
|
||||
# For full list, see https://docs.prylabs.network/docs/prysm-usage/parameters
|
||||
|
||||
@@ -754,8 +754,6 @@ func (bs *Server) GetValidatorPerformance(
|
||||
beforeTransitionBalances := make([]uint64, 0, responseCap)
|
||||
afterTransitionBalances := make([]uint64, 0, responseCap)
|
||||
effectiveBalances := make([]uint64, 0, responseCap)
|
||||
inclusionSlots := make([]types.Slot, 0, responseCap)
|
||||
inclusionDistances := make([]types.Slot, 0, responseCap)
|
||||
correctlyVotedSource := make([]bool, 0, responseCap)
|
||||
correctlyVotedTarget := make([]bool, 0, responseCap)
|
||||
correctlyVotedHead := make([]bool, 0, responseCap)
|
||||
@@ -789,8 +787,6 @@ func (bs *Server) GetValidatorPerformance(
|
||||
|
||||
if headState.Version() == version.Phase0 {
|
||||
correctlyVotedSource = append(correctlyVotedSource, summary.IsPrevEpochAttester)
|
||||
inclusionSlots = append(inclusionSlots, summary.InclusionSlot)
|
||||
inclusionDistances = append(inclusionDistances, summary.InclusionDistance)
|
||||
} else {
|
||||
correctlyVotedSource = append(correctlyVotedSource, summary.IsPrevEpochSourceAttester)
|
||||
inactivityScores = append(inactivityScores, summary.InactivityScore)
|
||||
@@ -806,9 +802,7 @@ func (bs *Server) GetValidatorPerformance(
|
||||
BalancesBeforeEpochTransition: beforeTransitionBalances,
|
||||
BalancesAfterEpochTransition: afterTransitionBalances,
|
||||
MissingValidators: missingValidators,
|
||||
InclusionSlots: inclusionSlots, // Only populated in phase0
|
||||
InclusionDistances: inclusionDistances, // Only populated in phase 0
|
||||
InactivityScores: inactivityScores, // Only populated in Altair
|
||||
InactivityScores: inactivityScores, // Only populated in Altair
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1846,12 +1846,9 @@ func TestGetValidatorPerformance_OK(t *testing.T) {
|
||||
GenesisTimeFetcher: &mock.ChainService{Genesis: time.Now().Add(time.Duration(-1*offset) * time.Second)},
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
||||
}
|
||||
farFuture := params.BeaconConfig().FarFutureSlot
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
PublicKeys: [][]byte{publicKey2[:], publicKey3[:]},
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
InclusionSlots: []types.Slot{farFuture, farFuture},
|
||||
InclusionDistances: []types.Slot{farFuture, farFuture},
|
||||
CorrectlyVotedSource: []bool{false, false},
|
||||
CorrectlyVotedTarget: []bool{false, false},
|
||||
CorrectlyVotedHead: []bool{false, false},
|
||||
@@ -1918,12 +1915,9 @@ func TestGetValidatorPerformance_Indices(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp, precompute.AttestationsDelta, precompute.ProposersDelta)
|
||||
require.NoError(t, err)
|
||||
farFuture := params.BeaconConfig().FarFutureSlot
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
PublicKeys: [][]byte{publicKey2[:], publicKey3[:]},
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
InclusionSlots: []types.Slot{farFuture, farFuture},
|
||||
InclusionDistances: []types.Slot{farFuture, farFuture},
|
||||
CorrectlyVotedSource: []bool{false, false},
|
||||
CorrectlyVotedTarget: []bool{false, false},
|
||||
CorrectlyVotedHead: []bool{false, false},
|
||||
@@ -1991,12 +1985,9 @@ func TestGetValidatorPerformance_IndicesPubkeys(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp, precompute.AttestationsDelta, precompute.ProposersDelta)
|
||||
require.NoError(t, err)
|
||||
farFuture := params.BeaconConfig().FarFutureSlot
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
PublicKeys: [][]byte{publicKey2[:], publicKey3[:]},
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
InclusionSlots: []types.Slot{farFuture, farFuture},
|
||||
InclusionDistances: []types.Slot{farFuture, farFuture},
|
||||
CorrectlyVotedSource: []bool{false, false},
|
||||
CorrectlyVotedTarget: []bool{false, false},
|
||||
CorrectlyVotedHead: []bool{false, false},
|
||||
@@ -2065,8 +2056,6 @@ func TestGetValidatorPerformanceAltair_OK(t *testing.T) {
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
PublicKeys: [][]byte{publicKey2[:], publicKey3[:]},
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
InclusionSlots: nil,
|
||||
InclusionDistances: nil,
|
||||
CorrectlyVotedSource: []bool{false, false},
|
||||
CorrectlyVotedTarget: []bool{false, false},
|
||||
CorrectlyVotedHead: []bool{false, false},
|
||||
@@ -2135,8 +2124,6 @@ func TestGetValidatorPerformanceBellatrix_OK(t *testing.T) {
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
PublicKeys: [][]byte{publicKey2[:], publicKey3[:]},
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
InclusionSlots: nil,
|
||||
InclusionDistances: nil,
|
||||
CorrectlyVotedSource: []bool{false, false},
|
||||
CorrectlyVotedTarget: []bool{false, false},
|
||||
CorrectlyVotedHead: []bool{false, false},
|
||||
|
||||
@@ -190,7 +190,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo
|
||||
continue
|
||||
}
|
||||
if chunkErr := s.chunkBlockWriter(stream, b); chunkErr != nil {
|
||||
log.WithError(chunkErr).Error("Could not send a chunked response")
|
||||
log.WithError(chunkErr).Debug("Could not send a chunked response")
|
||||
s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream)
|
||||
tracing.AnnotateError(span, chunkErr)
|
||||
return chunkErr
|
||||
|
||||
@@ -178,6 +178,7 @@ func (s *Service) Start() {
|
||||
s.processPendingBlocksQueue()
|
||||
s.processPendingAttsQueue()
|
||||
s.maintainPeerStatuses()
|
||||
s.resyncIfBehind()
|
||||
|
||||
// Update sync metrics.
|
||||
async.RunEvery(s.ctx, syncMetricsInterval, s.updateMetrics)
|
||||
|
||||
@@ -13,6 +13,7 @@ go_library(
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
|
||||
"github.com/prysmaticlabs/prysm/v3/io/file"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -64,7 +65,8 @@ func parseJWTSecretFromFile(c *cli.Context) ([]byte, error) {
|
||||
}
|
||||
|
||||
func parseExecutionChainEndpoint(c *cli.Context) (string, error) {
|
||||
if c.String(flags.ExecutionEngineEndpoint.Name) == "" {
|
||||
aliasUsed := c.IsSet(flags.HTTPWeb3ProviderFlag.Name)
|
||||
if c.String(flags.ExecutionEngineEndpoint.Name) == "" && !aliasUsed {
|
||||
return "", fmt.Errorf(
|
||||
"you need to specify %s to provide a connection endpoint to an Ethereum execution client "+
|
||||
"for your Prysm beacon node. This is a requirement for running a node. You can read more about "+
|
||||
@@ -73,5 +75,12 @@ func parseExecutionChainEndpoint(c *cli.Context) (string, error) {
|
||||
flags.ExecutionEngineEndpoint.Name,
|
||||
)
|
||||
}
|
||||
// If users only declare the deprecated flag without setting the execution engine
|
||||
// flag, we fallback to using the deprecated flag value.
|
||||
if aliasUsed && !c.IsSet(flags.ExecutionEngineEndpoint.Name) {
|
||||
log.Warnf("The %s flag has been deprecated and will be removed in a future release,"+
|
||||
"please use the execution endpoint flag instead %s", flags.HTTPWeb3ProviderFlag.Name, flags.ExecutionEngineEndpoint.Name)
|
||||
return c.String(flags.HTTPWeb3ProviderFlag.Name), nil
|
||||
}
|
||||
return c.String(flags.ExecutionEngineEndpoint.Name), nil
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ var (
|
||||
Usage: "An execution client http endpoint. Can contain auth header as well in the format",
|
||||
Value: "http://localhost:8551",
|
||||
}
|
||||
// Deprecated: HTTPWeb3ProviderFlag is a deprecated flag and is an alias for the ExecutionEngineEndpoint flag.
|
||||
HTTPWeb3ProviderFlag = &cli.StringFlag{
|
||||
Name: "http-web3provider",
|
||||
Usage: "DEPRECATED: A mainchain web3 provider string http endpoint. Can contain auth header as well in the format --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Basic xxx\" for project secret (base64 encoded) and --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Bearer xxx\" for jwt use",
|
||||
Value: "http://localhost:8551",
|
||||
Hidden: true,
|
||||
}
|
||||
// ExecutionJWTSecretFlag provides a path to a file containing a hex-encoded string representing a 32 byte secret
|
||||
// used to authenticate with an execution node via HTTP. This is required if using an HTTP connection, otherwise all requests
|
||||
// to execution nodes for consensus-related calls will fail. This is not required if using an IPC connection.
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
var appFlags = []cli.Flag{
|
||||
flags.DepositContractFlag,
|
||||
flags.ExecutionEngineEndpoint,
|
||||
flags.HTTPWeb3ProviderFlag,
|
||||
flags.ExecutionJWTSecretFlag,
|
||||
flags.RPCHost,
|
||||
flags.RPCPort,
|
||||
@@ -231,6 +232,13 @@ func startNode(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
logrus.SetLevel(level)
|
||||
// Set libp2p logger to only panic logs for the info level.
|
||||
golog.SetAllLoggers(golog.LevelPanic)
|
||||
|
||||
if level == logrus.DebugLevel {
|
||||
// Set libp2p logger to error logs for the debug level.
|
||||
golog.SetAllLoggers(golog.LevelError)
|
||||
}
|
||||
if level == logrus.TraceLevel {
|
||||
// libp2p specific logging.
|
||||
golog.SetAllLoggers(golog.LevelDebug)
|
||||
|
||||
@@ -107,6 +107,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
flags.GRPCGatewayPort,
|
||||
flags.GPRCGatewayCorsDomain,
|
||||
flags.ExecutionEngineEndpoint,
|
||||
flags.HTTPWeb3ProviderFlag,
|
||||
flags.ExecutionJWTSecretFlag,
|
||||
flags.SetGCPercent,
|
||||
flags.SlotsPerArchivedPoint,
|
||||
|
||||
@@ -96,31 +96,3 @@ func ExpandSingleEndpointIfFile(ctx *cli.Context, flag *cli.StringFlag) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExpandWeb3EndpointsIfFile expands the path for --fallback-web3provider if specified as a file.
|
||||
func ExpandWeb3EndpointsIfFile(ctx *cli.Context, flags *cli.StringSliceFlag) error {
|
||||
// Return early if no flag value is set.
|
||||
if !ctx.IsSet(flags.Name) {
|
||||
return nil
|
||||
}
|
||||
rawFlags := ctx.StringSlice(flags.Name)
|
||||
for i, rawValue := range rawFlags {
|
||||
switch {
|
||||
case strings.HasPrefix(rawValue, "http://"):
|
||||
case strings.HasPrefix(rawValue, "https://"):
|
||||
case strings.HasPrefix(rawValue, "ws://"):
|
||||
case strings.HasPrefix(rawValue, "wss://"):
|
||||
default:
|
||||
web3endpoint, err := file.ExpandPath(rawValue)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not expand path for %s", rawValue)
|
||||
}
|
||||
// Given that rawFlags is a pointer this will replace the unexpanded path
|
||||
// with the expanded one. Also there is no easy way to replace the string
|
||||
// slice flag value compared to other flag types. This is why we resort to
|
||||
// replacing it like this.
|
||||
rawFlags[i] = web3endpoint
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -111,43 +111,3 @@ func TestExpandSingleEndpointIfFile(t *testing.T) {
|
||||
require.NoError(t, ExpandSingleEndpointIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.Equal(t, curentdir+"/path.ipc", context.String(HTTPWeb3ProviderFlag.Name))
|
||||
}
|
||||
|
||||
func TestExpandWeb3EndpointsIfFile(t *testing.T) {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
HTTPWeb3ProviderFlag := &cli.StringSliceFlag{Name: "fallback-web3provider", Value: cli.NewStringSlice()}
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context := cli.NewContext(&app, set, nil)
|
||||
// with nothing set
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// with url scheme
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "http://localhost:8545"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{"http://localhost:8545"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// reset context
|
||||
set = flag.NewFlagSet("test", 0)
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context = cli.NewContext(&app, set, nil)
|
||||
|
||||
// relative user home path
|
||||
usr, err := user.Current()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "~/relative/path.ipc"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{usr.HomeDir + "/relative/path.ipc"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// reset context
|
||||
set = flag.NewFlagSet("test", 0)
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context = cli.NewContext(&app, set, nil)
|
||||
|
||||
// current dir path
|
||||
curentdir, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "./path.ipc"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{curentdir + "/path.ipc"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ go_library(
|
||||
deps = [
|
||||
"//cmd/prysmctl/checkpoint:go_default_library",
|
||||
"//cmd/prysmctl/p2p:go_default_library",
|
||||
"//cmd/prysmctl/testnet:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/checkpoint"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/p2p"
|
||||
"github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/testnet"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@@ -23,5 +24,6 @@ func main() {
|
||||
|
||||
func init() {
|
||||
prysmctlCommands = append(prysmctlCommands, checkpoint.Commands...)
|
||||
prysmctlCommands = append(prysmctlCommands, testnet.Commands...)
|
||||
prysmctlCommands = append(prysmctlCommands, p2p.Commands...)
|
||||
}
|
||||
|
||||
34
cmd/prysmctl/testnet/BUILD.bazel
Normal file
34
cmd/prysmctl/testnet/BUILD.bazel
Normal file
@@ -0,0 +1,34 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"generate_genesis.go",
|
||||
"testnet.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/testnet",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//config/params:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/interop:go_default_library",
|
||||
"@com_github_ghodss_yaml//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["generate_genesis_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//crypto/bls:go_default_library",
|
||||
"//runtime/interop:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
],
|
||||
)
|
||||
265
cmd/prysmctl/testnet/generate_genesis.go
Normal file
265
cmd/prysmctl/testnet/generate_genesis.go
Normal file
@@ -0,0 +1,265 @@
|
||||
package testnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/pkg/errors"
|
||||
fastssz "github.com/prysmaticlabs/fastssz"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/io/file"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/interop"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
generateGenesisStateFlags = struct {
|
||||
DepositJsonFile string
|
||||
ChainConfigFile string
|
||||
ConfigName string
|
||||
NumValidators uint64
|
||||
GenesisTime uint64
|
||||
OutputSSZ string
|
||||
OutputJSON string
|
||||
OutputYaml string
|
||||
}{}
|
||||
log = logrus.WithField("prefix", "genesis")
|
||||
outputSSZFlag = &cli.StringFlag{
|
||||
Name: "output-ssz",
|
||||
Destination: &generateGenesisStateFlags.OutputSSZ,
|
||||
Usage: "Output filename of the SSZ marshaling of the generated genesis state",
|
||||
Value: "",
|
||||
}
|
||||
outputYamlFlag = &cli.StringFlag{
|
||||
Name: "output-yaml",
|
||||
Destination: &generateGenesisStateFlags.OutputYaml,
|
||||
Usage: "Output filename of the YAML marshaling of the generated genesis state",
|
||||
Value: "",
|
||||
}
|
||||
outputJsonFlag = &cli.StringFlag{
|
||||
Name: "output-json",
|
||||
Destination: &generateGenesisStateFlags.OutputJSON,
|
||||
Usage: "Output filename of the JSON marshaling of the generated genesis state",
|
||||
Value: "",
|
||||
}
|
||||
generateGenesisStateCmd = &cli.Command{
|
||||
Name: "generate-genesis",
|
||||
Usage: "Generate a beacon chain genesis state",
|
||||
Action: cliActionGenerateGenesisState,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "chain-config-file",
|
||||
Destination: &generateGenesisStateFlags.ChainConfigFile,
|
||||
Usage: "The path to a YAML file with chain config values",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "deposit-json-file",
|
||||
Destination: &generateGenesisStateFlags.DepositJsonFile,
|
||||
Usage: "Path to deposit_data.json file generated by the staking-deposit-cli tool for optionally specifying validators in genesis state",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config-name",
|
||||
Usage: "Config kind to be used for generating the genesis state. Default: mainnet. Options include mainnet, interop, minimal, prater, ropsten, sepolia. --chain-config-file will override this flag.",
|
||||
Destination: &generateGenesisStateFlags.ConfigName,
|
||||
Value: params.MainnetName,
|
||||
},
|
||||
&cli.Uint64Flag{
|
||||
Name: "num-validators",
|
||||
Usage: "Number of validators to deterministically generate in the genesis state",
|
||||
Destination: &generateGenesisStateFlags.NumValidators,
|
||||
Required: true,
|
||||
},
|
||||
&cli.Uint64Flag{
|
||||
Name: "genesis-time",
|
||||
Destination: &generateGenesisStateFlags.GenesisTime,
|
||||
Usage: "Unix timestamp seconds used as the genesis time in the genesis state. If unset, defaults to now()",
|
||||
},
|
||||
outputSSZFlag,
|
||||
outputYamlFlag,
|
||||
outputJsonFlag,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Represents a json object of hex string and uint64 values for
|
||||
// validators on Ethereum. This file can be generated using the official staking-deposit-cli.
|
||||
type depositDataJSON struct {
|
||||
PubKey string `json:"pubkey"`
|
||||
Amount uint64 `json:"amount"`
|
||||
WithdrawalCredentials string `json:"withdrawal_credentials"`
|
||||
DepositDataRoot string `json:"deposit_data_root"`
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
func cliActionGenerateGenesisState(cliCtx *cli.Context) error {
|
||||
if generateGenesisStateFlags.GenesisTime == 0 {
|
||||
log.Info("No genesis time specified, defaulting to now()")
|
||||
}
|
||||
outputJson := generateGenesisStateFlags.OutputJSON
|
||||
outputYaml := generateGenesisStateFlags.OutputYaml
|
||||
outputSSZ := generateGenesisStateFlags.OutputSSZ
|
||||
noOutputFlag := outputSSZ == "" && outputJson == "" && outputYaml == ""
|
||||
if noOutputFlag {
|
||||
return fmt.Errorf(
|
||||
"no %s, %s, %s flag(s) specified. At least one is required",
|
||||
outputJsonFlag.Name,
|
||||
outputYamlFlag.Name,
|
||||
outputSSZFlag.Name,
|
||||
)
|
||||
}
|
||||
if err := setGlobalParams(); err != nil {
|
||||
return fmt.Errorf("could not set config params: %v", err)
|
||||
}
|
||||
genesisState, err := generateGenesis(cliCtx.Context)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not generate genesis state: %v", err)
|
||||
}
|
||||
if outputJson != "" {
|
||||
if err := writeToOutputFile(outputJson, genesisState, json.Marshal); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if outputYaml != "" {
|
||||
if err := writeToOutputFile(outputJson, genesisState, yaml.Marshal); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if outputSSZ != "" {
|
||||
marshalFn := func(o interface{}) ([]byte, error) {
|
||||
marshaler, ok := o.(fastssz.Marshaler)
|
||||
if !ok {
|
||||
return nil, errors.New("not a marshaler")
|
||||
}
|
||||
return marshaler.MarshalSSZ()
|
||||
}
|
||||
if err := writeToOutputFile(outputSSZ, genesisState, marshalFn); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.Info("Command completed")
|
||||
return nil
|
||||
}
|
||||
|
||||
func setGlobalParams() error {
|
||||
chainConfigFile := generateGenesisStateFlags.ChainConfigFile
|
||||
if chainConfigFile != "" {
|
||||
log.Infof("Specified a chain config file: %s", chainConfigFile)
|
||||
return params.LoadChainConfigFile(chainConfigFile, nil)
|
||||
}
|
||||
cfg, err := params.ByName(generateGenesisStateFlags.ConfigName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to find config using name %s: %v", generateGenesisStateFlags.ConfigName, err)
|
||||
}
|
||||
return params.SetActive(cfg.Copy())
|
||||
}
|
||||
|
||||
func generateGenesis(ctx context.Context) (*ethpb.BeaconState, error) {
|
||||
genesisTime := generateGenesisStateFlags.GenesisTime
|
||||
numValidators := generateGenesisStateFlags.NumValidators
|
||||
depositJsonFile := generateGenesisStateFlags.DepositJsonFile
|
||||
if depositJsonFile != "" {
|
||||
expanded, err := file.ExpandPath(depositJsonFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inputJSON, err := os.Open(expanded) // #nosec G304
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if err := inputJSON.Close(); err != nil {
|
||||
log.WithError(err).Printf("Could not close file %s", depositJsonFile)
|
||||
}
|
||||
}()
|
||||
log.Printf("Generating genesis state from input JSON deposit data %s", depositJsonFile)
|
||||
return genesisStateFromJSONValidators(ctx, inputJSON, genesisTime)
|
||||
}
|
||||
if numValidators == 0 {
|
||||
return nil, fmt.Errorf(
|
||||
"expected --num-validators > 0 to have been provided",
|
||||
)
|
||||
}
|
||||
// If no JSON input is specified, we create the state deterministically from interop keys.
|
||||
genesisState, _, err := interop.GenerateGenesisState(ctx, genesisTime, numValidators)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return genesisState, err
|
||||
}
|
||||
|
||||
func genesisStateFromJSONValidators(ctx context.Context, r io.Reader, genesisTime uint64) (*ethpb.BeaconState, error) {
|
||||
enc, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var depositJSON []*depositDataJSON
|
||||
if err := json.Unmarshal(enc, &depositJSON); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
depositDataList := make([]*ethpb.Deposit_Data, len(depositJSON))
|
||||
depositDataRoots := make([][]byte, len(depositJSON))
|
||||
for i, val := range depositJSON {
|
||||
data, dataRootBytes, err := depositJSONToDepositData(val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
depositDataList[i] = data
|
||||
depositDataRoots[i] = dataRootBytes
|
||||
}
|
||||
beaconState, _, err := interop.GenerateGenesisStateFromDepositData(ctx, genesisTime, depositDataList, depositDataRoots)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return beaconState, nil
|
||||
}
|
||||
|
||||
func depositJSONToDepositData(input *depositDataJSON) (depositData *ethpb.Deposit_Data, dataRoot []byte, err error) {
|
||||
pubKeyBytes, err := hex.DecodeString(strings.TrimPrefix(input.PubKey, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
withdrawalbytes, err := hex.DecodeString(strings.TrimPrefix(input.WithdrawalCredentials, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
signatureBytes, err := hex.DecodeString(strings.TrimPrefix(input.Signature, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dataRootBytes, err := hex.DecodeString(strings.TrimPrefix(input.DepositDataRoot, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
depositData = ðpb.Deposit_Data{
|
||||
PublicKey: pubKeyBytes,
|
||||
WithdrawalCredentials: withdrawalbytes,
|
||||
Amount: input.Amount,
|
||||
Signature: signatureBytes,
|
||||
}
|
||||
dataRoot = dataRootBytes
|
||||
return
|
||||
}
|
||||
|
||||
func writeToOutputFile(
|
||||
fPath string,
|
||||
data interface{},
|
||||
marshalFn func(o interface{}) ([]byte, error),
|
||||
) error {
|
||||
encoded, err := marshalFn(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.WriteFile(fPath, encoded); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Done writing genesis state to %s", fPath)
|
||||
return nil
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package main
|
||||
package testnet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
@@ -17,8 +18,9 @@ func Test_genesisStateFromJSONValidators(t *testing.T) {
|
||||
jsonData := createGenesisDepositData(t, numKeys)
|
||||
jsonInput, err := json.Marshal(jsonData)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
genesisState, err := genesisStateFromJSONValidators(
|
||||
bytes.NewReader(jsonInput), 0, /* genesis time defaults to time.Now() */
|
||||
ctx, bytes.NewReader(jsonInput), 0, /* genesis time defaults to time.Now() */
|
||||
)
|
||||
require.NoError(t, err)
|
||||
for i, val := range genesisState.Validators {
|
||||
@@ -26,7 +28,7 @@ func Test_genesisStateFromJSONValidators(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func createGenesisDepositData(t *testing.T, numKeys int) []*DepositDataJSON {
|
||||
func createGenesisDepositData(t *testing.T, numKeys int) []*depositDataJSON {
|
||||
pubKeys := make([]bls.PublicKey, numKeys)
|
||||
privKeys := make([]bls.SecretKey, numKeys)
|
||||
for i := 0; i < numKeys; i++ {
|
||||
@@ -37,11 +39,11 @@ func createGenesisDepositData(t *testing.T, numKeys int) []*DepositDataJSON {
|
||||
}
|
||||
dataList, _, err := interop.DepositDataFromKeys(privKeys, pubKeys)
|
||||
require.NoError(t, err)
|
||||
jsonData := make([]*DepositDataJSON, numKeys)
|
||||
jsonData := make([]*depositDataJSON, numKeys)
|
||||
for i := 0; i < numKeys; i++ {
|
||||
dataRoot, err := dataList[i].HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
jsonData[i] = &DepositDataJSON{
|
||||
jsonData[i] = &depositDataJSON{
|
||||
PubKey: fmt.Sprintf("%#x", dataList[i].PublicKey),
|
||||
Amount: dataList[i].Amount,
|
||||
WithdrawalCredentials: fmt.Sprintf("%#x", dataList[i].WithdrawalCredentials),
|
||||
13
cmd/prysmctl/testnet/testnet.go
Normal file
13
cmd/prysmctl/testnet/testnet.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package testnet
|
||||
|
||||
import "github.com/urfave/cli/v2"
|
||||
|
||||
var Commands = []*cli.Command{
|
||||
{
|
||||
Name: "testnet",
|
||||
Usage: "commands for dealing with Ethereum beacon chain testnets",
|
||||
Subcommands: []*cli.Command{
|
||||
generateGenesisStateCmd,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
package flags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
@@ -340,16 +341,17 @@ var (
|
||||
|
||||
// EnableBuilderFlag enables the periodic validator registration API calls that will update the custom builder with validator settings.
|
||||
EnableBuilderFlag = &cli.BoolFlag{
|
||||
Name: "enable-builder",
|
||||
Usage: "Enables Builder validator registration APIs for the validator client to update settings such as fee recipient and gas limit. Note* this flag is not required if using proposer settings config file",
|
||||
Value: false,
|
||||
Name: "enable-builder",
|
||||
Usage: "Enables Builder validator registration APIs for the validator client to update settings such as fee recipient and gas limit. Note* this flag is not required if using proposer settings config file",
|
||||
Value: false,
|
||||
Aliases: []string{"enable-validator-registration"},
|
||||
}
|
||||
|
||||
// BuilderGasLimitFlag defines the gas limit for the builder to use for constructing a payload.
|
||||
BuilderGasLimitFlag = &cli.IntFlag{
|
||||
BuilderGasLimitFlag = &cli.StringFlag{
|
||||
Name: "suggested-gas-limit",
|
||||
Usage: "Sets gas limit for the builder to use for constructing a payload for all the validators",
|
||||
Value: int(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
Value: fmt.Sprint(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -12,8 +12,84 @@ var (
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedBackupWebHookFlag = &cli.BoolFlag{
|
||||
Name: "enable-db-backup-webhook",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedBoltMmapFlag = &cli.StringFlag{
|
||||
Name: "bolt-mmap-initial-size",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedDisableDiscV5Flag = &cli.BoolFlag{
|
||||
Name: "disable-discv5",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedDisableAttHistoryCacheFlag = &cli.BoolFlag{
|
||||
Name: "disable-attesting-history-db-cache",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedEnableVectorizedHtr = &cli.BoolFlag{
|
||||
Name: "enable-vectorized-htr",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedEnablePeerScorer = &cli.BoolFlag{
|
||||
Name: "enable-peer-scorer",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedEnableForkchoiceDoublyLinkedTree = &cli.BoolFlag{
|
||||
Name: "enable-forkchoice-doubly-linked-tree",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedDutyCountdown = &cli.BoolFlag{
|
||||
Name: "enable-duty-count-down",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedHeadSync = &cli.BoolFlag{
|
||||
Name: "head-sync",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedGossipBatchAggregation = &cli.BoolFlag{
|
||||
Name: "enable-gossip-batch-aggregation",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedEnableLargerGossipHistory = &cli.BoolFlag{
|
||||
Name: "enable-larger-gossip-history",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedFallbackProvider = &cli.StringFlag{
|
||||
Name: "fallback-web3provider",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
)
|
||||
|
||||
// Deprecated flags for both the beacon node and validator client.
|
||||
var deprecatedFlags = []cli.Flag{
|
||||
exampleDeprecatedFeatureFlag,
|
||||
deprecatedBoltMmapFlag,
|
||||
deprecatedDisableDiscV5Flag,
|
||||
deprecatedDisableAttHistoryCacheFlag,
|
||||
deprecatedEnableVectorizedHtr,
|
||||
deprecatedEnablePeerScorer,
|
||||
deprecatedEnableForkchoiceDoublyLinkedTree,
|
||||
deprecatedDutyCountdown,
|
||||
deprecatedHeadSync,
|
||||
deprecatedGossipBatchAggregation,
|
||||
deprecatedEnableLargerGossipHistory,
|
||||
deprecatedFallbackProvider,
|
||||
}
|
||||
|
||||
var deprecatedBeaconFlags = []cli.Flag{
|
||||
deprecatedBackupWebHookFlag,
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ var E2EValidatorFlags = []string{
|
||||
}
|
||||
|
||||
// BeaconChainFlags contains a list of all the feature flags that apply to the beacon-chain client.
|
||||
var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
|
||||
var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []cli.Flag{
|
||||
devModeFlag,
|
||||
writeSSZStateTransitionsFlag,
|
||||
disableGRPCConnectionLogging,
|
||||
@@ -156,7 +156,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
|
||||
disableForkChoiceDoublyLinkedTree,
|
||||
disableGossipBatchAggregation,
|
||||
EnableOnlyBlindedBeaconBlocks,
|
||||
}...)
|
||||
}...)...)
|
||||
|
||||
// E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.
|
||||
var E2EBeaconChainFlags = []string{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package validator_service_config
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
@@ -25,10 +27,41 @@ type ProposerOptionPayload struct {
|
||||
// GasLimit is a number set to help the network decide on the maximum gas in each block.
|
||||
type BuilderConfig struct {
|
||||
Enabled bool `json:"enabled" yaml:"enabled"`
|
||||
GasLimit uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
|
||||
GasLimit Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
|
||||
Relays []string `json:"relays" yaml:"relays"`
|
||||
}
|
||||
|
||||
type Uint64 uint64
|
||||
|
||||
func (u *Uint64) UnmarshalJSON(bs []byte) error {
|
||||
str := string(bs) // Parse plain numbers directly.
|
||||
if bs[0] == '"' && bs[len(bs)-1] == '"' {
|
||||
// Unwrap the quotes from string numbers.
|
||||
str = string(bs[1 : len(bs)-1])
|
||||
}
|
||||
x, err := strconv.ParseUint(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*u = Uint64(x)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var str string
|
||||
err := unmarshal(&str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
x, err := strconv.ParseUint(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*u = Uint64(x)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProposerSettings is a Prysm internal representation of the fee recipient config on the validator client.
|
||||
// ProposerSettingsPayload maps to ProposerSettings on import through the CLI.
|
||||
type ProposerSettings struct {
|
||||
|
||||
372
proto/prysm/v1alpha1/slasher.pb.go
generated
372
proto/prysm/v1alpha1/slasher.pb.go
generated
@@ -11,7 +11,6 @@ import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield"
|
||||
github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
_ "github.com/prysmaticlabs/prysm/v3/proto/eth/ext"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
@@ -280,173 +279,6 @@ func (x *HighestAttestation) GetHighestTargetEpoch() github_com_prysmaticlabs_pr
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch(0)
|
||||
}
|
||||
|
||||
type ProposalHistory struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Deprecated: Do not use.
|
||||
EpochBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=epoch_bits,json=epochBits,proto3" json:"epoch_bits,omitempty" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitlist"`
|
||||
// Deprecated: Do not use.
|
||||
LatestEpochWritten github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch `protobuf:"varint,2,opt,name=latest_epoch_written,json=latestEpochWritten,proto3" json:"latest_epoch_written,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"`
|
||||
}
|
||||
|
||||
func (x *ProposalHistory) Reset() {
|
||||
*x = ProposalHistory{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ProposalHistory) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProposalHistory) ProtoMessage() {}
|
||||
|
||||
func (x *ProposalHistory) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProposalHistory.ProtoReflect.Descriptor instead.
|
||||
func (*ProposalHistory) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_slasher_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *ProposalHistory) GetEpochBits() github_com_prysmaticlabs_go_bitfield.Bitlist {
|
||||
if x != nil {
|
||||
return x.EpochBits
|
||||
}
|
||||
return github_com_prysmaticlabs_go_bitfield.Bitlist(nil)
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *ProposalHistory) GetLatestEpochWritten() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch {
|
||||
if x != nil {
|
||||
return x.LatestEpochWritten
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch(0)
|
||||
}
|
||||
|
||||
type Slashable struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Deprecated: Do not use.
|
||||
Slashable bool `protobuf:"varint,1,opt,name=slashable,proto3" json:"slashable,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Slashable) Reset() {
|
||||
*x = Slashable{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Slashable) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Slashable) ProtoMessage() {}
|
||||
|
||||
func (x *Slashable) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Slashable.ProtoReflect.Descriptor instead.
|
||||
func (*Slashable) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_slasher_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *Slashable) GetSlashable() bool {
|
||||
if x != nil {
|
||||
return x.Slashable
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type AttestationHistory struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Deprecated: Do not use.
|
||||
TargetToSource map[uint64]uint64 `protobuf:"bytes,1,rep,name=target_to_source,json=targetToSource,proto3" json:"target_to_source,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
// Deprecated: Do not use.
|
||||
LatestEpochWritten github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch `protobuf:"varint,2,opt,name=latest_epoch_written,json=latestEpochWritten,proto3" json:"latest_epoch_written,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"`
|
||||
}
|
||||
|
||||
func (x *AttestationHistory) Reset() {
|
||||
*x = AttestationHistory{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AttestationHistory) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AttestationHistory) ProtoMessage() {}
|
||||
|
||||
func (x *AttestationHistory) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_slasher_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AttestationHistory.ProtoReflect.Descriptor instead.
|
||||
func (*AttestationHistory) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_slasher_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *AttestationHistory) GetTargetToSource() map[uint64]uint64 {
|
||||
if x != nil {
|
||||
return x.TargetToSource
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *AttestationHistory) GetLatestEpochWritten() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch {
|
||||
if x != nil {
|
||||
return x.LatestEpochWritten
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Epoch(0)
|
||||
}
|
||||
|
||||
var File_proto_prysm_v1alpha1_slasher_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_prysm_v1alpha1_slasher_proto_rawDesc = []byte{
|
||||
@@ -505,87 +337,50 @@ var file_proto_prysm_v1alpha1_slasher_proto_rawDesc = []byte{
|
||||
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, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x12,
|
||||
0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x45, 0x70, 0x6f,
|
||||
0x63, 0x68, 0x22, 0xe0, 0x01, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x48,
|
||||
0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x51, 0x0a, 0x0a, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f,
|
||||
0x62, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x32, 0x18, 0x01, 0x82, 0xb5,
|
||||
0x18, 0x2c, 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, 0x67, 0x6f, 0x2d, 0x62, 0x69,
|
||||
0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x09,
|
||||
0x65, 0x70, 0x6f, 0x63, 0x68, 0x42, 0x69, 0x74, 0x73, 0x12, 0x7a, 0x0a, 0x14, 0x6c, 0x61, 0x74,
|
||||
0x65, 0x73, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x77, 0x72, 0x69, 0x74, 0x74, 0x65,
|
||||
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x48, 0x18, 0x01, 0x82, 0xb5, 0x18, 0x42, 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, 0x45, 0x70, 0x6f, 0x63,
|
||||
0x68, 0x52, 0x12, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x57, 0x72,
|
||||
0x69, 0x74, 0x74, 0x65, 0x6e, 0x22, 0x2d, 0x0a, 0x09, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x12, 0x20, 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x22, 0xc0, 0x02, 0x0a, 0x12, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x6b, 0x0a, 0x10, 0x74,
|
||||
0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x6f, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18,
|
||||
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79,
|
||||
0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45,
|
||||
0x6e, 0x74, 0x72, 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
|
||||
0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x7a, 0x0a, 0x14, 0x6c, 0x61, 0x74, 0x65,
|
||||
0x73, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x48, 0x18, 0x01, 0x82, 0xb5, 0x18, 0x42, 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, 0x45, 0x70, 0x6f, 0x63, 0x68,
|
||||
0x52, 0x12, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x57, 0x72, 0x69,
|
||||
0x74, 0x74, 0x65, 0x6e, 0x1a, 0x41, 0x0a, 0x13, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x6f,
|
||||
0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61,
|
||||
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x90, 0x04, 0x0a, 0x07, 0x53, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x65, 0x72, 0x12, 0xad, 0x01, 0x0a, 0x16, 0x49, 0x73, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x63, 0x68, 0x32, 0x90, 0x04, 0x0a, 0x07, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x12, 0xad,
|
||||
0x01, 0x0a, 0x16, 0x49, 0x73, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69,
|
||||
0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93,
|
||||
0x02, 0x31, 0x22, 0x2c, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x3a, 0x01, 0x2a, 0x12, 0xa3, 0x01, 0x0a, 0x10, 0x49, 0x73, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e,
|
||||
0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
||||
0x28, 0x12, 0x26, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f,
|
||||
0x73, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65, 0x12, 0xae, 0x01, 0x0a, 0x13, 0x48, 0x69,
|
||||
0x67, 0x68, 0x65, 0x73, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x12, 0x30, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x67, 0x68, 0x65, 0x73,
|
||||
0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x67, 0x68,
|
||||
0x65, 0x73, 0x74, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x6c,
|
||||
0x61, 0x73, 0x68, 0x65, 0x72, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2f, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x97, 0x01, 0x0a, 0x19, 0x6f,
|
||||
0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x65,
|
||||
0x72, 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, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x31, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x74, 0x74,
|
||||
0x65, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x22, 0x2c, 0x2f,
|
||||
0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x6c, 0x61,
|
||||
0x73, 0x68, 0x65, 0x72, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0xa3,
|
||||
0x01, 0x0a, 0x10, 0x49, 0x73, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x12, 0x2e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e,
|
||||
0x65, 0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61,
|
||||
0x64, 0x65, 0x72, 0x1a, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70,
|
||||
0x6f, 0x73, 0x65, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x65, 0x72, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x12, 0xae, 0x01, 0x0a, 0x13, 0x48, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74,
|
||||
0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x30, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x41, 0x74, 0x74, 0x65,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x41, 0x74,
|
||||
0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a, 0x2f, 0x65, 0x74, 0x68, 0x2f,
|
||||
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72,
|
||||
0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x68, 0x69,
|
||||
0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x97, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70,
|
||||
0x68, 0x61, 0x31, 0x42, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x72, 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, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa,
|
||||
0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -600,38 +395,33 @@ func file_proto_prysm_v1alpha1_slasher_proto_rawDescGZIP() []byte {
|
||||
return file_proto_prysm_v1alpha1_slasher_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_prysm_v1alpha1_slasher_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_proto_prysm_v1alpha1_slasher_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_proto_prysm_v1alpha1_slasher_proto_goTypes = []interface{}{
|
||||
(*AttesterSlashingResponse)(nil), // 0: ethereum.eth.v1alpha1.AttesterSlashingResponse
|
||||
(*ProposerSlashingResponse)(nil), // 1: ethereum.eth.v1alpha1.ProposerSlashingResponse
|
||||
(*HighestAttestationRequest)(nil), // 2: ethereum.eth.v1alpha1.HighestAttestationRequest
|
||||
(*HighestAttestationResponse)(nil), // 3: ethereum.eth.v1alpha1.HighestAttestationResponse
|
||||
(*HighestAttestation)(nil), // 4: ethereum.eth.v1alpha1.HighestAttestation
|
||||
(*ProposalHistory)(nil), // 5: ethereum.eth.v1alpha1.ProposalHistory
|
||||
(*Slashable)(nil), // 6: ethereum.eth.v1alpha1.Slashable
|
||||
(*AttestationHistory)(nil), // 7: ethereum.eth.v1alpha1.AttestationHistory
|
||||
nil, // 8: ethereum.eth.v1alpha1.AttestationHistory.TargetToSourceEntry
|
||||
(*AttesterSlashing)(nil), // 9: ethereum.eth.v1alpha1.AttesterSlashing
|
||||
(*ProposerSlashing)(nil), // 10: ethereum.eth.v1alpha1.ProposerSlashing
|
||||
(*IndexedAttestation)(nil), // 11: ethereum.eth.v1alpha1.IndexedAttestation
|
||||
(*SignedBeaconBlockHeader)(nil), // 12: ethereum.eth.v1alpha1.SignedBeaconBlockHeader
|
||||
(*AttesterSlashing)(nil), // 5: ethereum.eth.v1alpha1.AttesterSlashing
|
||||
(*ProposerSlashing)(nil), // 6: ethereum.eth.v1alpha1.ProposerSlashing
|
||||
(*IndexedAttestation)(nil), // 7: ethereum.eth.v1alpha1.IndexedAttestation
|
||||
(*SignedBeaconBlockHeader)(nil), // 8: ethereum.eth.v1alpha1.SignedBeaconBlockHeader
|
||||
}
|
||||
var file_proto_prysm_v1alpha1_slasher_proto_depIdxs = []int32{
|
||||
9, // 0: ethereum.eth.v1alpha1.AttesterSlashingResponse.attester_slashings:type_name -> ethereum.eth.v1alpha1.AttesterSlashing
|
||||
10, // 1: ethereum.eth.v1alpha1.ProposerSlashingResponse.proposer_slashings:type_name -> ethereum.eth.v1alpha1.ProposerSlashing
|
||||
4, // 2: ethereum.eth.v1alpha1.HighestAttestationResponse.attestations:type_name -> ethereum.eth.v1alpha1.HighestAttestation
|
||||
8, // 3: ethereum.eth.v1alpha1.AttestationHistory.target_to_source:type_name -> ethereum.eth.v1alpha1.AttestationHistory.TargetToSourceEntry
|
||||
11, // 4: ethereum.eth.v1alpha1.Slasher.IsSlashableAttestation:input_type -> ethereum.eth.v1alpha1.IndexedAttestation
|
||||
12, // 5: ethereum.eth.v1alpha1.Slasher.IsSlashableBlock:input_type -> ethereum.eth.v1alpha1.SignedBeaconBlockHeader
|
||||
2, // 6: ethereum.eth.v1alpha1.Slasher.HighestAttestations:input_type -> ethereum.eth.v1alpha1.HighestAttestationRequest
|
||||
0, // 7: ethereum.eth.v1alpha1.Slasher.IsSlashableAttestation:output_type -> ethereum.eth.v1alpha1.AttesterSlashingResponse
|
||||
1, // 8: ethereum.eth.v1alpha1.Slasher.IsSlashableBlock:output_type -> ethereum.eth.v1alpha1.ProposerSlashingResponse
|
||||
3, // 9: ethereum.eth.v1alpha1.Slasher.HighestAttestations:output_type -> ethereum.eth.v1alpha1.HighestAttestationResponse
|
||||
7, // [7:10] is the sub-list for method output_type
|
||||
4, // [4:7] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
5, // 0: ethereum.eth.v1alpha1.AttesterSlashingResponse.attester_slashings:type_name -> ethereum.eth.v1alpha1.AttesterSlashing
|
||||
6, // 1: ethereum.eth.v1alpha1.ProposerSlashingResponse.proposer_slashings:type_name -> ethereum.eth.v1alpha1.ProposerSlashing
|
||||
4, // 2: ethereum.eth.v1alpha1.HighestAttestationResponse.attestations:type_name -> ethereum.eth.v1alpha1.HighestAttestation
|
||||
7, // 3: ethereum.eth.v1alpha1.Slasher.IsSlashableAttestation:input_type -> ethereum.eth.v1alpha1.IndexedAttestation
|
||||
8, // 4: ethereum.eth.v1alpha1.Slasher.IsSlashableBlock:input_type -> ethereum.eth.v1alpha1.SignedBeaconBlockHeader
|
||||
2, // 5: ethereum.eth.v1alpha1.Slasher.HighestAttestations:input_type -> ethereum.eth.v1alpha1.HighestAttestationRequest
|
||||
0, // 6: ethereum.eth.v1alpha1.Slasher.IsSlashableAttestation:output_type -> ethereum.eth.v1alpha1.AttesterSlashingResponse
|
||||
1, // 7: ethereum.eth.v1alpha1.Slasher.IsSlashableBlock:output_type -> ethereum.eth.v1alpha1.ProposerSlashingResponse
|
||||
3, // 8: ethereum.eth.v1alpha1.Slasher.HighestAttestations:output_type -> ethereum.eth.v1alpha1.HighestAttestationResponse
|
||||
6, // [6:9] is the sub-list for method output_type
|
||||
3, // [3:6] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_prysm_v1alpha1_slasher_proto_init() }
|
||||
@@ -701,42 +491,6 @@ func file_proto_prysm_v1alpha1_slasher_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_slasher_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ProposalHistory); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_slasher_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Slashable); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_slasher_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AttestationHistory); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@@ -744,7 +498,7 @@ func file_proto_prysm_v1alpha1_slasher_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_prysm_v1alpha1_slasher_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 9,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@@ -82,35 +82,3 @@ message HighestAttestation {
|
||||
[ (ethereum.eth.ext.cast_type) =
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch" ];
|
||||
}
|
||||
|
||||
// ProposalHistory defines the structure for recording a validator's historical
|
||||
// proposals. Using a bitlist to represent the epochs and an uint64 to mark the
|
||||
// latest marked epoch of the bitlist, we can easily store which epochs a
|
||||
// validator has proposed a block for while pruning the older data.
|
||||
message ProposalHistory {
|
||||
bytes epoch_bits = 1 [
|
||||
(ethereum.eth.ext.cast_type) =
|
||||
"github.com/prysmaticlabs/go-bitfield.Bitlist",
|
||||
deprecated = true
|
||||
];
|
||||
uint64 latest_epoch_written = 2 [
|
||||
(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch",
|
||||
deprecated = true
|
||||
];
|
||||
}
|
||||
|
||||
message Slashable { bool slashable = 1 [ deprecated = true ]; }
|
||||
|
||||
// AttestationHistory defines the structure for recording a validator's
|
||||
// historical attestation. Using a map[uint64]uint64 to map its target epoch to
|
||||
// its source epoch, in order to detect if a vote being created is not a double
|
||||
// vote and surrounded by, or surrounding any other votes. Using an uint64 to
|
||||
// mark the latest written epoch, we can safely perform a rolling prune whenever
|
||||
// the history is updated.
|
||||
message AttestationHistory {
|
||||
map<uint64, uint64> target_to_source = 1 [ deprecated = true ];
|
||||
uint64 latest_epoch_written = 2 [
|
||||
(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch",
|
||||
deprecated = true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -37,12 +37,17 @@ func NewBuilder(t testing.TB, initialState state.BeaconState, initialBlock inter
|
||||
// Tick resets the genesis time to now()-tick and adjusts the slot to the appropriate value.
|
||||
func (bb *Builder) Tick(t testing.TB, tick int64) {
|
||||
bb.service.SetGenesisTime(time.Unix(time.Now().Unix()-tick, 0))
|
||||
bb.service.ForkChoicer().SetGenesisTime(uint64(time.Now().Unix() - tick))
|
||||
if tick > bb.lastTick {
|
||||
slot := uint64(tick) / params.BeaconConfig().SecondsPerSlot
|
||||
require.NoError(t, bb.service.ForkChoicer().NewSlot(context.TODO(), types.Slot(slot)))
|
||||
bb.lastTick = tick
|
||||
lastSlot := uint64(bb.lastTick) / params.BeaconConfig().SecondsPerSlot
|
||||
currentSlot := uint64(tick) / params.BeaconConfig().SecondsPerSlot
|
||||
for lastSlot < currentSlot {
|
||||
lastSlot++
|
||||
bb.service.ForkChoicer().SetGenesisTime(uint64(time.Now().Unix() - int64(params.BeaconConfig().SecondsPerSlot*lastSlot)))
|
||||
require.NoError(t, bb.service.ForkChoicer().NewSlot(context.TODO(), types.Slot(lastSlot)))
|
||||
}
|
||||
if tick > int64(params.BeaconConfig().SecondsPerSlot*lastSlot) {
|
||||
bb.service.ForkChoicer().SetGenesisTime(uint64(time.Now().Unix() - tick))
|
||||
}
|
||||
bb.lastTick = tick
|
||||
}
|
||||
|
||||
// block returns the block root.
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
|
||||
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
|
||||
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle")
|
||||
load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/tools/genesis-state-gen",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//config/params:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/interop:go_default_library",
|
||||
"@com_github_ghodss_yaml//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "genesis-state-gen",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_image(
|
||||
name = "image",
|
||||
base = select({
|
||||
"//tools:base_image_alpine": "//tools:alpine_cc_image",
|
||||
"//tools:base_image_cc": "//tools:cc_image",
|
||||
"//conditions:default": "//tools:cc_image",
|
||||
}),
|
||||
binary = ":genesis-state-gen",
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
container_bundle(
|
||||
name = "image_bundle",
|
||||
images = {
|
||||
"gcr.io/prysmaticlabs/prysm/genesis-state-gen:latest": ":image",
|
||||
"gcr.io/prysmaticlabs/prysm/genesis-state-gen:{DOCKER_TAG}": ":image",
|
||||
},
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
docker_push(
|
||||
name = "push_images",
|
||||
bundle = ":image_bundle",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["main_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//crypto/bls:go_default_library",
|
||||
"//runtime/interop:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -1,201 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/io/file"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/interop"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// DepositDataJSON representing a json object of hex string and uint64 values for
|
||||
// validators on Ethereum. This file can be generated using the official eth2.0-deposit-cli.
|
||||
type DepositDataJSON struct {
|
||||
PubKey string `json:"pubkey"`
|
||||
Amount uint64 `json:"amount"`
|
||||
WithdrawalCredentials string `json:"withdrawal_credentials"`
|
||||
DepositDataRoot string `json:"deposit_data_root"`
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
var (
|
||||
depositJSONFile = flag.String(
|
||||
"deposit-json-file",
|
||||
"",
|
||||
"Path to deposit_data.json file generated by the eth2.0-deposit-cli tool",
|
||||
)
|
||||
numValidators = flag.Int("num-validators", 0, "Number of validators to deterministically generate in the generated genesis state")
|
||||
useMainnetConfig = flag.Bool("mainnet-config", false, "Select whether genesis state should be generated with mainnet or minimal (default) params")
|
||||
genesisTime = flag.Uint64("genesis-time", 0, "Unix timestamp used as the genesis time in the generated genesis state (defaults to now)")
|
||||
sszOutputFile = flag.String("output-ssz", "", "Output filename of the SSZ marshaling of the generated genesis state")
|
||||
yamlOutputFile = flag.String("output-yaml", "", "Output filename of the YAML marshaling of the generated genesis state")
|
||||
jsonOutputFile = flag.String("output-json", "", "Output filename of the JSON marshaling of the generated genesis state")
|
||||
configName = flag.String("config-name", params.MinimalName, "ConfigName for the BeaconChainConfig that will be used for interop, inc GenesisForkVersion of generated genesis state")
|
||||
configFile = flag.String("chain-config-file", "", "Path to a chain config file for setting global params")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if *genesisTime == 0 {
|
||||
log.Print("No --genesis-time specified, defaulting to now")
|
||||
}
|
||||
if *sszOutputFile == "" && *yamlOutputFile == "" && *jsonOutputFile == "" {
|
||||
log.Println("Expected --output-ssz, --output-yaml, or --output-json to have been provided, received nil")
|
||||
return
|
||||
}
|
||||
if *useMainnetConfig {
|
||||
if err := params.SetActive(params.MainnetConfig().Copy()); err != nil {
|
||||
log.Fatalf("unable to set mainnet config active, err=%s", err.Error())
|
||||
}
|
||||
} else {
|
||||
if *configFile != "" {
|
||||
if err := params.LoadChainConfigFile(*configFile, nil); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
cfg, err := params.ByName(*configName)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to find config using name %s, err=%s", *configName, err.Error())
|
||||
}
|
||||
if err := params.SetActive(cfg.Copy()); err != nil {
|
||||
log.Fatalf("unable to set %s config active, err=%s", cfg.ConfigName, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
var genesisState *ethpb.BeaconState
|
||||
var err error
|
||||
if *depositJSONFile != "" {
|
||||
inputFile := *depositJSONFile
|
||||
expanded, err := file.ExpandPath(inputFile)
|
||||
if err != nil {
|
||||
log.WithError(err).Printf("Could not expand file path %s", inputFile)
|
||||
return
|
||||
}
|
||||
inputJSON, err := os.Open(expanded) // #nosec G304
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not open JSON file for reading")
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := inputJSON.Close(); err != nil {
|
||||
log.WithError(err).Printf("Could not close file %s", inputFile)
|
||||
}
|
||||
}()
|
||||
log.Printf("Generating genesis state from input JSON deposit data %s", inputFile)
|
||||
genesisState, err = genesisStateFromJSONValidators(inputJSON, *genesisTime)
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not generate genesis beacon state")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if *numValidators == 0 {
|
||||
log.Println("Expected --num-validators to have been provided, received 0")
|
||||
return
|
||||
}
|
||||
// If no JSON input is specified, we create the state deterministically from interop keys.
|
||||
genesisState, _, err = interop.GenerateGenesisState(context.Background(), *genesisTime, uint64(*numValidators))
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not generate genesis beacon state")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if *sszOutputFile != "" {
|
||||
encodedState, err := genesisState.MarshalSSZ()
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not ssz marshal the genesis beacon state")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(*sszOutputFile, encodedState); err != nil {
|
||||
log.WithError(err).Print("Could not write encoded genesis beacon state to file")
|
||||
return
|
||||
}
|
||||
log.Printf("Done writing to %s", *sszOutputFile)
|
||||
}
|
||||
if *yamlOutputFile != "" {
|
||||
encodedState, err := yaml.Marshal(genesisState)
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not yaml marshal the genesis beacon state")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(*yamlOutputFile, encodedState); err != nil {
|
||||
log.WithError(err).Print("Could not write encoded genesis beacon state to file")
|
||||
return
|
||||
}
|
||||
log.Printf("Done writing to %s", *yamlOutputFile)
|
||||
}
|
||||
if *jsonOutputFile != "" {
|
||||
encodedState, err := json.Marshal(genesisState)
|
||||
if err != nil {
|
||||
log.WithError(err).Print("Could not json marshal the genesis beacon state")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(*jsonOutputFile, encodedState); err != nil {
|
||||
log.WithError(err).Print("Could not write encoded genesis beacon state to file")
|
||||
return
|
||||
}
|
||||
log.Printf("Done writing to %s", *jsonOutputFile)
|
||||
}
|
||||
}
|
||||
|
||||
func genesisStateFromJSONValidators(r io.Reader, genesisTime uint64) (*ethpb.BeaconState, error) {
|
||||
enc, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var depositJSON []*DepositDataJSON
|
||||
if err := json.Unmarshal(enc, &depositJSON); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
depositDataList := make([]*ethpb.Deposit_Data, len(depositJSON))
|
||||
depositDataRoots := make([][]byte, len(depositJSON))
|
||||
for i, val := range depositJSON {
|
||||
data, dataRootBytes, err := depositJSONToDepositData(val)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
depositDataList[i] = data
|
||||
depositDataRoots[i] = dataRootBytes
|
||||
}
|
||||
beaconState, _, err := interop.GenerateGenesisStateFromDepositData(context.Background(), genesisTime, depositDataList, depositDataRoots)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return beaconState, nil
|
||||
}
|
||||
|
||||
func depositJSONToDepositData(input *DepositDataJSON) (depositData *ethpb.Deposit_Data, dataRoot []byte, err error) {
|
||||
pubKeyBytes, err := hex.DecodeString(strings.TrimPrefix(input.PubKey, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
withdrawalbytes, err := hex.DecodeString(strings.TrimPrefix(input.WithdrawalCredentials, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
signatureBytes, err := hex.DecodeString(strings.TrimPrefix(input.Signature, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dataRootBytes, err := hex.DecodeString(strings.TrimPrefix(input.DepositDataRoot, "0x"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
depositData = ðpb.Deposit_Data{
|
||||
PublicKey: pubKeyBytes,
|
||||
WithdrawalCredentials: withdrawalbytes,
|
||||
Amount: input.Amount,
|
||||
Signature: signatureBytes,
|
||||
}
|
||||
dataRoot = dataRootBytes
|
||||
return
|
||||
}
|
||||
@@ -88,17 +88,6 @@ var (
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorInclusionDistancesGaugeVec used to keep track of validator inclusion distances by public key.
|
||||
ValidatorInclusionDistancesGaugeVec = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "validator",
|
||||
Name: "inclusion_distance",
|
||||
Help: "Inclusion distance of last attestation. Deprecated after Altair hard fork.",
|
||||
},
|
||||
[]string{
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
// ValidatorAttestedSlotsGaugeVec used to keep track of validator attested slots by public key.
|
||||
ValidatorAttestedSlotsGaugeVec = promauto.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
@@ -332,19 +321,6 @@ func (v *validator) logForEachValidator(index int, pubKey []byte, resp *ethpb.Va
|
||||
"percentChangeSinceStart": fmt.Sprintf("%.5f%%", percentSinceStart*100),
|
||||
}
|
||||
|
||||
// These fields are deprecated after Altair.
|
||||
if slots.ToEpoch(slot) < params.BeaconConfig().AltairForkEpoch {
|
||||
if index < len(resp.InclusionSlots) {
|
||||
previousEpochSummaryFields["inclusionSlot"] = resp.InclusionSlots[index]
|
||||
} else {
|
||||
log.WithField("pubKey", truncatedKey).Warn("Missing inclusion slot")
|
||||
}
|
||||
if index < len(resp.InclusionDistances) {
|
||||
previousEpochSummaryFields["inclusionDistance"] = resp.InclusionDistances[index]
|
||||
} else {
|
||||
log.WithField("pubKey", truncatedKey).Warn("Missing inclusion distance")
|
||||
}
|
||||
}
|
||||
if slots.ToEpoch(slot) >= params.BeaconConfig().AltairForkEpoch {
|
||||
if index < len(resp.InactivityScores) {
|
||||
previousEpochSummaryFields["inactivityScore"] = resp.InactivityScores[index]
|
||||
@@ -373,13 +349,7 @@ func (v *validator) logForEachValidator(index int, pubKey []byte, resp *ethpb.Va
|
||||
}
|
||||
|
||||
// Phase0 specific metrics
|
||||
if slots.ToEpoch(slot) < params.BeaconConfig().AltairForkEpoch {
|
||||
if index < len(resp.InclusionDistances) {
|
||||
ValidatorInclusionDistancesGaugeVec.WithLabelValues(fmtKey).Set(float64(resp.InclusionDistances[index]))
|
||||
}
|
||||
} else { // Altair specific metrics.
|
||||
// Reset phase0 fields that no longer apply
|
||||
ValidatorInclusionDistancesGaugeVec.DeleteLabelValues(fmtKey)
|
||||
if slots.ToEpoch(slot) >= params.BeaconConfig().AltairForkEpoch {
|
||||
if index < len(resp.InactivityScores) {
|
||||
ValidatorInactivityScoreGaugeVec.WithLabelValues(fmtKey).Set(float64(resp.InactivityScores[index]))
|
||||
}
|
||||
@@ -396,12 +366,6 @@ func (v *validator) UpdateLogAggregateStats(resp *ethpb.ValidatorPerformanceResp
|
||||
var attested, correctSource, correctTarget, correctHead, inactivityScore int
|
||||
|
||||
for i := range resp.PublicKeys {
|
||||
if slots.ToEpoch(slot) < params.BeaconConfig().AltairForkEpoch && i < len(resp.InclusionDistances) {
|
||||
if uint64(resp.InclusionSlots[i]) != ^uint64(0) {
|
||||
summary.totalDistance += resp.InclusionDistances[i]
|
||||
}
|
||||
}
|
||||
|
||||
included := false
|
||||
if i < len(resp.CorrectlyVotedSource) && resp.CorrectlyVotedSource[i] {
|
||||
included = true
|
||||
|
||||
@@ -40,8 +40,6 @@ func TestUpdateLogAggregateStats(t *testing.T) {
|
||||
bytesutil.FromBytes48(pubKeyBytes[1]),
|
||||
bytesutil.FromBytes48(pubKeyBytes[2]),
|
||||
},
|
||||
InclusionSlots: []types.Slot{types.Slot(^uint64(0)), 10, 11}, // exact slot doesn't matter, only if it is == or != ^uint64(0)
|
||||
InclusionDistances: []types.Slot{0, 5, 2},
|
||||
CorrectlyVotedHead: []bool{false, true, false},
|
||||
CorrectlyVotedSource: []bool{false, true, true},
|
||||
CorrectlyVotedTarget: []bool{false, true, true},
|
||||
@@ -52,8 +50,6 @@ func TestUpdateLogAggregateStats(t *testing.T) {
|
||||
bytesutil.FromBytes48(pubKeyBytes[1]),
|
||||
bytesutil.FromBytes48(pubKeyBytes[2]),
|
||||
},
|
||||
InclusionSlots: []types.Slot{33, 34, 35},
|
||||
InclusionDistances: []types.Slot{1, 2, 3},
|
||||
CorrectlyVotedHead: []bool{true, true, true},
|
||||
CorrectlyVotedSource: []bool{true, true, true},
|
||||
CorrectlyVotedTarget: []bool{true, true, true},
|
||||
@@ -64,8 +60,6 @@ func TestUpdateLogAggregateStats(t *testing.T) {
|
||||
bytesutil.FromBytes48(pubKeyBytes[1]),
|
||||
bytesutil.FromBytes48(pubKeyBytes[2]),
|
||||
},
|
||||
InclusionSlots: []types.Slot{65, types.Slot(^uint64(0)), 67},
|
||||
InclusionDistances: []types.Slot{1, 0, 2},
|
||||
CorrectlyVotedHead: []bool{true, false, true},
|
||||
CorrectlyVotedSource: []bool{true, false, true},
|
||||
CorrectlyVotedTarget: []bool{false, false, true},
|
||||
@@ -88,7 +82,7 @@ func TestUpdateLogAggregateStats(t *testing.T) {
|
||||
require.LogsContain(t, hook, "msg=\"Previous epoch aggregated voting summary\" attestationInclusionPct=\"67%\" "+
|
||||
"correctlyVotedHeadPct=\"100%\" correctlyVotedSourcePct=\"100%\" correctlyVotedTargetPct=\"50%\" epoch=2")
|
||||
require.LogsContain(t, hook, "msg=\"Vote summary since launch\" attestationsInclusionPct=\"78%\" "+
|
||||
"averageInclusionDistance=\"2.29 slots\" correctlyVotedHeadPct=\"86%\" correctlyVotedSourcePct=\"100%\" "+
|
||||
"averageInclusionDistance=\"0.00 slots\" correctlyVotedHeadPct=\"86%\" correctlyVotedSourcePct=\"100%\" "+
|
||||
"correctlyVotedTargetPct=\"86%\" numberOfEpochs=3 pctChangeCombinedBalance=\"0.20555%\"")
|
||||
|
||||
}
|
||||
|
||||
@@ -1066,7 +1066,7 @@ func (v *validator) buildSignedRegReqs(ctx context.Context, pubkeys [][fieldpara
|
||||
feeRecipient = v.ProposerSettings.DefaultConfig.FeeRecipient // Use cli config for fee recipient.
|
||||
config := v.ProposerSettings.DefaultConfig.BuilderConfig
|
||||
if config != nil && config.Enabled {
|
||||
gasLimit = config.GasLimit // Use cli config for gas limit.
|
||||
gasLimit = uint64(config.GasLimit) // Use cli config for gas limit.
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ func (v *validator) buildSignedRegReqs(ctx context.Context, pubkeys [][fieldpara
|
||||
builderConfig := config.BuilderConfig
|
||||
if builderConfig != nil {
|
||||
if builderConfig.Enabled {
|
||||
gasLimit = builderConfig.GasLimit // Use file config for gas limit.
|
||||
gasLimit = uint64(builderConfig.GasLimit) // Use file config for gas limit.
|
||||
enabled = true
|
||||
} else {
|
||||
enabled = false // Custom config can disable validator from register.
|
||||
|
||||
@@ -1514,7 +1514,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
v.ProposerSettings = &validatorserviceconfig.ProposerSettings{
|
||||
@@ -1523,7 +1523,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress(defaultFeeHex),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(35000000),
|
||||
GasLimit: 35000000,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1541,11 +1541,11 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
|
||||
{
|
||||
FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9").Bytes(),
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
{
|
||||
FeeRecipient: byteValueAddress,
|
||||
GasLimit: uint64(35000000),
|
||||
GasLimit: 35000000,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1594,7 +1594,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
v.ProposerSettings = &validatorserviceconfig.ProposerSettings{
|
||||
@@ -1603,7 +1603,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress(defaultFeeHex),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: uint64(35000000),
|
||||
GasLimit: 35000000,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1715,7 +1715,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress(defaultFeeHex),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1771,7 +1771,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress(defaultFeeHex),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1963,7 +1963,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.Address{},
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
}
|
||||
v.ProposerSettings = &validatorserviceconfig.ProposerSettings{
|
||||
@@ -1972,7 +1972,7 @@ func TestValidator_PushProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress(defaultFeeHex),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -498,9 +499,17 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett
|
||||
suggestedFee := cliCtx.String(flags.SuggestedFeeRecipientFlag.Name)
|
||||
var vr *validatorServiceConfig.BuilderConfig
|
||||
if cliCtx.Bool(flags.EnableBuilderFlag.Name) {
|
||||
sgl := cliCtx.String(flags.BuilderGasLimitFlag.Name)
|
||||
vr = &validatorServiceConfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: reviewGasLimit(uint64(cliCtx.Int(flags.BuilderGasLimitFlag.Name))),
|
||||
GasLimit: validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
}
|
||||
if sgl != "" {
|
||||
gl, err := strconv.ParseUint(sgl, 10, 64)
|
||||
if err != nil {
|
||||
return nil, errors.New("Gas Limit is not a uint64")
|
||||
}
|
||||
vr.GasLimit = reviewGasLimit(validatorServiceConfig.Uint64(gl))
|
||||
}
|
||||
}
|
||||
fileConfig = &validatorServiceConfig.ProposerSettingsPayload{
|
||||
@@ -595,10 +604,10 @@ func warnNonChecksummedAddress(feeRecipient string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func reviewGasLimit(gasLimit uint64) uint64 {
|
||||
func reviewGasLimit(gasLimit validatorServiceConfig.Uint64) validatorServiceConfig.Uint64 {
|
||||
// sets gas limit to default if not defined or set to 0
|
||||
if gasLimit == 0 {
|
||||
return params.BeaconConfig().DefaultBuilderGasLimit
|
||||
return validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
}
|
||||
//TODO(10810): add in warning for ranges
|
||||
return gasLimit
|
||||
|
||||
@@ -211,6 +211,7 @@ func TestProposerSettings(t *testing.T) {
|
||||
dir string
|
||||
url string
|
||||
defaultfee string
|
||||
defaultgas string
|
||||
}
|
||||
|
||||
type args struct {
|
||||
@@ -271,14 +272,14 @@ func TestProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
bytesutil.ToBytes48(key2): {
|
||||
FeeRecipient: common.HexToAddress("0x60155530FCE8a85ec7055A5F8b2bE214B3DaeFd4"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(35000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -286,7 +287,7 @@ func TestProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -336,7 +337,7 @@ func TestProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: uint64(40000000),
|
||||
GasLimit: 40000000,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -344,7 +345,7 @@ func TestProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -386,7 +387,32 @@ func TestProposerSettings(t *testing.T) {
|
||||
FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: params.BeaconConfig().DefaultBuilderGasLimit,
|
||||
GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
wantErr: "",
|
||||
validatorRegistrationEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "Happy Path Suggested Fee , validator registration enabled and default gas",
|
||||
args: args{
|
||||
proposerSettingsFlagValues: &proposerSettingsFlag{
|
||||
dir: "",
|
||||
url: "",
|
||||
defaultfee: "0x6e35733c5af9B61374A128e6F85f553aF09ff89A",
|
||||
defaultgas: "50000000",
|
||||
},
|
||||
},
|
||||
want: func() *validatorserviceconfig.ProposerSettings {
|
||||
return &validatorserviceconfig.ProposerSettings{
|
||||
ProposeConfig: nil,
|
||||
DefaultConfig: &validatorserviceconfig.ProposerOption{
|
||||
FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"),
|
||||
BuilderConfig: &validatorserviceconfig.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: 50000000,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -487,6 +513,20 @@ func TestProposerSettings(t *testing.T) {
|
||||
},
|
||||
wantErr: "cannot specify both",
|
||||
},
|
||||
{
|
||||
name: "Bad Gas value in JSON",
|
||||
args: args{
|
||||
proposerSettingsFlagValues: &proposerSettingsFlag{
|
||||
dir: "./testdata/bad-gas-value-proposer-settings.json",
|
||||
url: "",
|
||||
defaultfee: "",
|
||||
},
|
||||
},
|
||||
want: func() *validatorserviceconfig.ProposerSettings {
|
||||
return nil
|
||||
},
|
||||
wantErr: "failed to unmarshal yaml file",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@@ -514,6 +554,10 @@ func TestProposerSettings(t *testing.T) {
|
||||
set.String(flags.SuggestedFeeRecipientFlag.Name, tt.args.proposerSettingsFlagValues.defaultfee, "")
|
||||
require.NoError(t, set.Set(flags.SuggestedFeeRecipientFlag.Name, tt.args.proposerSettingsFlagValues.defaultfee))
|
||||
}
|
||||
if tt.args.proposerSettingsFlagValues.defaultgas != "" {
|
||||
set.String(flags.BuilderGasLimitFlag.Name, tt.args.proposerSettingsFlagValues.defaultgas, "")
|
||||
require.NoError(t, set.Set(flags.BuilderGasLimitFlag.Name, tt.args.proposerSettingsFlagValues.defaultgas))
|
||||
}
|
||||
if tt.validatorRegistrationEnabled {
|
||||
set.Bool(flags.EnableBuilderFlag.Name, true, "")
|
||||
}
|
||||
|
||||
19
validator/node/testdata/bad-gas-value-proposer-settings.json
vendored
Normal file
19
validator/node/testdata/bad-gas-value-proposer-settings.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"proposer_config": {
|
||||
"0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a": {
|
||||
"fee_recipient": "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3",
|
||||
"builder": {
|
||||
"enabled": true,
|
||||
"gas_limit": "asdfsffsdf"
|
||||
}
|
||||
}
|
||||
},
|
||||
"default_config": {
|
||||
"fee_recipient": "0x6e35733c5af9B61374A128e6F85f553aF09ff89A",
|
||||
"builder": {
|
||||
"enabled": true,
|
||||
"gas_limit": 40000000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
"fee_recipient": "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3",
|
||||
"builder": {
|
||||
"enabled": true,
|
||||
"gas_limit": 30000000
|
||||
"gas_limit": "30000000"
|
||||
}
|
||||
},
|
||||
"0xb057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7b": {
|
||||
"fee_recipient": "0x60155530FCE8a85ec7055A5F8b2bE214B3DaeFd4",
|
||||
"builder": {
|
||||
"enabled": true,
|
||||
"gas_limit": 30000000
|
||||
"gas_limit": 35000000
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
"fee_recipient": "0x6e35733c5af9B61374A128e6F85f553aF09ff89A",
|
||||
"builder": {
|
||||
"enabled": true,
|
||||
"gas_limit": 30000000
|
||||
"gas_limit": 40000000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ default_config:
|
||||
fee_recipient: '0x6e35733c5af9B61374A128e6F85f553aF09ff89A'
|
||||
builder:
|
||||
enabled: false
|
||||
gas_limit: 30000000
|
||||
gas_limit: '30000000'
|
||||
@@ -406,11 +406,11 @@ func (s *Server) GetGasLimit(_ context.Context, req *ethpbservice.PubkeyRequest)
|
||||
proposerOption, found := s.validatorService.ProposerSettings.ProposeConfig[bytesutil.ToBytes48(validatorKey)]
|
||||
if found {
|
||||
if proposerOption.BuilderConfig != nil {
|
||||
resp.Data.GasLimit = proposerOption.BuilderConfig.GasLimit
|
||||
resp.Data.GasLimit = uint64(proposerOption.BuilderConfig.GasLimit)
|
||||
return resp, nil
|
||||
}
|
||||
} else if s.validatorService.ProposerSettings.DefaultConfig != nil && s.validatorService.ProposerSettings.DefaultConfig.BuilderConfig != nil {
|
||||
resp.Data.GasLimit = s.validatorService.ProposerSettings.DefaultConfig.BuilderConfig.GasLimit
|
||||
resp.Data.GasLimit = uint64(s.validatorService.ProposerSettings.DefaultConfig.BuilderConfig.GasLimit)
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
@@ -437,10 +437,10 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR
|
||||
// "DefaultConfig.BuilderConfig".
|
||||
bo := *s.validatorService.ProposerSettings.DefaultConfig.BuilderConfig
|
||||
pBuilderConfig = &bo
|
||||
pBuilderConfig.GasLimit = req.GasLimit
|
||||
pBuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit)
|
||||
} else {
|
||||
// No default BuildConfig to copy from, just create one and set "GasLimit", but keep "Enabled" to "false".
|
||||
pBuilderConfig = &validatorServiceConfig.BuilderConfig{Enabled: false, GasLimit: req.GasLimit}
|
||||
pBuilderConfig = &validatorServiceConfig.BuilderConfig{Enabled: false, GasLimit: validatorServiceConfig.Uint64(req.GasLimit)}
|
||||
}
|
||||
|
||||
pOption := validatorServiceConfig.DefaultProposerOption()
|
||||
@@ -463,7 +463,7 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR
|
||||
if proposerOption.BuilderConfig == nil {
|
||||
proposerOption.BuilderConfig = pBuilderConfig
|
||||
} else {
|
||||
proposerOption.BuilderConfig.GasLimit = req.GasLimit
|
||||
proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit)
|
||||
}
|
||||
} else {
|
||||
s.validatorService.ProposerSettings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = &pOption
|
||||
|
||||
@@ -1007,7 +1007,7 @@ func TestServer_SetGasLimit(t *testing.T) {
|
||||
_, err = s.SetGasLimit(ctx, ðpbservice.SetGasLimitRequest{Pubkey: tt.pubkey, GasLimit: tt.newGasLimit})
|
||||
require.NoError(t, err)
|
||||
for _, w := range tt.w {
|
||||
assert.Equal(t, w.gaslimit, s.validatorService.ProposerSettings.ProposeConfig[bytesutil.ToBytes48(w.pubkey)].BuilderConfig.GasLimit)
|
||||
assert.Equal(t, w.gaslimit, uint64(s.validatorService.ProposerSettings.ProposeConfig[bytesutil.ToBytes48(w.pubkey)].BuilderConfig.GasLimit))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user