mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-09 20:41:20 +00:00
529d359ca6
An update to the devnet to introduce a local heimdall to facilitate multiple validators without the need for an external process, and hence validator registration/staking etc. In this initial release only span generation is supported. It has the following changes: * Introduction of a local grpc heimdall interface * Allocation of accounts via a devnet account generator () * Introduction on 'Services' for the network config "--chain bor-devnet --bor.localheimdall" will run a 2 validator network with a local service "--chain bor-devnet --bor.withoutheimdall" will sun a single validator with no heimdall service as before --------- Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package accounts_steps
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/devnet"
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/requests"
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/scenarios"
|
|
)
|
|
|
|
func init() {
|
|
scenarios.MustRegisterStepHandlers(
|
|
scenarios.StepHandler(GetBalance),
|
|
scenarios.StepHandler(GetNonce),
|
|
)
|
|
}
|
|
|
|
//const (
|
|
// addr = "0x71562b71999873DB5b286dF957af199Ec94617F7"
|
|
//)
|
|
|
|
func GetBalance(ctx context.Context, addr string, blockNum requests.BlockNumber) (uint64, error) {
|
|
logger := devnet.Logger(ctx)
|
|
|
|
node := devnet.CurrentNode(ctx)
|
|
|
|
if node == nil {
|
|
node = devnet.SelectBlockProducer(ctx)
|
|
}
|
|
|
|
logger.Info("Getting balance", "addess", addr)
|
|
address := libcommon.HexToAddress(addr)
|
|
|
|
bal, err := node.GetBalance(address, blockNum)
|
|
|
|
if err != nil {
|
|
logger.Error("FAILURE", "error", err)
|
|
return 0, err
|
|
}
|
|
|
|
logger.Info("SUCCESS", "balance", bal)
|
|
|
|
return bal, nil
|
|
}
|
|
|
|
func GetNonce(ctx context.Context, address libcommon.Address) (uint64, error) {
|
|
node := devnet.CurrentNode(ctx)
|
|
|
|
if node == nil {
|
|
node = devnet.SelectBlockProducer(ctx)
|
|
}
|
|
|
|
res, err := node.GetTransactionCount(address, requests.BlockNumbers.Latest)
|
|
|
|
if err != nil {
|
|
return 0, fmt.Errorf("failed to get transaction count for address 0x%x: %v", address, err)
|
|
}
|
|
|
|
return res.Uint64(), nil
|
|
}
|