requester

package
v0.36.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const LatestBlockHeight uint64 = math.MaxUint64 - 1

Variables

This section is empty.

Functions

This section is empty.

Types

type CrossSporkClient added in v0.12.0

type CrossSporkClient struct {
	access.Client
	// contains filtered or unexported fields
}

CrossSporkClient is a wrapper around the Flow AN client that can access different AN APIs based on the height boundaries of the sporks.

Each spork is defined with the last height included in that spork, based on the list we know which AN client to use when requesting the data.

Any API that supports cross-spork access must have a defined function that shadows the original access Client function.

func NewCrossSporkClient added in v0.12.0

func NewCrossSporkClient(
	currentSpork access.Client,
	pastSporks []access.Client,
	logger zerolog.Logger,
	chainID flowGo.ChainID,
) (*CrossSporkClient, error)

NewCrossSporkClient creates a new instance of the multi-spork client. It requires the current spork client and a slice of past spork clients.

func (*CrossSporkClient) ExecuteScriptAtBlockHeight added in v0.12.0

func (c *CrossSporkClient) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	height uint64,
	script []byte,
	arguments []cadence.Value,
) (cadence.Value, error)

func (*CrossSporkClient) GetBlockHeaderByHeight added in v0.12.0

func (c *CrossSporkClient) GetBlockHeaderByHeight(
	ctx context.Context,
	height uint64,
) (*flow.BlockHeader, error)

func (*CrossSporkClient) GetLatestHeightForSpork added in v0.12.0

func (c *CrossSporkClient) GetLatestHeightForSpork(ctx context.Context, height uint64) (uint64, error)

GetLatestHeightForSpork will determine the spork client in which the provided height is contained and then find the latest height in that spork.

func (*CrossSporkClient) IsPastSpork added in v0.12.0

func (c *CrossSporkClient) IsPastSpork(height uint64) bool

IsPastSpork will check if the provided height is contained in the previous sporks.

func (*CrossSporkClient) SubscribeEventsByBlockHeight added in v0.12.0

func (c *CrossSporkClient) SubscribeEventsByBlockHeight(
	ctx context.Context,
	startHeight uint64,
	filter flow.EventFilter,
	opts ...access.SubscribeOption,
) (<-chan flow.BlockEvents, <-chan error, error)

type EVM

type EVM struct {
	// contains filtered or unexported fields
}

func NewEVM

func NewEVM(
	client *CrossSporkClient,
	config *config.Config,
	signer crypto.Signer,
	logger zerolog.Logger,
	blocks storage.BlockIndexer,
	txPool *TxPool,
	collector metrics.Collector,
) (*EVM, error)

func (*EVM) Call

func (e *EVM) Call(
	ctx context.Context,
	data []byte,
	from common.Address,
	evmHeight int64,
) ([]byte, error)

func (*EVM) EstimateGas

func (e *EVM) EstimateGas(
	ctx context.Context,
	data []byte,
	from common.Address,
	evmHeight int64,
) (uint64, error)

func (*EVM) GetBalance

func (e *EVM) GetBalance(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) (*big.Int, error)

func (*EVM) GetCode added in v0.2.0

func (e *EVM) GetCode(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) ([]byte, error)

func (*EVM) GetLatestEVMHeight added in v0.6.0

func (e *EVM) GetLatestEVMHeight(ctx context.Context) (uint64, error)

func (*EVM) GetNonce added in v0.2.0

func (e *EVM) GetNonce(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) (uint64, error)

func (*EVM) GetStorageAt added in v0.23.0

func (e *EVM) GetStorageAt(
	ctx context.Context,
	address common.Address,
	hash common.Hash,
	evmHeight int64,
) (common.Hash, error)

func (*EVM) SendRawTransaction

func (e *EVM) SendRawTransaction(ctx context.Context, data []byte) (common.Hash, error)

type KMSKeyRotationSigner added in v0.18.0

type KMSKeyRotationSigner struct {
	// contains filtered or unexported fields
}

KMSKeyRotationSigner is a crypto signer that contains a pool of `crypto.Signer`[1] objects, each of which is tied to a Cloud KMS asymmetric signing key. It keeps track of the signer/key combination that should be used for the next incoming signing request. This allows for faster submission of transactions to the network, due to a sequence number not being reused between different keys used. It also contains logic to queue up signature requests and in case there are more transactions pending than the keys in the pool it will wait for transactions to get executed so the new sequence key can be obtained. The signer is concurrency-safe.

[1](https://github.com/onflow/flow-go-sdk/blob/master/crypto/cloudkms/signer.go#L37)

func NewKMSKeyRotationSigner added in v0.18.0

func NewKMSKeyRotationSigner(
	ctx context.Context,
	keys []cloudkms.Key,
	logger zerolog.Logger,
) (*KMSKeyRotationSigner, error)

NewKMSKeyRotationSigner returns a new KMSKeyRotationSigner, for the given slice of Cloud KMS keys.

func (*KMSKeyRotationSigner) PublicKey added in v0.18.0

func (s *KMSKeyRotationSigner) PublicKey() crypto.PublicKey

PublicKey returns the current public key which is available for signing.

func (*KMSKeyRotationSigner) Sign added in v0.18.0

func (s *KMSKeyRotationSigner) Sign(message []byte) ([]byte, error)

Sign signs the message and then rotates to the next key. Note: if you want to get the public key pair, you should first call PublicKey and then Sign.

type KeyRotationSigner

type KeyRotationSigner struct {
	// contains filtered or unexported fields
}

KeyRotationSigner is a crypto signer that contains a pool of key pairs to sign with, and it rotates the key used for each signing request. This allows for faster submission of transactions to the network, due to a sequence number not being reused between different keys used. It also contains logic to queue up signature requests and in case there are more transactions pending than the keys in the pool it will wait for transactions to get executed so the new sequence key can be obtained. The signer is concurrency-safe.

func NewKeyRotationSigner

func NewKeyRotationSigner(keys []crypto.PrivateKey, hashAlgo crypto.HashAlgorithm) (*KeyRotationSigner, error)

func (*KeyRotationSigner) PublicKey

func (k *KeyRotationSigner) PublicKey() crypto.PublicKey

PublicKey returns the current public key which is available for signing.

func (*KeyRotationSigner) Sign

func (k *KeyRotationSigner) Sign(message []byte) ([]byte, error)

Sign signs the message and then rotates to the next key. note: if you want to get the public key pair, you should first call PublicKey and then Sign.

type Requester

type Requester interface {
	// SendRawTransaction will submit signed transaction data to the network.
	// The submitted EVM transaction hash is returned.
	SendRawTransaction(ctx context.Context, data []byte) (common.Hash, error)

	// GetBalance returns the amount of wei for the given address in the state of the
	// given EVM block height.
	GetBalance(ctx context.Context, address common.Address, evmHeight int64) (*big.Int, error)

	// Call executes the given signed transaction data on the state for the given EVM block height.
	// Note, this function doesn't make and changes in the state/blockchain and is
	// useful to execute and retrieve values.
	Call(ctx context.Context, data []byte, from common.Address, evmHeight int64) ([]byte, error)

	// EstimateGas executes the given signed transaction data on the state for the given EVM block height.
	// Note, this function doesn't make any changes in the state/blockchain and is
	// useful to executed and retrieve the gas consumption and possible failures.
	EstimateGas(ctx context.Context, data []byte, from common.Address, evmHeight int64) (uint64, error)

	// GetNonce gets nonce from the network at the given EVM block height.
	GetNonce(ctx context.Context, address common.Address, evmHeight int64) (uint64, error)

	// GetCode returns the code stored at the given address in
	// the state for the given EVM block height.
	GetCode(ctx context.Context, address common.Address, evmHeight int64) ([]byte, error)

	// GetLatestEVMHeight returns the latest EVM height of the network.
	GetLatestEVMHeight(ctx context.Context) (uint64, error)

	// GetStorageAt returns the storage from the state at the given address, key and block number.
	GetStorageAt(ctx context.Context, address common.Address, hash common.Hash, evmHeight int64) (common.Hash, error)
}

type TxPool added in v0.21.0

type TxPool struct {
	// contains filtered or unexported fields
}

func NewTxPool added in v0.21.0

func NewTxPool(
	client *CrossSporkClient,
	transactionsPublisher *models.Publisher,
	logger zerolog.Logger,
) *TxPool

func (*TxPool) Send added in v0.21.0

func (t *TxPool) Send(
	ctx context.Context,
	flowTx *flow.Transaction,
	evmTx *gethTypes.Transaction,
) error

Send flow transaction that executes EVM run function which takes in the encoded EVM transaction. The flow transaction status is awaited and an error is returned in case of a failure in submission, or an EVM validation error. Until the flow transaction is sealed the transaction will stay in the transaction pool marked as pending.

Jump to

Keyboard shortcuts

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