common

package
v0.0.0-...-2d42763 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package common is a helper around redundant creation of Network, App and Node part

As testground doesn't have native support of uint64 conversion from .toml files, GetBandwidthValue in network.go is used to adjust the bandwidth per instance for each of the test-case

In order to eliminate the boilerplate code of creating a validators' set, please use `common.BuildValidator`. This Func does: - InitChain - Add-Gen-Account - Collect-GenTxs - Add-Persistent-Peers In addition, the func returns initialized cobra cmd, so you can continue operating with the validator

Default: network.LinkShape{
	Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")),
}

appcmd, err := common.BuildValidator(ctx, runenv, initCtx) appcmd.PayForBlob(...)

In order to eliminate the boilerplate code of creating a bridge node, please use `common.BuildBridge`. This Func does: - Listens to all available validators - Connects to the validator (match is done using group sequence) - Sends the genesis hash to the topic - - As well as it's multiaddress - Returns the node pointer itself

nd, err := common.BuildBridge(ctx, runenv, initCtx) nd.Stop()

Index

Constants

View Source
const (
	// EVMPrivateKeyPassphrase the EVM keystore passphrase that will be used when storing all EVM keys
	EVMPrivateKeyPassphrase = "123"
	// P2PPrivateKeyNickname the P2P private key nickname that will be used when storing all P2P keys
	P2PPrivateKeyNickname = "key"
)

Variables

View Source
var DefaultNameId = namespace.ID{100, 100, 150, 150, 200, 200, 250, 255}

DefaultNameId is used in cases where we only have 1 Namespace.ID used across all nodes that submit pfd and get shares by this ID

Functions

func BroadcastAndCollectGenTx

func BroadcastAndCollectGenTx(ctx context.Context, home string, accAddr string, initCtx *run.InitContext, runenv *runtime.RunEnv, cmd *appkit.AppKit) error

func BuildBridge

func BuildBridge(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext, opts ...fx.Option) (*nodebuilder.Node, error)

func BuildOrchestrator

func BuildOrchestrator(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) (*qgbkit.QGBKit, error)

func BuildRelayer

func BuildRelayer(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) (*qgbkit.QGBKit, error)

func BuildValidator

func BuildValidator(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) (*appkit.AppKit, error)

func CheckBalanceDeduction

func CheckBalanceDeduction(ctx context.Context, nd *nodebuilder.Node, bal *state.Balance) error

CheckBalanceDeduction checks if the balance of a node has been deducted after a successful pfb

func CheckSharesByNamespace

func CheckSharesByNamespace(ctx context.Context, nd *nodebuilder.Node, nid namespace.ID, eh *header.ExtendedHeader, expectedData []byte) error

CheckSharesByNamespace accepts an expected namespace.ID and data that was submitted. Next, it verifies the data against the received shares of a block from a user-specified extended header by comparing length of each

func DiscoverPeers

func DiscoverPeers(ctx context.Context, home string, ip net.IP, initCtx *run.InitContext, runenv *runtime.RunEnv) error

func ECDSAToAddress

func ECDSAToAddress(ethPrivateKey *ecdsa.PrivateKey) *common.Address

func GenerateEVMAddress

func GenerateEVMAddress() (*common.Address, *ecdsa.PrivateKey, error)

func GenerateNamespaceID

func GenerateNamespaceID(amount string) namespace.ID

GenerateNamespaceID returns a namespace ID based on runenv.StringParams defined in the composition file TODO(@Bidon15): We actually need to refactor this out using runenv.IntParam()

func GetBandwidthValue

func GetBandwidthValue(v string) uint64

func GetBridgeNode

func GetBridgeNode(ctx context.Context, syncclient sync.Client, id int64, amountOfBridges int) (*testkit.BridgeNodeInfo, error)

func GetBridgeNodes

func GetBridgeNodes(
	ctx context.Context,
	syncclient sync.Client,
	amountOfBridges int,
) (
	bridges []*testkit.BridgeNodeInfo,
	err error,
)

func GetRandomMessageBySize

func GetRandomMessageBySize(size int) []byte

GetRandomMessageBySize returns a random []byte per each call made by each instance of node type. The size is defined in the .toml file

func GetRandomNamespace

func GetRandomNamespace() namespace.ID

GetRandomNamespace returns a random namespace.ID per each call made by each instance of node type

func GetRandomisedPeers

func GetRandomisedPeers(randomizer int, peersRange int, peers []appkit.ValidatorNode) []appkit.ValidatorNode

func GetValidatorInfo

func GetValidatorInfo(ctx context.Context, syncclient sync.Client, valAmount, id int) (*testkit.AppNodeInfo, error)

func InitChainAndMaybeBroadcastGenesis

func InitChainAndMaybeBroadcastGenesis(
	ctx context.Context,
	runenv *runtime.RunEnv,
	initCtx *run.InitContext,
	home string,
) (*appkit.AppKit, string, string, error)

func SubmitData

func SubmitData(ctx context.Context, runenv *runtime.RunEnv, nd *nodebuilder.Node, nid namespace.ID, data []byte) error

SubmitData calls a node.StateService SubmitPayForBlob() method with recording a txLog output.

func UpdateAndPublishConfig

func UpdateAndPublishConfig(
	ctx context.Context,
	home string,
	cmd *appkit.AppKit,
	initCtx *run.InitContext,
) (net.IP, error)

func VerifyDataInNamespace

func VerifyDataInNamespace(ctx context.Context, nd *nodebuilder.Node, nid namespace.ID, data []byte) error

VerifyDataInNamespace encapsulates 3 steps to get the data verified against the next block's shares found in a user-specified namespace.ID

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL