prysm-pulse/testing/endtoend/evaluators/fee_recipient.go

181 lines
5.8 KiB
Go
Raw Normal View History

E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
package evaluators
import (
"bytes"
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v5/config/params"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v5/runtime/interop"
"github.com/prysmaticlabs/prysm/v5/testing/endtoend/components"
e2e "github.com/prysmaticlabs/prysm/v5/testing/endtoend/params"
"github.com/prysmaticlabs/prysm/v5/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/v5/testing/endtoend/types"
log "github.com/sirupsen/logrus"
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
)
var FeeRecipientIsPresent = types.Evaluator{
Name: "fee_recipient_is_present_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().BellatrixForkEpoch
return policies.AfterNthEpoch(fEpoch)(e)
},
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
Evaluation: feeRecipientIsPresent,
}
func lhKeyMap() (map[string]bool, error) {
if e2e.TestParams.LighthouseBeaconNodeCount == 0 {
return nil, nil
}
pry, lh := e2e.TestParams.BeaconNodeCount, e2e.TestParams.LighthouseBeaconNodeCount
valPerNode := int(params.BeaconConfig().MinGenesisActiveValidatorCount) / (pry + lh)
lhOff := valPerNode * pry
_, keys, err := interop.DeterministicallyGenerateKeys(uint64(lhOff), uint64(valPerNode*lh))
if err != nil {
return nil, err
}
km := make(map[string]bool)
for _, k := range keys {
km[hexutil.Encode(k.Marshal())] = true
}
return km, nil
}
func valKeyMap() (map[string]bool, error) {
nvals := params.BeaconConfig().MinGenesisActiveValidatorCount
// matches validator start in validator component + validators used for deposits
_, pubs, err := interop.DeterministicallyGenerateKeys(0, nvals+e2e.DepositCount)
if err != nil {
return nil, err
}
km := make(map[string]bool)
for _, k := range pubs {
km[hexutil.Encode(k.Marshal())] = true
}
return km, nil
}
func feeRecipientIsPresent(_ *types.EvaluationContext, conns ...*grpc.ClientConn) error {
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
conn := conns[0]
client := ethpb.NewBeaconChainClient(conn)
chainHead, err := client.GetChainHead(context.Background(), &emptypb.Empty{})
if err != nil {
return errors.Wrap(err, "failed to get chain head")
}
req := &ethpb.ListBlocksRequest{QueryFilter: &ethpb.ListBlocksRequest_Epoch{Epoch: chainHead.HeadEpoch.Sub(1)}}
blks, err := client.ListBeaconBlocks(context.Background(), req)
if err != nil {
return errors.Wrap(err, "failed to list blocks")
}
rpcclient, err := rpc.DialHTTP(fmt.Sprintf("http://127.0.0.1:%d", e2e.TestParams.Ports.Eth1RPCPort))
if err != nil {
return err
}
defer rpcclient.Close()
valkeys, err := valKeyMap()
if err != nil {
return err
}
lhkeys, err := lhKeyMap()
if err != nil {
return err
}
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
for _, ctr := range blks.BlockContainers {
if ctr.GetBellatrixBlock() != nil {
bb := ctr.GetBellatrixBlock().Block
payload := bb.Body.ExecutionPayload
// If the beacon chain has transitioned to Bellatrix, but the EL hasn't hit TTD, we could see a few slots
// of blocks with empty payloads.
if bytes.Equal(payload.BlockHash, make([]byte, 32)) {
continue
}
if len(payload.FeeRecipient) == 0 || hexutil.Encode(payload.FeeRecipient) == params.BeaconConfig().EthBurnAddressHex {
log.WithField("proposerIndex", bb.ProposerIndex).WithField("slot", bb.Slot).Error("fee recipient eval bug")
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
return errors.New("fee recipient is not set")
}
fr := common.BytesToAddress(payload.FeeRecipient)
gvr := &ethpb.GetValidatorRequest{
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
QueryFilter: &ethpb.GetValidatorRequest_Index{
Index: ctr.GetBellatrixBlock().Block.ProposerIndex,
},
}
validator, err := client.GetValidator(context.Background(), gvr)
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
if err != nil {
return errors.Wrap(err, "failed to get validators")
}
pk := hexutil.Encode(validator.GetPublicKey())
if _, ok := lhkeys[pk]; ok {
// Don't check lighthouse keys.
continue
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
}
// In e2e we generate deterministic keys by validator index, and then use a slice of their public key bytes
// as the fee recipient, so that this will also be deterministic, so this test can statelessly verify it.
// These should be the only keys we see.
// Otherwise something has changed in e2e and this test needs to be updated.
_, knownKey := valkeys[pk]
if !knownKey {
log.WithField("pubkey", pk).
WithField("slot", bb.Slot).
WithField("proposerIndex", bb.ProposerIndex).
WithField("feeRecipient", fr.Hex()).
Warn("unknown key observed, not a deterministically generated key")
return errors.New("unknown key observed, not a deterministically generated key")
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
}
if components.FeeRecipientFromPubkey(pk) != fr.Hex() {
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
return fmt.Errorf("publickey %s, fee recipient %s does not match the proposer settings fee recipient %s",
pk, fr.Hex(), components.FeeRecipientFromPubkey(pk))
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
}
if err := checkRecipientBalance(rpcclient, common.BytesToHash(payload.BlockHash), common.BytesToHash(payload.ParentHash), fr); err != nil {
E2E: fee-recipient evaluator (#10528) * testing out fee-recipient evaluator * fixing bazel linter * adjusting comparison * typo on file rolling back * adding fee recipient is present to minimal e2e * fixing gofmt * fixing gofmt * fixing flag usage name * adding in log to help debug * fixing log build * trying to figure out why suggested fee recipient isn't working in e2e, adding more logging temporarily * rolling back logs * making e2e test more dynamic * fixing deepsource issue * fixing bazel * adding in condition for latest release * duplicate condtion check. * fixing gofmt * rolling back changes * adding fee recipient evaluator in new file * fixing validator component logic * testing rpc client addition * testing fee recipient evaluator * fixing bazel: * testing casting * test casting * reverting * testing casting * testing casting * testing log * adding bazel fix * switching mixed case and adding temp logging * fixing gofmt * rolling back changes * removing fee recipient evaluator when web3signer is used * test only minimal config * reverting changes * adding fee recipient evaluator to mainnet * current version uses wrong flag name * optimizing key usage * making mining address a variable * moving from global to local variable * removing unneeded log * removing redundant check * make proposer settings mroe deterministic and also have the evaluator compare the wanting values * fixing err return * fixing bazel * checking file too much moving it out * fixing gosec * trying to fix gosec error * trying to fix address * fixing linting * trying to gerenate key and random address * fixing linting * fixing check for proposer config * trying with multi config files * fixing is dir check * testing for older previous balance * adding logging to help debug * changing how i get the block numbers * fixing missed error check * adding gasused check * adding log for current gas used * taking suggestion to make fee recipient more deterministic * fixing linting * fixing check * fixing the address check * fixing format error * logic to differentiate recipients * fixing linting
2022-06-30 00:24:39 +00:00
return err
}
}
}
return nil
}
func checkRecipientBalance(c *rpc.Client, block, parent common.Hash, account common.Address) error {
web3 := ethclient.NewClient(c)
ctx := context.Background()
b, err := web3.BlockByHash(ctx, block)
if err != nil {
return err
}
bal, err := web3.BalanceAt(ctx, account, b.Number())
if err != nil {
return err
}
pBlock, err := web3.BlockByHash(ctx, parent)
if err != nil {
return err
}
pBal, err := web3.BalanceAt(ctx, account, pBlock.Number())
if err != nil {
return err
}
if b.GasUsed() > 0 && bal.Uint64() <= pBal.Uint64() {
return errors.Errorf("account balance didn't change after applying fee recipient for account: %s", account.Hex())
}
return nil
}