mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-21 19:20:38 +00:00
Clean up various warnings (#10710)
* Clean up various warnings * Update beacon-chain/rpc/prysm/v1alpha1/debug/state_test.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Fix redundant casting genState 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:
parent
1c51f6d1be
commit
092e9e1d19
@ -46,10 +46,8 @@ const (
|
||||
type StateOrBlockId string
|
||||
|
||||
const (
|
||||
IdFinalized StateOrBlockId = "finalized"
|
||||
IdGenesis StateOrBlockId = "genesis"
|
||||
IdHead StateOrBlockId = "head"
|
||||
IdJustified StateOrBlockId = "justified"
|
||||
IdGenesis StateOrBlockId = "genesis"
|
||||
IdHead StateOrBlockId = "head"
|
||||
)
|
||||
|
||||
var ErrMalformedHostname = errors.New("hostname must include port, separated by one colon, like example.com:3500")
|
||||
@ -60,7 +58,7 @@ func IdFromRoot(r [32]byte) StateOrBlockId {
|
||||
return StateOrBlockId(fmt.Sprintf("%#x", r))
|
||||
}
|
||||
|
||||
// IdFromRoot encodes a Slot in the format expected by the API in places where a slot can be used to identify
|
||||
// IdFromSlot encodes a Slot in the format expected by the API in places where a slot can be used to identify
|
||||
// a BeaconState or SignedBeaconBlock.
|
||||
func IdFromSlot(s types.Slot) StateOrBlockId {
|
||||
return StateOrBlockId(strconv.FormatUint(uint64(s), 10))
|
||||
|
@ -376,7 +376,7 @@ func (_ *ChainService) HeadGenesisValidatorsRoot() [32]byte {
|
||||
return [32]byte{}
|
||||
}
|
||||
|
||||
// VerifyBlkDescendant mocks VerifyBlkDescendant and always returns nil.
|
||||
// VerifyFinalizedBlkDescendant mocks VerifyBlkDescendant and always returns nil.
|
||||
func (s *ChainService) VerifyFinalizedBlkDescendant(_ context.Context, _ [32]byte) error {
|
||||
return s.VerifyBlkDescendantErr
|
||||
}
|
||||
@ -451,7 +451,7 @@ func (s *ChainService) IsOptimisticForRoot(_ context.Context, _ [32]byte) (bool,
|
||||
return s.Optimistic, nil
|
||||
}
|
||||
|
||||
// ProcessAttestationsAndUpdateHead mocks the same method in the chain service.
|
||||
// UpdateHead mocks the same method in the chain service.
|
||||
func (s *ChainService) UpdateHead(_ context.Context) error { return nil }
|
||||
|
||||
// ReceiveAttesterSlashing mocks the same method in the chain service.
|
||||
|
2
beacon-chain/cache/committee_test.go
vendored
2
beacon-chain/cache/committee_test.go
vendored
@ -110,7 +110,7 @@ func TestCommitteeCache_CanRotate(t *testing.T) {
|
||||
sort.Slice(k, func(i, j int) bool {
|
||||
return k[i].(string) < k[j].(string)
|
||||
})
|
||||
wanted := end - int(maxCommitteesCacheSize)
|
||||
wanted := end - maxCommitteesCacheSize
|
||||
s := bytesutil.ToBytes32([]byte(strconv.Itoa(wanted)))
|
||||
assert.Equal(t, key(s), k[0], "incorrect key received for slot 190")
|
||||
|
||||
|
@ -14,7 +14,7 @@ var ErrNotFoundState = kv.ErrNotFoundState
|
||||
// ErrNotFoundOriginBlockRoot wraps ErrNotFound for an error specific to the origin block root.
|
||||
var ErrNotFoundOriginBlockRoot = kv.ErrNotFoundOriginBlockRoot
|
||||
|
||||
// ErrNotFoundOriginBlockRoot wraps ErrNotFound for an error specific to the origin block root.
|
||||
// ErrNotFoundBackfillBlockRoot wraps ErrNotFound for an error specific to the backfill block root.
|
||||
var ErrNotFoundBackfillBlockRoot = kv.ErrNotFoundBackfillBlockRoot
|
||||
|
||||
// ErrNotFoundGenesisBlockRoot means no genesis block root was found, indicating the db was not initialized with genesis
|
||||
|
@ -16,7 +16,7 @@ var ErrNotFoundOriginBlockRoot = errors.Wrap(ErrNotFound, "OriginBlockRoot")
|
||||
// ErrNotFoundGenesisBlockRoot means no genesis block root was found, indicating the db was not initialized with genesis
|
||||
var ErrNotFoundGenesisBlockRoot = errors.Wrap(ErrNotFound, "OriginGenesisRoot")
|
||||
|
||||
// ErrNotFoundOriginBlockRoot is an error specifically for the origin block root getter
|
||||
// ErrNotFoundBackfillBlockRoot is an error specifically for the origin block root getter
|
||||
var ErrNotFoundBackfillBlockRoot = errors.Wrap(ErrNotFound, "BackfillBlockRoot")
|
||||
|
||||
// ErrNotFoundFeeRecipient is a not found error specifically for the fee recipient getter
|
||||
|
@ -130,7 +130,7 @@ func TestUpdateSyncCommitteeTrackedVals(t *testing.T) {
|
||||
|
||||
func TestNewService(t *testing.T) {
|
||||
config := &ValidatorMonitorConfig{}
|
||||
tracked := []types.ValidatorIndex{}
|
||||
var tracked []types.ValidatorIndex
|
||||
ctx := context.Background()
|
||||
_, err := NewService(ctx, config, tracked)
|
||||
require.NoError(t, err)
|
||||
|
@ -2835,50 +2835,50 @@ func TestGetAggregateAttestation(t *testing.T) {
|
||||
},
|
||||
Signature: sig1,
|
||||
}
|
||||
root2_1 := bytesutil.PadTo([]byte("root2_1"), 32)
|
||||
sig2_1 := bytesutil.PadTo([]byte("sig2_1"), fieldparams.BLSSignatureLength)
|
||||
attSlot2_1 := ðpbalpha.Attestation{
|
||||
root21 := bytesutil.PadTo([]byte("root2_1"), 32)
|
||||
sig21 := bytesutil.PadTo([]byte("sig2_1"), fieldparams.BLSSignatureLength)
|
||||
attslot21 := ðpbalpha.Attestation{
|
||||
AggregationBits: []byte{0, 1, 1},
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 2,
|
||||
CommitteeIndex: 2,
|
||||
BeaconBlockRoot: root2_1,
|
||||
BeaconBlockRoot: root21,
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: 1,
|
||||
Root: root2_1,
|
||||
Root: root21,
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: 1,
|
||||
Root: root2_1,
|
||||
Root: root21,
|
||||
},
|
||||
},
|
||||
Signature: sig2_1,
|
||||
Signature: sig21,
|
||||
}
|
||||
root2_2 := bytesutil.PadTo([]byte("root2_2"), 32)
|
||||
sig2_2 := bytesutil.PadTo([]byte("sig2_2"), fieldparams.BLSSignatureLength)
|
||||
attSlot2_2 := ðpbalpha.Attestation{
|
||||
root22 := bytesutil.PadTo([]byte("root2_2"), 32)
|
||||
sig22 := bytesutil.PadTo([]byte("sig2_2"), fieldparams.BLSSignatureLength)
|
||||
attslot22 := ðpbalpha.Attestation{
|
||||
AggregationBits: []byte{0, 1, 1, 1},
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 2,
|
||||
CommitteeIndex: 3,
|
||||
BeaconBlockRoot: root2_2,
|
||||
BeaconBlockRoot: root22,
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: 1,
|
||||
Root: root2_2,
|
||||
Root: root22,
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: 1,
|
||||
Root: root2_2,
|
||||
Root: root22,
|
||||
},
|
||||
},
|
||||
Signature: sig2_2,
|
||||
Signature: sig22,
|
||||
}
|
||||
vs := &Server{
|
||||
AttestationsPool: &mock.PoolMock{AggregatedAtts: []*ethpbalpha.Attestation{attSlot1, attSlot2_1, attSlot2_2}},
|
||||
AttestationsPool: &mock.PoolMock{AggregatedAtts: []*ethpbalpha.Attestation{attSlot1, attslot21, attslot22}},
|
||||
}
|
||||
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
reqRoot, err := attSlot2_2.Data.HashTreeRoot()
|
||||
reqRoot, err := attslot22.Data.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
req := ðpbv1.AggregateAttestationRequest{
|
||||
AttestationDataRoot: reqRoot[:],
|
||||
@ -2889,16 +2889,16 @@ func TestGetAggregateAttestation(t *testing.T) {
|
||||
require.NotNil(t, att)
|
||||
require.NotNil(t, att.Data)
|
||||
assert.DeepEqual(t, bitfield.Bitlist{0, 1, 1, 1}, att.Data.AggregationBits)
|
||||
assert.DeepEqual(t, sig2_2, att.Data.Signature)
|
||||
assert.DeepEqual(t, sig22, att.Data.Signature)
|
||||
assert.Equal(t, types.Slot(2), att.Data.Data.Slot)
|
||||
assert.Equal(t, types.CommitteeIndex(3), att.Data.Data.Index)
|
||||
assert.DeepEqual(t, root2_2, att.Data.Data.BeaconBlockRoot)
|
||||
assert.DeepEqual(t, root22, att.Data.Data.BeaconBlockRoot)
|
||||
require.NotNil(t, att.Data.Data.Source)
|
||||
assert.Equal(t, types.Epoch(1), att.Data.Data.Source.Epoch)
|
||||
assert.DeepEqual(t, root2_2, att.Data.Data.Source.Root)
|
||||
assert.DeepEqual(t, root22, att.Data.Data.Source.Root)
|
||||
require.NotNil(t, att.Data.Data.Target)
|
||||
assert.Equal(t, types.Epoch(1), att.Data.Data.Target.Epoch)
|
||||
assert.DeepEqual(t, root2_2, att.Data.Data.Target.Root)
|
||||
assert.DeepEqual(t, root22, att.Data.Data.Target.Root)
|
||||
})
|
||||
|
||||
t.Run("No matching attestation", func(t *testing.T) {
|
||||
|
@ -50,7 +50,6 @@ go_test(
|
||||
"//beacon-chain/db/testing:go_default_library",
|
||||
"//beacon-chain/forkchoice/protoarray:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/state/stategen/mock:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
||||
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
mockstategen "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen/mock"
|
||||
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
|
||||
@ -83,10 +82,9 @@ func TestServer_GetBeaconState(t *testing.T) {
|
||||
Slot: slot + 1,
|
||||
},
|
||||
}
|
||||
state := state.BeaconState(st)
|
||||
// since we are requesting a state at a skipped slot, use the same method as stategen
|
||||
// to advance to the pre-state for the subsequent slot
|
||||
state, err = stategen.ReplayProcessSlots(ctx, state, slot+1)
|
||||
state, err := stategen.ReplayProcessSlots(ctx, st, slot+1)
|
||||
require.NoError(t, err)
|
||||
wanted, err = state.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// MockGenesisTimeFetcher is a fake implementation of the powchain.ChainInfoFetcher
|
||||
// MockPOWChainInfoFetcher is a fake implementation of the powchain.ChainInfoFetcher
|
||||
type MockPOWChainInfoFetcher struct {
|
||||
CurrEndpoint string
|
||||
CurrError error
|
||||
@ -12,11 +12,11 @@ type MockPOWChainInfoFetcher struct {
|
||||
Errors []error
|
||||
}
|
||||
|
||||
func (m *MockPOWChainInfoFetcher) Eth2GenesisPowchainInfo() (uint64, *big.Int) {
|
||||
func (*MockPOWChainInfoFetcher) Eth2GenesisPowchainInfo() (uint64, *big.Int) {
|
||||
return uint64(0), &big.Int{}
|
||||
}
|
||||
|
||||
func (m *MockPOWChainInfoFetcher) IsConnectedToETH1() bool {
|
||||
func (*MockPOWChainInfoFetcher) IsConnectedToETH1() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ func (f *FieldTrie) RecomputeTrie(indices []uint64, elements interface{}) ([32]b
|
||||
}
|
||||
// We remove the duplicates here in order to prevent
|
||||
// duplicated insertions into the trie.
|
||||
newIndices := []uint64{}
|
||||
var newIndices []uint64
|
||||
indexExists := make(map[uint64]bool)
|
||||
newRoots := make([][32]byte, 0, len(fieldRoots)/iNumOfElems)
|
||||
for i, idx := range indices {
|
||||
|
@ -374,7 +374,7 @@ func handleBalanceSlice(val, indices []uint64, convertAll bool) ([][32]byte, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
roots := [][32]byte{}
|
||||
var roots [][32]byte
|
||||
for _, idx := range indices {
|
||||
// We split the indexes into their relevant groups. Balances
|
||||
// are compressed according to 4 values -> 1 chunk.
|
||||
|
@ -10,7 +10,7 @@ var _ fssz.HashRoot = (HistoricalRoots)([][32]byte{})
|
||||
var _ fssz.Marshaler = (*HistoricalRoots)(nil)
|
||||
var _ fssz.Unmarshaler = (*HistoricalRoots)(nil)
|
||||
|
||||
// Byte32 represents a 32 bytes HistoricalRoots object in Ethereum beacon chain consensus.
|
||||
// HistoricalRoots represents a 32 bytes HistoricalRoots object in Ethereum beacon chain consensus.
|
||||
type HistoricalRoots [][32]byte
|
||||
|
||||
// HashTreeRoot returns calculated hash root.
|
||||
|
@ -23,7 +23,7 @@ func NewMockService() *MockStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
// StateByRootIfCachedNoCopy
|
||||
// StateByRootIfCachedNoCopy --
|
||||
func (_ *MockStateManager) StateByRootIfCachedNoCopy(_ [32]byte) state.BeaconState {
|
||||
panic("implement me")
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ func TestCommitteeIndex_Casting(t *testing.T) {
|
||||
t.Errorf("Unequal: %v = %v", CommitteeIndex(x1), committeeIdx)
|
||||
}
|
||||
|
||||
var x2 float64 = 42.2
|
||||
var x2 = 42.2
|
||||
if CommitteeIndex(x2) != committeeIdx {
|
||||
t.Errorf("Unequal: %v = %v", CommitteeIndex(x2), committeeIdx)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("int", func(t *testing.T) {
|
||||
var x int = 42
|
||||
var x = 42
|
||||
if CommitteeIndex(x) != committeeIdx {
|
||||
t.Errorf("Unequal: %v = %v", CommitteeIndex(x), committeeIdx)
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ func TestSlot_Casting(t *testing.T) {
|
||||
t.Errorf("Unequal: %v = %v", types.Slot(x1), slot)
|
||||
}
|
||||
|
||||
var x2 float64 = 42.2
|
||||
var x2 = 42.2
|
||||
if types.Slot(x2) != slot {
|
||||
t.Errorf("Unequal: %v = %v", types.Slot(x2), slot)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("int", func(t *testing.T) {
|
||||
var x int = 42
|
||||
var x = 42
|
||||
if types.Slot(x) != slot {
|
||||
t.Errorf("Unequal: %v = %v", types.Slot(x), slot)
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ func TestValidatorIndex_Casting(t *testing.T) {
|
||||
t.Errorf("Unequal: %v = %v", ValidatorIndex(x1), valIdx)
|
||||
}
|
||||
|
||||
var x2 float64 = 42.2
|
||||
var x2 = 42.2
|
||||
if ValidatorIndex(x2) != valIdx {
|
||||
t.Errorf("Unequal: %v = %v", ValidatorIndex(x2), valIdx)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("int", func(t *testing.T) {
|
||||
var x int = 42
|
||||
var x = 42
|
||||
if ValidatorIndex(x) != valIdx {
|
||||
t.Errorf("Unequal: %v = %v", ValidatorIndex(x), valIdx)
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ func TestBellatrixBeaconBlock_IsNil(t *testing.T) {
|
||||
assert.Equal(t, false, wb.IsNil())
|
||||
}
|
||||
|
||||
func TesTBellatrixBeaconBlock_IsBlinded(t *testing.T) {
|
||||
func TestBellatrixBeaconBlock_IsBlinded(t *testing.T) {
|
||||
wsb, err := wrapper.WrappedBeaconBlock(ðpb.BeaconBlockBellatrix{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, wsb.IsNil())
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
)
|
||||
|
||||
// NewDepositContractcallFromBoundContract creates a new instance of DepositContractCaller, bound to
|
||||
// NewDepositContractCallerFromBoundContract creates a new instance of DepositContractCaller, bound to
|
||||
// a specific deployed contract.
|
||||
func NewDepositContractCallerFromBoundContract(contract *bind.BoundContract) DepositContractCaller {
|
||||
return DepositContractCaller{contract: contract}
|
||||
|
@ -44,7 +44,7 @@ func TestAggregateVerify(t *testing.T) {
|
||||
func TestAggregateVerify_CompressedSignatures(t *testing.T) {
|
||||
pubkeys := make([]common.PublicKey, 0, 100)
|
||||
sigs := make([]common.Signature, 0, 100)
|
||||
sigBytes := [][]byte{}
|
||||
var sigBytes [][]byte
|
||||
var msgs [][32]byte
|
||||
for i := 0; i < 100; i++ {
|
||||
msg := [32]byte{'h', 'e', 'l', 'l', 'o', byte(i)}
|
||||
|
@ -49,7 +49,7 @@ func TestCopySignatureSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
keys := []SecretKey{}
|
||||
var keys []SecretKey
|
||||
for i := 0; i < 100; i++ {
|
||||
key, err := RandKey()
|
||||
assert.NoError(t, err)
|
||||
@ -73,9 +73,9 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
chosenKeys := keys[:20]
|
||||
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -105,9 +105,9 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -149,9 +149,9 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -190,9 +190,9 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -242,9 +242,9 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -328,7 +328,7 @@ func TestSignatureBatch_RemoveDuplicates(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
keys := []SecretKey{}
|
||||
var keys []SecretKey
|
||||
for i := 0; i < 100; i++ {
|
||||
key, err := RandKey()
|
||||
assert.NoError(t, err)
|
||||
@ -353,9 +353,9 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
chosenKeys := keys[:20]
|
||||
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -383,9 +383,9 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
chosenKeys := keys[:20]
|
||||
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -409,9 +409,9 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -459,9 +459,9 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
msg := [32]byte{'r', 'a', 'n', 'd', 'o', 'm'}
|
||||
msg1 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '1'}
|
||||
msg2 := [32]byte{'r', 'a', 'n', 'd', 'o', 'm', '2'}
|
||||
signatures := [][]byte{}
|
||||
messages := [][32]byte{}
|
||||
pubs := []PublicKey{}
|
||||
var signatures [][]byte
|
||||
var messages [][32]byte
|
||||
var pubs []PublicKey
|
||||
for _, k := range chosenKeys[:10] {
|
||||
s := k.Sign(msg[:])
|
||||
signatures = append(signatures, s.Marshal())
|
||||
@ -485,7 +485,7 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
messages[15][31] ^= byte(100)
|
||||
messages[25][31] ^= byte(100)
|
||||
|
||||
newSigs := [][]byte{}
|
||||
var newSigs [][]byte
|
||||
newSigs = append(newSigs, signatures[:5]...)
|
||||
newSigs = append(newSigs, signatures[6:10]...)
|
||||
|
||||
@ -504,7 +504,7 @@ func TestSignatureBatch_AggregateBatch(t *testing.T) {
|
||||
aggSig3, err := AggregateCompressedSignatures(newSigs)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newPubs := []PublicKey{}
|
||||
var newPubs []PublicKey
|
||||
newPubs = append(newPubs, pubs[:5]...)
|
||||
newPubs = append(newPubs, pubs[6:10]...)
|
||||
|
||||
|
@ -78,7 +78,7 @@ type LighthouseBeaconNode struct {
|
||||
enr string
|
||||
}
|
||||
|
||||
// NewBeaconNode creates and returns a beacon node.
|
||||
// NewLighthouseBeaconNode creates and returns a lighthouse beacon node.
|
||||
func NewLighthouseBeaconNode(config *e2etypes.E2EConfig, index int, enr string) *LighthouseBeaconNode {
|
||||
return &LighthouseBeaconNode{
|
||||
config: config,
|
||||
|
@ -125,9 +125,9 @@ func validatorsParticipating(conns ...*grpc.ClientConn) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get beacon state")
|
||||
}
|
||||
missSrcVals := []uint64{}
|
||||
missTgtVals := []uint64{}
|
||||
missHeadVals := []uint64{}
|
||||
var missSrcVals []uint64
|
||||
var missTgtVals []uint64
|
||||
var missHeadVals []uint64
|
||||
switch obj := st.Data.State.(type) {
|
||||
case *eth.BeaconStateContainer_Phase0State:
|
||||
// Do Nothing
|
||||
@ -273,9 +273,9 @@ func findMissingValidators(participation []byte) ([]uint64, []uint64, []uint64,
|
||||
sourceFlagIndex := cfg.TimelySourceFlagIndex
|
||||
targetFlagIndex := cfg.TimelyTargetFlagIndex
|
||||
headFlagIndex := cfg.TimelyHeadFlagIndex
|
||||
missingSourceValidators := []uint64{}
|
||||
missingHeadValidators := []uint64{}
|
||||
missingTargetValidators := []uint64{}
|
||||
var missingSourceValidators []uint64
|
||||
var missingHeadValidators []uint64
|
||||
var missingTargetValidators []uint64
|
||||
for i, b := range participation {
|
||||
hasSource, err := altair.HasValidatorFlag(b, sourceFlagIndex)
|
||||
if err != nil {
|
||||
|
@ -78,7 +78,7 @@ func GenerateAttestations(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headState = state.BeaconState(genState)
|
||||
headState = genState
|
||||
case version.Altair:
|
||||
pbState, err := v2.ProtobufBeaconState(bState.CloneInnerState())
|
||||
if err != nil {
|
||||
@ -88,7 +88,7 @@ func GenerateAttestations(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headState = state.BeaconState(genState)
|
||||
headState = genState
|
||||
default:
|
||||
return nil, errors.New("state type isn't supported")
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
|
||||
)
|
||||
|
||||
// Deletes the accounts that the user requests to be deleted from the wallet.
|
||||
// Delete the accounts that the user requests to be deleted from the wallet.
|
||||
func (acm *AccountsCLIManager) Delete(ctx context.Context) error {
|
||||
rawPublicKeys := make([][]byte, len(acm.filteredPubKeys))
|
||||
formattedPubKeys := make([]string, len(acm.filteredPubKeys))
|
||||
|
@ -82,7 +82,7 @@ func TestUpdateLogAggregateStats(t *testing.T) {
|
||||
if i == len(responses)-1 { // Handle last log.
|
||||
hook = logTest.NewGlobal()
|
||||
}
|
||||
v.UpdateLogAggregateStats(val, types.Slot(params.BeaconConfig().SlotsPerEpoch*types.Slot(i+1)))
|
||||
v.UpdateLogAggregateStats(val, params.BeaconConfig().SlotsPerEpoch*types.Slot(i+1))
|
||||
}
|
||||
|
||||
require.LogsContain(t, hook, "msg=\"Previous epoch aggregated voting summary\" attestationInclusionPct=\"67%\" "+
|
||||
|
@ -241,7 +241,7 @@ func (v *ValidatorService) Status() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UseInteropKeys returns the useInteropKeys flag.
|
||||
// InteropKeysConfig returns the useInteropKeys flag.
|
||||
func (v *ValidatorService) InteropKeysConfig() *local.InteropKeymanagerConfig {
|
||||
return v.interopKeysConfig
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (fv *FakeValidator) Done() {
|
||||
fv.DoneCalled = true
|
||||
}
|
||||
|
||||
// WaitForWalletInitialization for mocking.
|
||||
// WaitForKeymanagerInitialization for mocking.
|
||||
func (fv *FakeValidator) WaitForKeymanagerInitialization(_ context.Context) error {
|
||||
fv.WaitForWalletInitializationCalled = true
|
||||
return nil
|
||||
|
@ -170,12 +170,12 @@ func MapProposerSlashing(slashing *ethpb.ProposerSlashing) (*ProposerSlashing, e
|
||||
return nil, errors.Wrap(err, "could not map signed header 2")
|
||||
}
|
||||
return &ProposerSlashing{
|
||||
SignedHeader_1: signedHeader1,
|
||||
SignedHeader_2: signedHeader2,
|
||||
Signedheader1: signedHeader1,
|
||||
Signedheader2: signedHeader2,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MapAttesterSlashing maps the eth2.AttesterSlashing proto to the Web3Signer spec.
|
||||
// MapSignedBeaconBlockHeader maps the eth2.AttesterSlashing proto to the Web3Signer spec.
|
||||
func MapSignedBeaconBlockHeader(signedHeader *ethpb.SignedBeaconBlockHeader) (*SignedBeaconBlockHeader, error) {
|
||||
if signedHeader == nil {
|
||||
return nil, fmt.Errorf("signed beacon block header is nil")
|
||||
@ -217,8 +217,8 @@ func MapAttesterSlashing(slashing *ethpb.AttesterSlashing) (*AttesterSlashing, e
|
||||
return nil, errors.Wrap(err, "could not map attestation 2")
|
||||
}
|
||||
return &AttesterSlashing{
|
||||
Attestation_1: attestation1,
|
||||
Attestation_2: attestation2,
|
||||
Attestation1: attestation1,
|
||||
Attestation2: attestation2,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,8 @@ func TestMapAttesterSlashing(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &v1.AttesterSlashing{
|
||||
Attestation_1: mock.MockIndexedAttestation(),
|
||||
Attestation_2: mock.MockIndexedAttestation(),
|
||||
Attestation1: mock.MockIndexedAttestation(),
|
||||
Attestation2: mock.MockIndexedAttestation(),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
@ -208,8 +208,8 @@ func TestMapAttesterSlashing(t *testing.T) {
|
||||
t.Errorf("MapAttesterSlashing() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got.Attestation_1, tt.want.Attestation_1) {
|
||||
t.Errorf("MapAttesterSlashing() got = %v, want %v", got.Attestation_1, tt.want.Attestation_1)
|
||||
if !reflect.DeepEqual(got.Attestation1, tt.want.Attestation1) {
|
||||
t.Errorf("MapAttesterSlashing() got = %v, want %v", got.Attestation1, tt.want.Attestation1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ func MockBeaconBlockAltair() *v1.BeaconBlockAltair {
|
||||
Graffiti: hexutil.Encode(make([]byte, 32)),
|
||||
ProposerSlashings: []*v1.ProposerSlashing{
|
||||
{
|
||||
SignedHeader_1: &v1.SignedBeaconBlockHeader{
|
||||
Signedheader1: &v1.SignedBeaconBlockHeader{
|
||||
Message: &v1.BeaconBlockHeader{
|
||||
Slot: "0",
|
||||
ProposerIndex: "0",
|
||||
@ -643,7 +643,7 @@ func MockBeaconBlockAltair() *v1.BeaconBlockAltair {
|
||||
},
|
||||
Signature: hexutil.Encode(make([]byte, fieldparams.BLSSignatureLength)),
|
||||
},
|
||||
SignedHeader_2: &v1.SignedBeaconBlockHeader{
|
||||
Signedheader2: &v1.SignedBeaconBlockHeader{
|
||||
Message: &v1.BeaconBlockHeader{
|
||||
Slot: "0",
|
||||
ProposerIndex: "0",
|
||||
@ -657,8 +657,8 @@ func MockBeaconBlockAltair() *v1.BeaconBlockAltair {
|
||||
},
|
||||
AttesterSlashings: []*v1.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: MockIndexedAttestation(),
|
||||
Attestation_2: MockIndexedAttestation(),
|
||||
Attestation1: MockIndexedAttestation(),
|
||||
Attestation2: MockIndexedAttestation(),
|
||||
},
|
||||
},
|
||||
Attestations: []*v1.Attestation{
|
||||
@ -703,7 +703,7 @@ func MockBeaconBlockBody() *v1.BeaconBlockBody {
|
||||
Graffiti: hexutil.Encode(make([]byte, 32)),
|
||||
ProposerSlashings: []*v1.ProposerSlashing{
|
||||
{
|
||||
SignedHeader_1: &v1.SignedBeaconBlockHeader{
|
||||
Signedheader1: &v1.SignedBeaconBlockHeader{
|
||||
Message: &v1.BeaconBlockHeader{
|
||||
Slot: "0",
|
||||
ProposerIndex: "0",
|
||||
@ -713,7 +713,7 @@ func MockBeaconBlockBody() *v1.BeaconBlockBody {
|
||||
},
|
||||
Signature: hexutil.Encode(make([]byte, fieldparams.BLSSignatureLength)),
|
||||
},
|
||||
SignedHeader_2: &v1.SignedBeaconBlockHeader{
|
||||
Signedheader2: &v1.SignedBeaconBlockHeader{
|
||||
Message: &v1.BeaconBlockHeader{
|
||||
Slot: "0",
|
||||
ProposerIndex: "0",
|
||||
@ -727,8 +727,8 @@ func MockBeaconBlockBody() *v1.BeaconBlockBody {
|
||||
},
|
||||
AttesterSlashings: []*v1.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: MockIndexedAttestation(),
|
||||
Attestation_2: MockIndexedAttestation(),
|
||||
Attestation1: MockIndexedAttestation(),
|
||||
Attestation2: MockIndexedAttestation(),
|
||||
},
|
||||
},
|
||||
Attestations: []*v1.Attestation{
|
||||
|
@ -10,7 +10,7 @@ type AggregationSlotSignRequest struct {
|
||||
AggregationSlot *AggregationSlot `json:"aggregation_slot" validate:"required"`
|
||||
}
|
||||
|
||||
// AggregationSlotSignRequest is a request object for web3signer sign api.
|
||||
// AggregateAndProofSignRequest is a request object for web3signer sign api.
|
||||
type AggregateAndProofSignRequest struct {
|
||||
Type string `json:"type" validate:"required"`
|
||||
ForkInfo *ForkInfo `json:"fork_info" validate:"required"`
|
||||
@ -183,9 +183,9 @@ type Eth1Data struct {
|
||||
// ProposerSlashing a sub property of BeaconBlockBody.
|
||||
type ProposerSlashing struct {
|
||||
// Prysm uses Header_1 but web3signer uses signed_header_1.
|
||||
SignedHeader_1 *SignedBeaconBlockHeader `json:"signed_header_1"`
|
||||
Signedheader1 *SignedBeaconBlockHeader `json:"signed_header_1"`
|
||||
// Prysm uses Header_2 but web3signer uses signed_header_2.
|
||||
SignedHeader_2 *SignedBeaconBlockHeader `json:"signed_header_2"`
|
||||
Signedheader2 *SignedBeaconBlockHeader `json:"signed_header_2"`
|
||||
}
|
||||
|
||||
// SignedBeaconBlockHeader is a sub property of ProposerSlashing.
|
||||
@ -205,8 +205,8 @@ type BeaconBlockHeader struct {
|
||||
|
||||
// AttesterSlashing a sub property of BeaconBlockBody.
|
||||
type AttesterSlashing struct {
|
||||
Attestation_1 *IndexedAttestation `json:"attestation_1"`
|
||||
Attestation_2 *IndexedAttestation `json:"attestation_2"`
|
||||
Attestation1 *IndexedAttestation `json:"attestation_1"`
|
||||
Attestation2 *IndexedAttestation `json:"attestation_2"`
|
||||
}
|
||||
|
||||
// IndexedAttestation a sub property of AttesterSlashing.
|
||||
|
Loading…
Reference in New Issue
Block a user