executor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGasPrice                = 20000000000 // 20 GWei
	FallBehindThreshold            = 5
	SleepSecondForUpdateClient     = 10
	DataSeedDenyServiceThreshold   = 60
	RPCTimeout                     = 3 * time.Second
	RelayerBytesLength             = 128
	UpdateCachedValidatorsInterval = 1 * time.Minute
	ClaimRewardInterval            = 1 * time.Minute
	MaxTxSizeForFixGasLimit        = 32768 // 32kb
	EstimatedTxExtraMetaSize       = 1024  // in bytes
	GnfdGasPrice                   = int64(5000000000)
	GasLimitRatio                  = int64(10)
)

Variables

View Source
var (
	BSCBalanceThreshold = big.NewInt(1) // when relayer is lower than 1BNB, it should try to claim rewards
	BNBDecimal          = big.NewInt(1000000000000000000)

	BSCRewardThreshold = big.NewInt(100000000000000000) // if reward is lower than 0.1 BNB, it will not be claimed.
)

Functions

func ApplyLightBlock

func ApplyLightBlock(cs *ConsensusState, block *tmtypes.LightBlock) (bool, error)

func EncodeLightBlockValidationResult

func EncodeLightBlockValidationResult(validatorSetChanged bool, consensusStateBytes []byte) []byte

output: | validatorSetChanged | empty | consensusStateBytesLength | new consensusState | | 1 byte | 23 bytes | 8 bytes | |

func GetTestConfig

func GetTestConfig() *config.Config

func InitExecutors

func InitExecutors() (*BSCExecutor, *GreenfieldExecutor)

Types

type BSCClient

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

type BSCExecutor

type BSCExecutor struct {
	GreenfieldExecutor *GreenfieldExecutor
	// contains filtered or unexported fields
}

func NewBSCExecutor

func NewBSCExecutor(cfg *config.Config, metricService *metric.MetricService) *BSCExecutor

func (*BSCExecutor) CallBuildInSystemContract

func (e *BSCExecutor) CallBuildInSystemContract(blsSignature []byte, validatorSet *big.Int, msgBytes []byte, nonce uint64) (common.Hash, error)

func (*BSCExecutor) ClaimRewardLoop

func (e *BSCExecutor) ClaimRewardLoop()

ClaimRewardLoop relayer would claim the reward if its balance is below 1BNB and the Reward is over 0.1BNB. if after refilled with the rewards, its balance is still lower than 1BNB, it will keep alerting

func (*BSCExecutor) GetBlockHeaderAtHeight

func (e *BSCExecutor) GetBlockHeaderAtHeight(height uint64) (*types.Header, error)

func (*BSCExecutor) GetEthClient

func (e *BSCExecutor) GetEthClient() *ethclient.Client

func (*BSCExecutor) GetGreenfieldLightClient

func (e *BSCExecutor) GetGreenfieldLightClient() *greenfieldlightclient.Greenfieldlightclient

func (*BSCExecutor) GetInturnRelayer

func (e *BSCExecutor) GetInturnRelayer() (*rtypes.InturnRelayer, error)

func (*BSCExecutor) GetLatestBlockHeightWithRetry

func (e *BSCExecutor) GetLatestBlockHeightWithRetry() (latestHeight uint64, err error)

func (*BSCExecutor) GetLatestFinalizedBlockHeightWithRetry

func (e *BSCExecutor) GetLatestFinalizedBlockHeightWithRetry() (latestHeight uint64, err error)

func (*BSCExecutor) GetLightClientLatestHeight

func (e *BSCExecutor) GetLightClientLatestHeight() (uint64, error)

func (*BSCExecutor) GetNextDeliveryOracleSequenceWithRetry

func (e *BSCExecutor) GetNextDeliveryOracleSequenceWithRetry(chainId sdk.ChainID) (sequence uint64, err error)

GetNextDeliveryOracleSequenceWithRetry gets the next delivery Oracle sequence from Greenfield

func (*BSCExecutor) GetNextReceiveSequenceForChannelWithRetry

func (e *BSCExecutor) GetNextReceiveSequenceForChannelWithRetry(channelID rtypes.ChannelId) (sequence uint64, err error)

GetNextReceiveSequenceForChannelWithRetry gets the next receive sequence for specified channel from BSC

func (*BSCExecutor) GetNextSendSequenceForChannelWithRetry

func (e *BSCExecutor) GetNextSendSequenceForChannelWithRetry() (sequence uint64, err error)

GetNextSendSequenceForChannelWithRetry gets the next send oracle sequence from BSC

func (*BSCExecutor) GetNonce

func (e *BSCExecutor) GetNonce() (uint64, error)

func (*BSCExecutor) GetRpcClient

func (e *BSCExecutor) GetRpcClient() *rpc.Client

func (*BSCExecutor) GetValidatorsBlsPublicKey

func (e *BSCExecutor) GetValidatorsBlsPublicKey() ([]string, error)

func (*BSCExecutor) QueryCachedLatestValidators

func (e *BSCExecutor) QueryCachedLatestValidators() ([]rtypes.Validator, error)

QueryCachedLatestValidators Used for gnfd -> bsc

func (*BSCExecutor) QueryLatestTendermintHeaderWithRetry

func (e *BSCExecutor) QueryLatestTendermintHeaderWithRetry() (lightBlockBts []byte, err error)

func (*BSCExecutor) QueryLatestValidators

func (e *BSCExecutor) QueryLatestValidators() ([]rtypes.Validator, error)

QueryLatestValidators used for gnfd -> bsc

func (*BSCExecutor) QueryTendermintLightBlockWithRetry

func (e *BSCExecutor) QueryTendermintLightBlockWithRetry(height int64) (lightBlock tmtypes.LightBlock, err error)

func (*BSCExecutor) SetGreenfieldExecutor

func (e *BSCExecutor) SetGreenfieldExecutor(ge *GreenfieldExecutor)

func (*BSCExecutor) SwitchClient

func (e *BSCExecutor) SwitchClient()

func (*BSCExecutor) SyncTendermintLightBlock

func (e *BSCExecutor) SyncTendermintLightBlock(height uint64) (common.Hash, error)

func (*BSCExecutor) UpdateCachedLatestValidatorsLoop

func (e *BSCExecutor) UpdateCachedLatestValidatorsLoop()

func (*BSCExecutor) UpdateClientLoop

func (e *BSCExecutor) UpdateClientLoop()

type ConsensusState

type ConsensusState struct {
	ChainID              string
	Height               uint64
	NextValidatorSetHash []byte
	ValidatorSet         *cbfttypes.ValidatorSet
}

func DecodeConsensusState

func DecodeConsensusState(input []byte) (ConsensusState, error)

func DecodeLightBlockValidationInput

func DecodeLightBlockValidationInput(input []byte) (*ConsensusState, error)

type GnfdCompositeClients

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

func NewGnfdCompositClients

func NewGnfdCompositClients(rpcAddrs []string, chainId string, account *types.Account, useWebsocket bool, srcZkmeSBTContractAddr string) GnfdCompositeClients

func (*GnfdCompositeClients) GetClient

func (gc *GnfdCompositeClients) GetClient() *GreenfieldClient

type GreenfieldClient

type GreenfieldClient struct {
	sdkclient.IClient

	Height int64
	// contains filtered or unexported fields
}

type GreenfieldExecutor

type GreenfieldExecutor struct {
	BscExecutor *BSCExecutor

	BlsPrivateKey []byte
	BlsPubKey     []byte
	// contains filtered or unexported fields
}

func NewGreenfieldExecutor

func NewGreenfieldExecutor(cfg *config.Config) *GreenfieldExecutor

func (*GreenfieldExecutor) BroadcastVote

func (e *GreenfieldExecutor) BroadcastVote(v *votepool.Vote) error

func (*GreenfieldExecutor) CallZkmeSBTAckMintedContract

func (e *GreenfieldExecutor) CallZkmeSBTAckMintedContract(chainId uint32, user ethcommon.Address, status uint8, nonce uint64) (ethcommon.Hash, error)

func (*GreenfieldExecutor) ClaimPackages

func (e *GreenfieldExecutor) ClaimPackages(client *GreenfieldClient, payloadBts []byte, aggregatedSig []byte, voteAddressSet []uint64, claimTs int64, oracleSeq uint64, nonce uint64) (string, error)

func (*GreenfieldExecutor) GetBlockAndBlockResultAtHeight

func (e *GreenfieldExecutor) GetBlockAndBlockResultAtHeight(height int64) (*tmtypes.Block, *ctypes.ResultBlockResults, error)

func (*GreenfieldExecutor) GetEthClient

func (e *GreenfieldExecutor) GetEthClient() *ethclient.Client

func (*GreenfieldExecutor) GetGnfdClient

func (e *GreenfieldExecutor) GetGnfdClient() *GreenfieldClient

func (*GreenfieldExecutor) GetInturnRelayer

func (*GreenfieldExecutor) GetLatestBlockHeight

func (e *GreenfieldExecutor) GetLatestBlockHeight() (latestHeight uint64, err error)

func (*GreenfieldExecutor) GetNextDeliverySequenceForChannelWithRetry

func (e *GreenfieldExecutor) GetNextDeliverySequenceForChannelWithRetry(channelID types.ChannelId) (sequence uint64, err error)

GetNextDeliverySequenceForChannelWithRetry calls dest chain(BSC) to return a sequence # which should be used.

func (*GreenfieldExecutor) GetNextReceiveOracleSequence

func (e *GreenfieldExecutor) GetNextReceiveOracleSequence(destChainId sdk.ChainID) (uint64, error)

GetNextReceiveOracleSequence gets the next receive Oracle sequence from Greenfield

func (*GreenfieldExecutor) GetNextReceiveSequenceForChannel

func (e *GreenfieldExecutor) GetNextReceiveSequenceForChannel(destChainId sdk.ChainID, channelId types.ChannelId) (uint64, error)

GetNextReceiveSequenceForChannel gets the sequence specifically for bsc -> gnfd package's channel from Greenfield

func (*GreenfieldExecutor) GetNextSendSequenceForChannelWithRetry

func (e *GreenfieldExecutor) GetNextSendSequenceForChannelWithRetry(destChainID sdk.ChainID, channelID types.ChannelId) (sequence uint64, err error)

GetNextSendSequenceForChannelWithRetry gets the next send sequence of a specified channel from Greenfield

func (*GreenfieldExecutor) GetNonce

func (e *GreenfieldExecutor) GetNonce() (uint64, error)

func (*GreenfieldExecutor) GetNonceOnNextBlock

func (e *GreenfieldExecutor) GetNonceOnNextBlock() (uint64, error)

func (*GreenfieldExecutor) GetValidatorsBlsPublicKey

func (e *GreenfieldExecutor) GetValidatorsBlsPublicKey() ([]string, error)

func (*GreenfieldExecutor) QueryCachedLatestValidators

func (e *GreenfieldExecutor) QueryCachedLatestValidators() ([]*tmtypes.Validator, error)

func (*GreenfieldExecutor) QueryTendermintLightBlock

func (e *GreenfieldExecutor) QueryTendermintLightBlock(height int64) (tmtypes.LightBlock, error)

func (*GreenfieldExecutor) QueryValidatorsAtHeight

func (e *GreenfieldExecutor) QueryValidatorsAtHeight(height uint64) ([]*tmtypes.Validator, error)

func (*GreenfieldExecutor) QueryVotesByEventHashAndType

func (e *GreenfieldExecutor) QueryVotesByEventHashAndType(eventHash []byte, eventType votepool.EventType) ([]*votepool.Vote, error)

func (*GreenfieldExecutor) SetBSCExecutor

func (e *GreenfieldExecutor) SetBSCExecutor(be *BSCExecutor)

func (*GreenfieldExecutor) UpdateCachedLatestValidatorsLoop

func (e *GreenfieldExecutor) UpdateCachedLatestValidatorsLoop()

Jump to

Keyboard shortcuts

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