clean up: godoc comments, redundant castings and more (#11428)

* clean up: Godoc comments, redundant castings and more

* Fix assertion check

* Update beacon-chain/forkchoice/doubly-linked-tree/forkchoice.go

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>

* Update beacon-chain/forkchoice/protoarray/store.go

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
terencechain
2022-09-12 16:03:20 +02:00
committed by GitHub
parent 6cf4f3c260
commit d860daff75
13 changed files with 18 additions and 28 deletions

View File

@@ -3411,6 +3411,6 @@ func TestOnBlock_HandleBlockAttestations(t *testing.T) {
// 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) {
offset := int64(slot*int64(params.BeaconConfig().SecondsPerSlot) - delay)
offset := slot*int64(params.BeaconConfig().SecondsPerSlot) - delay
s.SetGenesisTime(time.Unix(time.Now().Unix()-offset, 0))
}

View File

@@ -11,7 +11,7 @@ import (
"google.golang.org/protobuf/proto"
)
// SavePowchainData saves the pow chain data.
// SaveExecutionChainData saves the execution chain data.
func (s *Store) SaveExecutionChainData(ctx context.Context, data *v2.ETH1ChainData) error {
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveExecutionChainData")
defer span.End()
@@ -34,7 +34,7 @@ func (s *Store) SaveExecutionChainData(ctx context.Context, data *v2.ETH1ChainDa
return err
}
// PowchainData retrieves the powchain data.
// ExecutionChainData retrieves the execution chain data.
func (s *Store) ExecutionChainData(ctx context.Context) (*v2.ETH1ChainData, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.ExecutionChainData")
defer span.End()

View File

@@ -51,7 +51,7 @@ func clientTimedOutError(err error) bool {
return strings.Contains(err.Error(), errTimedOut.Error())
}
// Eth2GenesisPowchainInfo retrieves the genesis time and eth1 block number of the beacon chain
// GenesisExecutionChainInfo retrieves the genesis time and execution block number of the beacon chain
// from the deposit contract.
func (s *Service) GenesisExecutionChainInfo() (uint64, *big.Int) {
return s.chainStartData.GenesisTime, big.NewInt(int64(s.chainStartData.GenesisBlock))

View File

@@ -491,7 +491,7 @@ func (f *ForkChoice) UpdateFinalizedCheckpoint(fc *forkchoicetypes.Checkpoint) e
return nil
}
// CommonAncestorRoot returns the common ancestor root between the two block roots r1 and r2.
// CommonAncestor returns the common ancestor root and slot between the two block roots r1 and r2.
func (f *ForkChoice) CommonAncestor(ctx context.Context, r1 [32]byte, r2 [32]byte) ([32]byte, types.Slot, error) {
ctx, span := trace.StartSpan(ctx, "doublelinkedtree.CommonAncestorRoot")
defer span.End()

View File

@@ -430,7 +430,7 @@ func TestForkChoice_BoostProposerRoot(t *testing.T) {
f := setup(0, 0)
slot := types.Slot(1)
currentSlot := types.Slot(1)
driftGenesisTime(f, currentSlot, uint64(params.BeaconConfig().SecondsPerSlot-1))
driftGenesisTime(f, currentSlot, params.BeaconConfig().SecondsPerSlot-1)
state, blkRoot, err := prepareForkchoiceState(ctx, slot, root, zeroHash, zeroHash, 0, 0)
require.NoError(t, err)
require.NoError(t, f.InsertNode(ctx, state, blkRoot))

View File

@@ -426,7 +426,7 @@ func TestForkChoice_BoostProposerRoot(t *testing.T) {
f := setup(0, 0)
slot := types.Slot(1)
currentSlot := types.Slot(1)
driftGenesisTime(f, currentSlot, uint64(params.BeaconConfig().SecondsPerSlot-1))
driftGenesisTime(f, currentSlot, params.BeaconConfig().SecondsPerSlot-1)
state, blkRoot, err := prepareForkchoiceState(ctx, slot, root, zeroHash, zeroHash, 0, 0)
require.NoError(t, err)
require.NoError(t, f.InsertNode(ctx, state, blkRoot))

View File

@@ -281,7 +281,7 @@ func (f *ForkChoice) AncestorRoot(ctx context.Context, root [32]byte, slot types
return f.store.nodes[i].root, nil
}
// CommonAncestorRoot returns the common ancestor root between the two block roots r1 and r2.
// CommonAncestor returns the common ancestor root and slot between the two block roots r1 and r2.
func (f *ForkChoice) CommonAncestor(ctx context.Context, r1 [32]byte, r2 [32]byte) ([32]byte, types.Slot, error) {
ctx, span := trace.StartSpan(ctx, "protoArray.CommonAncestorRoot")
defer span.End()

View File

@@ -8,7 +8,7 @@ import (
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p/p2p/muxer/mplex"
noise "github.com/libp2p/go-libp2p/p2p/security/noise"
"github.com/libp2p/go-libp2p/p2p/security/noise"
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"

View File

@@ -13,7 +13,7 @@ import (
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
noise "github.com/libp2p/go-libp2p/p2p/security/noise"
"github.com/libp2p/go-libp2p/p2p/security/noise"
"github.com/multiformats/go-multiaddr"
"github.com/prysmaticlabs/prysm/v3/async/event"
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"

View File

@@ -275,7 +275,7 @@ func (p *PayloadStatus) MarshalJSON() ([]byte, error) {
var latestHash *common.Hash
if p.LatestValidHash != nil {
hash := common.Hash(bytesutil.ToBytes32(p.LatestValidHash))
latestHash = (*common.Hash)(&hash)
latestHash = &hash
}
return json.Marshal(payloadStatusJSON{
LatestValidHash: latestHash,
@@ -324,7 +324,7 @@ func (t *TransitionConfiguration) MarshalJSON() ([]byte, error) {
}
return json.Marshal(transitionConfigurationJSON{
TerminalTotalDifficulty: hexNum,
TerminalBlockHash: common.Hash(*(*[32]byte)(t.TerminalBlockHash)),
TerminalBlockHash: *(*[32]byte)(t.TerminalBlockHash),
TerminalBlockNumber: hexutil.Uint64(num.Uint64()),
})
}

View File

@@ -682,16 +682,6 @@ func genBlindedBeaconBlockBodyBellatrix() *v1alpha1.BlindedBeaconBlockBodyBellat
}
}
func genBlindedBeaconBlockBellatrix() *v1alpha1.BlindedBeaconBlockBellatrix {
return &v1alpha1.BlindedBeaconBlockBellatrix{
Slot: 123455,
ProposerIndex: 55433,
ParentRoot: bytes(),
StateRoot: bytes(),
Body: genBlindedBeaconBlockBodyBellatrix(),
}
}
func genSyncCommitteeMessage() *v1alpha1.SyncCommitteeMessage {
return &v1alpha1.SyncCommitteeMessage{
Slot: 424555,

View File

@@ -13,7 +13,7 @@ import (
"github.com/prysmaticlabs/prysm/v3/validator/keymanager/remote"
)
// CreateWalletWithKeymanager specified by configuration options.
// WalletCreate creates wallet specified by configuration options.
func (acm *AccountsCLIManager) WalletCreate(ctx context.Context) (*wallet.Wallet, error) {
w := wallet.New(&wallet.Config{
WalletDir: acm.walletDir,

View File

@@ -938,7 +938,7 @@ func TestServer_SetGasLimit(t *testing.T) {
},
},
w: []want{
want{
{
pubkey: pubkey1,
gaslimit: 9999,
},
@@ -959,11 +959,11 @@ func TestServer_SetGasLimit(t *testing.T) {
},
},
w: []want{
want{
{
pubkey: pubkey1,
gaslimit: 123456789,
},
want{
{
pubkey: pubkey2,
gaslimit: 8888,
},
@@ -979,7 +979,7 @@ func TestServer_SetGasLimit(t *testing.T) {
},
},
w: []want{
want{
{
pubkey: pubkey1,
gaslimit: 8888,
},
@@ -991,7 +991,7 @@ func TestServer_SetGasLimit(t *testing.T) {
newGasLimit: 7777,
// proposerSettings is not set - we need to create proposerSettings and set gaslimit properly
w: []want{
want{
{
pubkey: pubkey1,
gaslimit: 7777,
},