Documentation ¶
Index ¶
- Constants
- Variables
- func AppendBytes(data ...[]byte) []byte
- func BroadcastMsgs(cliCtx context.CLIContext, msgs []sdk.Msg) (sdk.TxResponse, error)
- func BroadcastMsgsWithCLI(cliCtx context.CLIContext, msgs []sdk.Msg) error
- func BroadcastTx(cliCtx context.CLIContext, tx authTypes.StdTx, mode string) (res sdk.TxResponse, err error)
- func BroadcastTxBytes(cliCtx context.CLIContext, txBytes []byte, mode string) (sdk.TxResponse, error)
- func BuildAndBroadcastMsgs(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) (sdk.TxResponse, error)
- func BuildAndBroadcastMsgsWithCLI(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) error
- func BytesToPubkey(pubKey []byte) secp256k1.PubKeySecp256k1
- func EventByID(abiObject *abi.ABI, sigdata []byte) *abi.Event
- func FetchFromAPI(cliCtx cliContext.CLIContext, URL string) (result rest.ResponseWithHeight, err error)
- func FetchSideTxSigs(client *httpClient.HTTP, height int64, txHash []byte, sideTxData []byte) ([][3]*big.Int, error)
- func FetchVotes(client *httpClient.HTTP, height int64) (votes []*tmTypes.CommitSig, sigs []byte, chainID string, err error)
- func FilterAttributes(attributes []sdk.Attribute, fn func(sdk.Attribute) bool) *sdk.Attribute
- func FilterEvents(events []sdk.StringEvent, fn func(sdk.StringEvent) bool) *sdk.StringEvent
- func GenerateAuthObj(client *ethclient.Client, address common.Address, data []byte) (auth *bind.TransactOpts, err error)
- func GetAddress() []byte
- func GetAmountFromPower(power int64) (*big.Int, error)
- func GetAmountFromString(amount string) (*big.Int, error)
- func GetBeginBlockEvents(client *httpClient.HTTP, height int64) ([]abci.Event, error)
- func GetBlock(cliCtx cosmosContext.CLIContext, height int64) (*ctypes.ResultBlock, error)
- func GetBlockWithClient(client *httpClient.HTTP, height int64) (*tmTypes.Block, error)
- func GetECDSAPrivKey() *ecdsa.PrivateKey
- func GetFromAddress(cliCtx context.CLIContext) types.HeimdallAddress
- func GetGenesisDoc() tmTypes.GenesisDoc
- func GetHeimdallServerEndpoint(endpoint string) string
- func GetMainChainRPCClient() *rpc.Client
- func GetMainClient() *ethclient.Client
- func GetMaticClient() *ethclient.Client
- func GetMaticEthClient() *eth.EthAPIBackend
- func GetMaticRPCClient() *rpc.Client
- func GetMerkleProofList(proof *merkle.SimpleProof) [][]byte
- func GetNodeStatus(cliCtx cosmosContext.CLIContext) (*ctypes.ResultStatus, error)
- func GetPkObjects(privKey crypto.PrivKey) (secp256k1.PrivKeySecp256k1, secp256k1.PubKeySecp256k1)
- func GetPowerFromAmount(amount *big.Int) (*big.Int, error)
- func GetPrivKey() secp256k1.PrivKeySecp256k1
- func GetPubKey() secp256k1.PubKeySecp256k1
- func GetPubObjects(pubkey crypto.PubKey) secp256k1.PubKeySecp256k1
- func GetReceiptLogData(log *ethTypes.Log) []byte
- func GetSideTxSigs(txHash []byte, sideTxData []byte, unFilteredVotes []*tmTypes.CommitSig) (sigs [][3]*big.Int, err error)
- func GetSignedTxBytes(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) ([]byte, error)
- func GetSignedTxBytesWithCLI(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) ([]byte, error)
- func GetStdTxBytes(cliCtx context.CLIContext, tx authTypes.StdTx) ([]byte, error)
- func GetTxDecoder(cdc *codec.Codec) sdk.TxDecoder
- func GetTxEncoder(cdc *codec.Codec) sdk.TxEncoder
- func GetUpdatedValidators(currentSet *hmTypes.ValidatorSet, validators []*hmTypes.Validator, ...) []*hmTypes.Validator
- func GetVoteBytes(unFilteredVotes []*tmTypes.CommitSig, chainID string) []byte
- func GetVoteSigs(unFilteredVotes []*tmTypes.CommitSig) (sigs []byte)
- func InitHeimdallConfig(homeDir string)
- func InitHeimdallConfigWith(homeDir string, heimdallConfigFilePath string)
- func NewLru(size int) (*lru.Cache, error)
- func Paginate(numObjs, page, limit, defLimit int) (start, end int)
- func PrepareTxBuilder(cliCtx context.CLIContext, txBldr authTypes.TxBuilder) (authTypes.TxBuilder, error)
- func PrintUnsignedStdTx(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) error
- func QueryTx(cliCtx cosmosContext.CLIContext, hashHexStr string) (sdk.TxResponse, error)
- func QueryTxWithProof(cliCtx cosmosContext.CLIContext, hash []byte) (*ctypes.ResultTx, error)
- func QueryTxsByEvents(cliCtx cosmosContext.CLIContext, tags []string, page, limit int) (*sdk.SearchTxsResult, error)
- func ReadStdTxFromFile(cdc *amino.Codec, filename string) (stdTx authTypes.StdTx, err error)
- func SetTestConfig(_conf Configuration)
- func SignStdTx(cliCtx context.CLIContext, stdTx authTypes.StdTx, appendSig bool, offline bool) (authTypes.StdTx, error)
- func StringToPubkey(pubkeyStr string) (secp256k1.PubKeySecp256k1, error)
- func TendermintTxDecode(txString string) ([]byte, error)
- func ToBytes32(x []byte) [32]byte
- func UnpackLog(abiObject *abi.ABI, out interface{}, event string, log *types.Log) error
- func UnpackSigAndVotes(payload []byte, abi abi.ABI) (votes []byte, sigs []byte, checkpointData []byte, err error)
- func ValidateTxResult(cliCtx cosmosContext.CLIContext, resTx *ctypes.ResultTx) error
- func WriteConfigFile(configFilePath string, config *Configuration)
- type Configuration
- type ContractCaller
- func (c *ContractCaller) ApproveTokens(amount *big.Int, stakeManager common.Address, tokenAddress common.Address, ...) error
- func (c *ContractCaller) CheckIfBlocksExist(end uint64) bool
- func (c *ContractCaller) CurrentAccountStateRoot(stakingInfoInstance *stakinginfo.Stakinginfo) ([32]byte, error)
- func (c *ContractCaller) CurrentHeaderBlock(rootChainInstance *rootchain.Rootchain, childBlockInterval uint64) (uint64, error)
- func (c *ContractCaller) CurrentSpanNumber(validatorSetInstance *validatorset.Validatorset) (Number *big.Int)
- func (c *ContractCaller) CurrentStateCounter(stateSenderInstance *statesender.Statesender) (Number *big.Int)
- func (c *ContractCaller) DecodeNewHeaderBlockEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*rootchain.RootchainNewHeaderBlock, error)
- func (c *ContractCaller) DecodeSignerUpdateEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoSignerChange, error)
- func (c *ContractCaller) DecodeSlashedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoSlashed, error)
- func (c *ContractCaller) DecodeStateSyncedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*statesender.StatesenderStateSynced, error)
- func (c *ContractCaller) DecodeUnJailedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoUnJailed, error)
- func (c *ContractCaller) DecodeValidatorExitEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoUnstakeInit, error)
- func (c *ContractCaller) DecodeValidatorJoinEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoStaked, error)
- func (c *ContractCaller) DecodeValidatorStakeUpdateEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoStakeUpdate, error)
- func (c *ContractCaller) DecodeValidatorTopupFeesEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoTopUpFee, error)
- func (c *ContractCaller) GetBalance(address common.Address) (*big.Int, error)
- func (c *ContractCaller) GetBlockNumberFromTxHash(tx common.Hash) (*big.Int, error)
- func (c *ContractCaller) GetCheckpointSign(txHash common.Hash) ([]byte, []byte, []byte, error)
- func (c *ContractCaller) GetConfirmedTxReceipt(tx common.Hash, requiredConfirmations uint64) (*ethTypes.Receipt, error)
- func (c *ContractCaller) GetHeaderInfo(number uint64, rootChainInstance *rootchain.Rootchain, ...) (root common.Hash, start uint64, end uint64, createdAt uint64, ...)
- func (c *ContractCaller) GetLastChildBlock(rootChainInstance *rootchain.Rootchain) (uint64, error)
- func (c *ContractCaller) GetMainChainBlock(blockNum *big.Int) (header *ethTypes.Header, err error)
- func (c *ContractCaller) GetMainTxReceipt(txHash common.Hash) (*ethTypes.Receipt, error)
- func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes.Header, err error)
- func (c *ContractCaller) GetMaticTokenInstance(maticTokenAddress common.Address) (*erc20.Erc20, error)
- func (c *ContractCaller) GetMaticTxReceipt(txHash common.Hash) (*ethTypes.Receipt, error)
- func (c *ContractCaller) GetRootChainInstance(rootchainAddress common.Address) (*rootchain.Rootchain, error)
- func (c *ContractCaller) GetRootHash(start uint64, end uint64, checkpointLength uint64) ([]byte, error)
- func (c *ContractCaller) GetSlashManagerInstance(slashManagerAddress common.Address) (*slashmanager.Slashmanager, error)
- func (c *ContractCaller) GetSpanDetails(id *big.Int, validatorSetInstance *validatorset.Validatorset) (*big.Int, *big.Int, *big.Int, error)
- func (c *ContractCaller) GetStakeManagerInstance(stakingManagerAddress common.Address) (*stakemanager.Stakemanager, error)
- func (c *ContractCaller) GetStakingInfoInstance(stakingInfoAddress common.Address) (*stakinginfo.Stakinginfo, error)
- func (c *ContractCaller) GetStateReceiverInstance(stateReceiverAddress common.Address) (*statereceiver.Statereceiver, error)
- func (c *ContractCaller) GetStateSenderInstance(stateSenderAddress common.Address) (*statesender.Statesender, error)
- func (c *ContractCaller) GetValidatorInfo(valID types.ValidatorID, stakingInfoInstance *stakinginfo.Stakinginfo) (validator types.Validator, err error)
- func (c *ContractCaller) GetValidatorSetInstance(validatorSetAddress common.Address) (*validatorset.Validatorset, error)
- func (c *ContractCaller) IsTxConfirmed(tx common.Hash, requiredConfirmations uint64) bool
- func (c *ContractCaller) SendCheckpoint(signedData []byte, sigs [][3]*big.Int, rootChainAddress common.Address, ...) (er error)
- func (c *ContractCaller) SendTick(signedData []byte, sigs []byte, slashManagerAddress common.Address, ...) (er error)
- func (c *ContractCaller) StakeFor(val common.Address, stakeAmount *big.Int, feeAmount *big.Int, ...) error
- type IContractCaller
Constants ¶
const ( NodeFlag = "node" WithHeimdallConfigFlag = "with-heimdall-config" HomeFlag = "home" FlagClientHome = "home-client" // --- // TODO Move these to common client flags // BroadcastBlock defines a tx broadcasting mode where the client waits for // the tx to be committed in a block. BroadcastBlock = "block" // BroadcastSync defines a tx broadcasting mode where the client waits for // a CheckTx execution response only. BroadcastSync = "sync" // BroadcastAsync defines a tx broadcasting mode where the client returns // immediately. BroadcastAsync = "async" DefaultMainRPCUrl = "http://localhost:9545" DefaultBorRPCUrl = "http://localhost:8545" // DefaultAmqpURL represents default AMQP url DefaultAmqpURL = "amqp://guest:guest@localhost:5672/" DefaultHeimdallServerURL = "http://0.0.0.0:1317" DefaultTendermintNodeURL = "http://0.0.0.0:26657" NoACKWaitTime = 1800 * time.Second // Time ack service waits to clear buffer and elect new proposer (1800 seconds ~ 30 mins) DefaultCheckpointerPollInterval = 5 * time.Minute DefaultSyncerPollInterval = 1 * time.Minute DefaultNoACKPollInterval = 1010 * time.Second DefaultClerkPollInterval = 10 * time.Second DefaultSpanPollInterval = 1 * time.Minute DefaultMainchainGasLimit = uint64(5000000) DefaultMainchainMaxGasPrice = 400000000000 // 400 Gwei DefaultBorChainID string = "15001" // Legacy value - DO NOT CHANGE // Maximum allowed event record data size LegacyMaxStateSyncSize = 100000 // New max state sync size after hardfork MaxStateSyncSize = 30000 )
const ( // CommitTimeout commit timeout CommitTimeout = 2 * time.Minute )
Variables ¶
var ( DefaultCLIHome = os.ExpandEnv("$HOME/.heimdallcli") DefaultNodeHome = os.ExpandEnv("$HOME/.heimdalld") MinBalance = big.NewInt(100000000000000000) // aka 0.1 Ether )
var GenesisDoc tmTypes.GenesisDoc
GenesisDoc contains the genesis file
var Logger logger.Logger
Logger stores global logger object
var ZeroAddress = common.Address{}
ZeroAddress represents empty address
var ZeroHash = common.Hash{}
ZeroHash represents empty hash
var ZeroPubKey = hmTypes.PubKey{}
ZeroPubKey represents empty pub key
Functions ¶
func BroadcastMsgs ¶
func BroadcastMsgs(cliCtx context.CLIContext, msgs []sdk.Msg) (sdk.TxResponse, error)
BroadcastMsgs creates transaction and broadcasts it
func BroadcastMsgsWithCLI ¶
func BroadcastMsgsWithCLI(cliCtx context.CLIContext, msgs []sdk.Msg) error
BroadcastMsgsWithCLI creates message and sends tx Used from cli- waits till transaction is included in block
func BroadcastTx ¶
func BroadcastTx(cliCtx context.CLIContext, tx authTypes.StdTx, mode string) (res sdk.TxResponse, err error)
BroadcastTx broadcasts transaction
func BroadcastTxBytes ¶
func BroadcastTxBytes(cliCtx context.CLIContext, txBytes []byte, mode string) (sdk.TxResponse, error)
BroadcastTxBytes sends request to tendermint using CLI
func BuildAndBroadcastMsgs ¶
func BuildAndBroadcastMsgs(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) (sdk.TxResponse, error)
BuildAndBroadcastMsgs creates transaction and broadcasts it
func BuildAndBroadcastMsgsWithCLI ¶
func BuildAndBroadcastMsgsWithCLI(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) error
BuildAndBroadcastMsgsWithCLI implements a utility function that facilitates sending a series of messages in a signed transaction given a TxBuilder and a QueryContext. It ensures that the account exists, has a proper number and sequence set. In addition, it builds and signs a transaction with the supplied messages. Finally, it broadcasts the signed transaction to a node.
func BytesToPubkey ¶
func BytesToPubkey(pubKey []byte) secp256k1.PubKeySecp256k1
BytesToPubkey converts bytes to Pubkey
func FetchFromAPI ¶ added in v0.1.5
func FetchFromAPI(cliCtx cliContext.CLIContext, URL string) (result rest.ResponseWithHeight, err error)
FetchFromAPI fetches data from any URL
func FetchSideTxSigs ¶ added in v0.1.7
func FetchSideTxSigs( client *httpClient.HTTP, height int64, txHash []byte, sideTxData []byte, ) ([][3]*big.Int, error)
FetchSideTxSigs fetches side tx sigs from it
func FetchVotes ¶ added in v0.1.5
func FetchVotes( client *httpClient.HTTP, height int64, ) (votes []*tmTypes.CommitSig, sigs []byte, chainID string, err error)
FetchVotes fetches votes and extracts sigs from it
func FilterAttributes ¶
FilterAttributes filter attributes by fn
func FilterEvents ¶
func FilterEvents(events []sdk.StringEvent, fn func(sdk.StringEvent) bool) *sdk.StringEvent
FilterEvents filter events by fn
func GenerateAuthObj ¶
func GetAmountFromPower ¶ added in v0.1.7
GetAmountFromPower returns amount from power
func GetAmountFromString ¶
GetAmountFromString converts string to its big Int
func GetBeginBlockEvents ¶ added in v0.1.7
GetBeginBlockEvents get block through per height
func GetBlock ¶
func GetBlock(cliCtx cosmosContext.CLIContext, height int64) (*ctypes.ResultBlock, error)
GetBlock returns a block
func GetBlockWithClient ¶
GetBlockWithClient get block through per height
func GetECDSAPrivKey ¶
func GetECDSAPrivKey() *ecdsa.PrivateKey
GetECDSAPrivKey return ecdsa private key
func GetFromAddress ¶
func GetFromAddress(cliCtx context.CLIContext) types.HeimdallAddress
GetFromAddress get from address
func GetGenesisDoc ¶
func GetGenesisDoc() tmTypes.GenesisDoc
func GetHeimdallServerEndpoint ¶ added in v0.1.5
GetHeimdallServerEndpoint returns heimdall server endpoint
func GetMainChainRPCClient ¶
GetMainChainRPCClient returns main chain RPC client
func GetMainClient ¶
GetMainClient returns main chain's eth client
func GetMaticClient ¶
GetMaticClient returns matic's eth client
func GetMaticEthClient ¶ added in v0.1.7
func GetMaticEthClient() *eth.EthAPIBackend
GetMaticEthClient returns matic's Eth client
func GetMaticRPCClient ¶
GetMaticRPCClient returns matic's RPC client
func GetMerkleProofList ¶
func GetMerkleProofList(proof *merkle.SimpleProof) [][]byte
GetMerkleProofList return proof array each proof has one byte for direction: 0x0 for left and 0x1 for right
func GetNodeStatus ¶
func GetNodeStatus(cliCtx cosmosContext.CLIContext) (*ctypes.ResultStatus, error)
GetNodeStatus returns node status
func GetPkObjects ¶
func GetPkObjects(privKey crypto.PrivKey) (secp256k1.PrivKeySecp256k1, secp256k1.PubKeySecp256k1)
GetPkObjects from crypto priv key
func GetPowerFromAmount ¶
GetPowerFromAmount returns power from amount -- note that this will polute amount object
func GetPubObjects ¶
func GetPubObjects(pubkey crypto.PubKey) secp256k1.PubKeySecp256k1
GetPubObjects returns PubKeySecp256k1 public key
func GetReceiptLogData ¶
GetReceiptLogData get receipt log data
func GetSideTxSigs ¶ added in v0.1.7
func GetSideTxSigs(txHash []byte, sideTxData []byte, unFilteredVotes []*tmTypes.CommitSig) (sigs [][3]*big.Int, err error)
GetSideTxSigs returns sigs bytes from vote by tx hash
func GetSignedTxBytes ¶
func GetSignedTxBytes(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) ([]byte, error)
GetSignedTxBytes returns signed tx bytes
func GetSignedTxBytesWithCLI ¶
func GetSignedTxBytesWithCLI(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) ([]byte, error)
GetSignedTxBytesWithCLI returns signed tx bytes
func GetStdTxBytes ¶
GetStdTxBytes get tx bytes
func GetTxDecoder ¶
GetTxDecoder returns tx decoder
func GetTxEncoder ¶
GetTxEncoder returns tx encoder
func GetUpdatedValidators ¶
func GetUpdatedValidators( currentSet *hmTypes.ValidatorSet, validators []*hmTypes.Validator, ackCount uint64, ) []*hmTypes.Validator
GetUpdatedValidators updates validators in validator set
func GetVoteBytes ¶
GetVoteBytes returns vote bytes
func GetVoteSigs ¶ added in v0.1.7
GetVoteSigs returns sigs bytes from vote
func InitHeimdallConfig ¶
func InitHeimdallConfig(homeDir string)
InitHeimdallConfig initializes with viper config (from heimdall configuration)
func InitHeimdallConfigWith ¶
InitHeimdallConfigWith initializes passed heimdall/tendermint config files
func Paginate ¶
Paginate returns the correct starting and ending index for a paginated query, given that client provides a desired page and limit of objects and the handler provides the total number of objects. If the start page is invalid, non-positive values are returned signaling the request is invalid.
NOTE: The start page is assumed to be 1-indexed.
func PrepareTxBuilder ¶
func PrepareTxBuilder(cliCtx context.CLIContext, txBldr authTypes.TxBuilder) (authTypes.TxBuilder, error)
PrepareTxBuilder populates a TxBuilder in preparation for the build of a Tx.
func PrintUnsignedStdTx ¶
func PrintUnsignedStdTx(cliCtx context.CLIContext, txBldr authTypes.TxBuilder, msgs []sdk.Msg) error
PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
func QueryTx ¶
func QueryTx(cliCtx cosmosContext.CLIContext, hashHexStr string) (sdk.TxResponse, error)
QueryTx query tx from node
func QueryTxWithProof ¶
func QueryTxWithProof(cliCtx cosmosContext.CLIContext, hash []byte) (*ctypes.ResultTx, error)
QueryTxWithProof query tx with proof from node
func QueryTxsByEvents ¶
func QueryTxsByEvents(cliCtx cosmosContext.CLIContext, tags []string, page, limit int) (*sdk.SearchTxsResult, error)
QueryTxsByEvents performs a search for transactions for a given set of tags via Tendermint RPC. It returns a slice of Info object containing txs and metadata. An error is returned if the query fails.
func ReadStdTxFromFile ¶
ReadStdTxFromFile and decode a StdTx from the given filename. Can pass "-" to read from stdin.
func SetTestConfig ¶ added in v0.1.8
func SetTestConfig(_conf Configuration)
TEST PURPOSE ONLY SetTestConfig sets test configuration
func SignStdTx ¶
func SignStdTx( cliCtx context.CLIContext, stdTx authTypes.StdTx, appendSig bool, offline bool, ) (authTypes.StdTx, error)
SignStdTx appends a signature to a StdTx and returns a copy of it. If appendSig is false, it replaces the signatures already attached with the new signature. Don't perform online validation or lookups if offline is true.
func StringToPubkey ¶
func StringToPubkey(pubkeyStr string) (secp256k1.PubKeySecp256k1, error)
StringToPubkey converts string to Pubkey
func TendermintTxDecode ¶
TendermintTxDecode decodes transaction string and return base tx object
func ToBytes32 ¶
ToBytes32 is a convenience method for converting a byte slice to a fix sized 32 byte array. This method will truncate the input if it is larger than 32 bytes.
func UnpackSigAndVotes ¶
func UnpackSigAndVotes(payload []byte, abi abi.ABI) (votes []byte, sigs []byte, checkpointData []byte, err error)
UnpackSigAndVotes Unpacks Sig and Votes from Tx Payload
func ValidateTxResult ¶
func ValidateTxResult(cliCtx cosmosContext.CLIContext, resTx *ctypes.ResultTx) error
ValidateTxResult performs transaction verification.
func WriteConfigFile ¶
func WriteConfigFile(configFilePath string, config *Configuration)
WriteConfigFile renders config using the template and writes it to configFilePath.
Types ¶
type Configuration ¶
type Configuration struct { EthRPCUrl string `mapstructure:"eth_rpc_url"` // RPC endpoint for main chain BorRPCUrl string `mapstructure:"bor_rpc_url"` // RPC endpoint for bor chain TendermintRPCUrl string `mapstructure:"tendermint_rpc_url"` // tendemint node url AmqpURL string `mapstructure:"amqp_url"` // amqp url HeimdallServerURL string `mapstructure:"heimdall_rest_server"` // heimdall server url MainchainGasLimit uint64 `mapstructure:"main_chain_gas_limit"` // gas limit to mainchain transaction. eg....submit checkpoint. MainchainMaxGasPrice int64 `mapstructure:"main_chain_max_gas_price"` // max gas price to mainchain transaction. eg....submit checkpoint. // config related to bridge CheckpointerPollInterval time.Duration `mapstructure:"checkpoint_poll_interval"` // Poll interval for checkpointer service to send new checkpoints or missing ACK SyncerPollInterval time.Duration `mapstructure:"syncer_poll_interval"` // Poll interval for syncher service to sync for changes on main chain NoACKPollInterval time.Duration `mapstructure:"noack_poll_interval"` // Poll interval for ack service to send no-ack in case of no checkpoints ClerkPollInterval time.Duration `mapstructure:"clerk_poll_interval"` SpanPollInterval time.Duration `mapstructure:"span_poll_interval"` // wait time related options NoACKWaitTime time.Duration `mapstructure:"no_ack_wait_time"` // Time ack service waits to clear buffer and elect new proposer }
Configuration represents heimdall config
func GetDefaultHeimdallConfig ¶
func GetDefaultHeimdallConfig() Configuration
GetDefaultHeimdallConfig returns configration with default params
func ParseConfig ¶
func ParseConfig() (*Configuration, error)
ParseConfig retrieves the default environment configuration for the application.
type ContractCaller ¶
type ContractCaller struct { MainChainClient *ethclient.Client MainChainRPC *rpc.Client MaticChainClient *ethclient.Client MaticChainRPC *rpc.Client RootChainABI abi.ABI StakingInfoABI abi.ABI ValidatorSetABI abi.ABI StateReceiverABI abi.ABI StateSenderABI abi.ABI StakeManagerABI abi.ABI SlashManagerABI abi.ABI MaticTokenABI abi.ABI ReceiptCache *lru.Cache ContractInstanceCache map[common.Address]interface{} }
ContractCaller contract caller
func NewContractCaller ¶
func NewContractCaller() (contractCallerObj ContractCaller, err error)
NewContractCaller contract caller
func (*ContractCaller) ApproveTokens ¶
func (c *ContractCaller) ApproveTokens(amount *big.Int, stakeManager common.Address, tokenAddress common.Address, maticTokenInstance *erc20.Erc20) error
ApproveTokens approves matic token for stake
func (*ContractCaller) CheckIfBlocksExist ¶ added in v0.1.8
func (c *ContractCaller) CheckIfBlocksExist(end uint64) bool
CheckIfBlocksExist - check if the given block exists on local chain
func (*ContractCaller) CurrentAccountStateRoot ¶
func (c *ContractCaller) CurrentAccountStateRoot(stakingInfoInstance *stakinginfo.Stakinginfo) ([32]byte, error)
CurrentAccountStateRoot get current account root from on chain
func (*ContractCaller) CurrentHeaderBlock ¶
func (c *ContractCaller) CurrentHeaderBlock(rootChainInstance *rootchain.Rootchain, childBlockInterval uint64) (uint64, error)
CurrentHeaderBlock fetches current header block
func (*ContractCaller) CurrentSpanNumber ¶
func (c *ContractCaller) CurrentSpanNumber(validatorSetInstance *validatorset.Validatorset) (Number *big.Int)
CurrentSpanNumber get current span
func (*ContractCaller) CurrentStateCounter ¶
func (c *ContractCaller) CurrentStateCounter(stateSenderInstance *statesender.Statesender) (Number *big.Int)
CurrentStateCounter get state counter
func (*ContractCaller) DecodeNewHeaderBlockEvent ¶
func (c *ContractCaller) DecodeNewHeaderBlockEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*rootchain.RootchainNewHeaderBlock, error)
DecodeNewHeaderBlockEvent represents new header block event
func (*ContractCaller) DecodeSignerUpdateEvent ¶
func (c *ContractCaller) DecodeSignerUpdateEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoSignerChange, error)
DecodeSignerUpdateEvent represents sig update event
func (*ContractCaller) DecodeSlashedEvent ¶ added in v0.1.7
func (c *ContractCaller) DecodeSlashedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoSlashed, error)
DecodeSlashedEvent represents tick ack on contract
func (*ContractCaller) DecodeStateSyncedEvent ¶
func (c *ContractCaller) DecodeStateSyncedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*statesender.StatesenderStateSynced, error)
DecodeStateSyncedEvent decode state sync data
func (*ContractCaller) DecodeUnJailedEvent ¶ added in v0.1.7
func (c *ContractCaller) DecodeUnJailedEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoUnJailed, error)
DecodeUnJailedEvent represents unjail on contract
func (*ContractCaller) DecodeValidatorExitEvent ¶
func (c *ContractCaller) DecodeValidatorExitEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoUnstakeInit, error)
DecodeValidatorExitEvent represents validator stake unstake event
func (*ContractCaller) DecodeValidatorJoinEvent ¶
func (c *ContractCaller) DecodeValidatorJoinEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoStaked, error)
DecodeValidatorJoinEvent represents validator staked event
func (*ContractCaller) DecodeValidatorStakeUpdateEvent ¶
func (c *ContractCaller) DecodeValidatorStakeUpdateEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoStakeUpdate, error)
DecodeValidatorStakeUpdateEvent represents validator stake update event
func (*ContractCaller) DecodeValidatorTopupFeesEvent ¶
func (c *ContractCaller) DecodeValidatorTopupFeesEvent(contractAddress common.Address, receipt *ethTypes.Receipt, logIndex uint64) (*stakinginfo.StakinginfoTopUpFee, error)
DecodeValidatorTopupFeesEvent represents topup for fees tokens
func (*ContractCaller) GetBalance ¶
GetBalance get balance of account (returns big.Int balance wont fit in uint64)
func (*ContractCaller) GetBlockNumberFromTxHash ¶
GetBlockNumberFromTxHash gets block number of transaction
func (*ContractCaller) GetCheckpointSign ¶
GetCheckpointSign returns sigs input of committed checkpoint tranasction
func (*ContractCaller) GetConfirmedTxReceipt ¶
func (c *ContractCaller) GetConfirmedTxReceipt(tx common.Hash, requiredConfirmations uint64) (*ethTypes.Receipt, error)
GetConfirmedTxReceipt returns confirmed tx receipt
func (*ContractCaller) GetHeaderInfo ¶
func (c *ContractCaller) GetHeaderInfo(number uint64, rootChainInstance *rootchain.Rootchain, childBlockInterval uint64) ( root common.Hash, start uint64, end uint64, createdAt uint64, proposer types.HeimdallAddress, err error, )
GetHeaderInfo get header info from checkpoint number
func (*ContractCaller) GetLastChildBlock ¶
func (c *ContractCaller) GetLastChildBlock(rootChainInstance *rootchain.Rootchain) (uint64, error)
GetLastChildBlock fetch current child block
func (*ContractCaller) GetMainChainBlock ¶
GetMainChainBlock returns main chain block header
func (*ContractCaller) GetMainTxReceipt ¶
GetMainTxReceipt returns main tx receipt
func (*ContractCaller) GetMaticChainBlock ¶
GetMaticChainBlock returns child chain block header
func (*ContractCaller) GetMaticTokenInstance ¶ added in v0.1.5
func (c *ContractCaller) GetMaticTokenInstance(maticTokenAddress common.Address) (*erc20.Erc20, error)
GetMaticTokenInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) GetMaticTxReceipt ¶
GetMaticTxReceipt returns matic tx receipt
func (*ContractCaller) GetRootChainInstance ¶ added in v0.1.5
func (c *ContractCaller) GetRootChainInstance(rootchainAddress common.Address) (*rootchain.Rootchain, error)
GetRootChainInstance returns RootChain contract instance for selected base chain
func (*ContractCaller) GetRootHash ¶ added in v0.1.7
func (c *ContractCaller) GetRootHash(start uint64, end uint64, checkpointLength uint64) ([]byte, error)
GetRootHash get root hash from bor chain
func (*ContractCaller) GetSlashManagerInstance ¶ added in v0.1.7
func (c *ContractCaller) GetSlashManagerInstance(slashManagerAddress common.Address) (*slashmanager.Slashmanager, error)
GetSlashManagerInstance returns slashManager contract instance for selected base chain
func (*ContractCaller) GetSpanDetails ¶
func (c *ContractCaller) GetSpanDetails(id *big.Int, validatorSetInstance *validatorset.Validatorset) ( *big.Int, *big.Int, *big.Int, error, )
GetSpanDetails get span details
func (*ContractCaller) GetStakeManagerInstance ¶ added in v0.1.5
func (c *ContractCaller) GetStakeManagerInstance(stakingManagerAddress common.Address) (*stakemanager.Stakemanager, error)
GetStakeManagerInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) GetStakingInfoInstance ¶ added in v0.1.5
func (c *ContractCaller) GetStakingInfoInstance(stakingInfoAddress common.Address) (*stakinginfo.Stakinginfo, error)
GetStakingInfoInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) GetStateReceiverInstance ¶ added in v0.1.5
func (c *ContractCaller) GetStateReceiverInstance(stateReceiverAddress common.Address) (*statereceiver.Statereceiver, error)
GetStateReceiverInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) GetStateSenderInstance ¶ added in v0.1.5
func (c *ContractCaller) GetStateSenderInstance(stateSenderAddress common.Address) (*statesender.Statesender, error)
GetStateSenderInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) GetValidatorInfo ¶
func (c *ContractCaller) GetValidatorInfo(valID types.ValidatorID, stakingInfoInstance *stakinginfo.Stakinginfo) (validator types.Validator, err error)
GetValidatorInfo get validator info
func (*ContractCaller) GetValidatorSetInstance ¶ added in v0.1.5
func (c *ContractCaller) GetValidatorSetInstance(validatorSetAddress common.Address) (*validatorset.Validatorset, error)
GetValidatorSetInstance returns stakinginfo contract instance for selected base chain
func (*ContractCaller) IsTxConfirmed ¶
func (c *ContractCaller) IsTxConfirmed(tx common.Hash, requiredConfirmations uint64) bool
IsTxConfirmed is tx confirmed
func (*ContractCaller) SendCheckpoint ¶
func (c *ContractCaller) SendCheckpoint(signedData []byte, sigs [][3]*big.Int, rootChainAddress common.Address, rootChainInstance *rootchain.Rootchain) (er error)
SendCheckpoint sends checkpoint to rootchain contract todo return err
func (*ContractCaller) SendTick ¶ added in v0.1.7
func (c *ContractCaller) SendTick(signedData []byte, sigs []byte, slashManagerAddress common.Address, slashManagerInstance *slashmanager.Slashmanager) (er error)
SendTick sends slash tick to rootchain contract
func (*ContractCaller) StakeFor ¶
func (c *ContractCaller) StakeFor(val common.Address, stakeAmount *big.Int, feeAmount *big.Int, acceptDelegation bool, stakeManagerAddress common.Address, stakeManagerInstance *stakemanager.Stakemanager) error
StakeFor stakes for a validator
type IContractCaller ¶
type IContractCaller interface { GetHeaderInfo(headerID uint64, rootChainInstance *rootchain.Rootchain, childBlockInterval uint64) (root common.Hash, start, end, createdAt uint64, proposer types.HeimdallAddress, err error) GetRootHash(start uint64, end uint64, checkpointLength uint64) ([]byte, error) GetValidatorInfo(valID types.ValidatorID, stakingInfoInstance *stakinginfo.Stakinginfo) (validator types.Validator, err error) GetLastChildBlock(rootChainInstance *rootchain.Rootchain) (uint64, error) CurrentHeaderBlock(rootChainInstance *rootchain.Rootchain, childBlockInterval uint64) (uint64, error) GetBalance(address common.Address) (*big.Int, error) SendCheckpoint(sigedData []byte, sigs [][3]*big.Int, rootchainAddress common.Address, rootChainInstance *rootchain.Rootchain) (err error) SendTick(sigedData []byte, sigs []byte, slashManagerAddress common.Address, slashManagerInstance *slashmanager.Slashmanager) (err error) GetCheckpointSign(txHash common.Hash) ([]byte, []byte, []byte, error) GetMainChainBlock(*big.Int) (*ethTypes.Header, error) GetMaticChainBlock(*big.Int) (*ethTypes.Header, error) IsTxConfirmed(common.Hash, uint64) bool GetConfirmedTxReceipt(common.Hash, uint64) (*ethTypes.Receipt, error) GetBlockNumberFromTxHash(common.Hash) (*big.Int, error) // decode header event DecodeNewHeaderBlockEvent(common.Address, *ethTypes.Receipt, uint64) (*rootchain.RootchainNewHeaderBlock, error) // decode validator events DecodeValidatorTopupFeesEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoTopUpFee, error) DecodeValidatorJoinEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoStaked, error) DecodeValidatorStakeUpdateEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoStakeUpdate, error) DecodeValidatorExitEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoUnstakeInit, error) DecodeSignerUpdateEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoSignerChange, error) // decode state events DecodeStateSyncedEvent(common.Address, *ethTypes.Receipt, uint64) (*statesender.StatesenderStateSynced, error) // decode slashing events DecodeSlashedEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoSlashed, error) DecodeUnJailedEvent(common.Address, *ethTypes.Receipt, uint64) (*stakinginfo.StakinginfoUnJailed, error) GetMainTxReceipt(common.Hash) (*ethTypes.Receipt, error) GetMaticTxReceipt(common.Hash) (*ethTypes.Receipt, error) ApproveTokens(*big.Int, common.Address, common.Address, *erc20.Erc20) error StakeFor(common.Address, *big.Int, *big.Int, bool, common.Address, *stakemanager.Stakemanager) error CurrentAccountStateRoot(stakingInfoInstance *stakinginfo.Stakinginfo) ([32]byte, error) // bor related contracts CurrentSpanNumber(validatorset *validatorset.Validatorset) (Number *big.Int) GetSpanDetails(id *big.Int, validatorset *validatorset.Validatorset) (*big.Int, *big.Int, *big.Int, error) CurrentStateCounter(stateSenderInstance *statesender.Statesender) (Number *big.Int) CheckIfBlocksExist(end uint64) bool GetRootChainInstance(rootchainAddress common.Address) (*rootchain.Rootchain, error) GetStakingInfoInstance(stakingInfoAddress common.Address) (*stakinginfo.Stakinginfo, error) GetValidatorSetInstance(validatorSetAddress common.Address) (*validatorset.Validatorset, error) GetStakeManagerInstance(stakingManagerAddress common.Address) (*stakemanager.Stakemanager, error) GetSlashManagerInstance(slashManagerAddress common.Address) (*slashmanager.Slashmanager, error) GetStateSenderInstance(stateSenderAddress common.Address) (*statesender.Statesender, error) GetStateReceiverInstance(stateReceiverAddress common.Address) (*statereceiver.Statereceiver, error) GetMaticTokenInstance(maticTokenAddress common.Address) (*erc20.Erc20, error) }
IContractCaller represents contract caller