mapprotocol

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: LGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NearAbiJson                  = `` /* 259-byte string literal not displayed */
	McsAbi                       = `` /* 4643-byte string literal not displayed */
	LightMangerAbi               = `` /* 1776-byte string literal not displayed */
	BscAbiJson                   = `` /* 3340-byte string literal not displayed */
	KlaytnAbiJson                = `` /* 2993-byte string literal not displayed */
	HeightAbiJson                = `` /* 146-byte string literal not displayed */
	VerifiableHeaderRangeAbiJson = `` /* 218-byte string literal not displayed */
	Map2OtherAbi                 = `` /* 5188-byte string literal not displayed */
	MaticAbiJson                 = `` /* 3340-byte string literal not displayed */
	Eth2AbiJson                  = `` /* 6528-byte string literal not displayed */
	PlatonAbiJson                = `` /* 4321-byte string literal not displayed */
	ConfluxAbiJson               = `` /* 3644-byte string literal not displayed */

	OracleAbiJson = `` /* 2006-byte string literal not displayed */
)
View Source
const (
	TransferOut = "transfer out"
	DepositOut  = "deposit out"
)
View Source
const (
	MethodVerifyProofData        = "verifyProofData"
	MethodUpdateBlockHeader      = "updateBlockHeader"
	MethodVerifiableHeaderRange  = "verifiableHeaderRange"
	MethodOfHeaderHeight         = "headerHeight"
	MethodOfTransferIn           = "transferIn"
	MethodOfDepositIn            = "depositIn"
	MethodOfSwapIn               = "swapIn"
	MethodOfOrderList            = "orderList"
	MethodOfIsUsedEvent          = "is_used_event"
	MethodOfGetBytes             = "getBytes"
	MethodOfGetFinalBytes        = "getFinalBytes"
	MethodOfGetHeadersBytes      = "getHeadersBytes"
	MethodOfGetBlockHeadersBytes = "getBlockHeaderBytes"
	MethodOfGetUpdatesBytes      = "getUpdateBytes"
	MethodUpdateLightClient      = "updateLightClient"
	MethodClientState            = "clientState"
	MethodClientStateAnalysis    = "clientStateAnalysis"
	MethodOfState                = "state"
	MethodOfNearestPivot         = "nearestPivot"
	MethodOFinalizedState        = "finalizedState"
	MethodOfVerifyReceiptProof   = "verifyReceiptProof"
	MethodOfOrderStatus          = "getOrderStatus"
	MethodOfPropose              = "propose"
	MethodOfVerifyAndStore       = "swapInVerify"
	MethodOfSwapInVerified       = "swapInVerified"
	EventOfSwapInVerified        = "mapSwapInVerified"
)
View Source
const (
	NearVerifyRange  = "get_verifiable_header_range"
	NearHeaderHeight = "get_header_height"
)
View Source
const (
	EpochOfMap          = 50000
	EpochOfBsc          = 200
	HeaderCountOfBsc    = 12
	HeaderCountOfMatic  = 16
	HeaderCountOfPlaton = 430
	EpochOfKlaytn       = 3600
	HeaderOneCount      = 1
	HeaderCountOfBttc   = 64
)

Variables

View Source
var (
	MapId             string
	GlobalMapConn     *ethclient.Client
	SyncOtherMap      = make(map[msg.ChainId]*big.Int)  // map to other chain init height
	Map2OtherHeight   = make(map[msg.ChainId]GetHeight) // get map to other height function collect
	ContractMapping   = make(map[msg.ChainId]*contract.Call)
	Get2MapHeight     = func(chainId msg.ChainId) (*big.Int, error) { return nil, nil }                // get other chain to map height
	GetEth22MapNumber = func(chainId msg.ChainId) (*big.Int, *big.Int, error) { return nil, nil, nil } // can reform, return data is []byte
	GetDataByManager  = func(string, ...interface{}) ([]byte, error) { return nil, nil }
)
View Source
var (
	HashOfDepositIn = common.HexToHash("0xb7100086a8e13ebae772a0f09b07046e389a6b036406d22b86f2d2e5b860a8d9")
	HashOfSwapIn    = common.HexToHash("0xca1cf8cebf88499429cca8f87cbca15ab8dafd06702259a5344ddce89ef3f3a5")
	NearOfDepositIn = "150bd848adaf4e3e699dcac82d75f111c078ce893375373593cc1b9208998377"
	NearOfSwapIn    = "ca1cf8cebf88499429cca8f87cbca15ab8dafd06702259a5344ddce89ef3f3a5"
)
View Source
var (
	ConfirmsOfMatic             = big.NewInt(10)
	HeaderLenOfBttc       int64 = 10
	HeaderLengthOfEth2          = 20
	HeaderLengthOfConflux       = 20
)
View Source
var (
	Big0 = big.NewInt(0)
)
View Source
var (
	OnlineChaId = map[msg.ChainId]string{}
)
View Source
var (
	PUBLENGTH = 128
)

Functions

func GetCurValidators added in v1.2.0

func GetCurValidators(cli *ethclient.Client, number *big.Int) ([]byte, error)

func GetLastReceipt

func GetLastReceipt(conn *ethclient.Client, latestBlock *big.Int) (*types.Receipt, error)

func GetMapTransactionsHashByBlockNumber

func GetMapTransactionsHashByBlockNumber(conn *ethclient.Client, number *big.Int) ([]common.Hash, error)

func GetZkProof added in v1.2.0

func GetZkProof(endpoint string, cid msg.ChainId, height uint64) ([]*big.Int, error)

func HeaderHeight

func HeaderHeight(to common.Address, input []byte) (*big.Int, error)

func Init2GetEth22MapNumber

func Init2GetEth22MapNumber(lightNode common.Address)

func InitLightManager added in v1.2.0

func InitLightManager(lightNode common.Address)

func InitOtherChain2MapHeight

func InitOtherChain2MapHeight(lightManager common.Address)

func PackInput

func PackInput(commonAbi abi.ABI, abiMethod string, params ...interface{}) ([]byte, error)

func StatusEncoding

func StatusEncoding(r *ethtypes.Receipt) []byte

func UnpackHeaderHeightOutput

func UnpackHeaderHeightOutput(output []byte) (*big.Int, error)

func UnpackVerifyRangeOutput

func UnpackVerifyRangeOutput(output []byte) (*big.Int, *big.Int, error)

func VerifyRange

func VerifyRange(to common.Address, input []byte) (*big.Int, *big.Int, error)

Types

type AccessKey

type AccessKey struct {
	Nonce      *big.Int
	Permission string
}

type Action

type Action struct {
	Actions []interface{} `json:"actions"` //
	//Actions             []map[string]interface{} `json:"actions"` //
	GasPrice            string        `json:"gas_price"`
	InputDataIds        []interface{} `json:"input_data_ids"`
	OutputDataReceivers []interface{} `json:"output_data_receivers"`
	SignerID            string        `json:"signer_id"`
	SignerPublicKey     string        `json:"signer_public_key"`
}

type BlockHeader

type BlockHeader struct {
	ParentHash  []byte
	Coinbase    common.Address
	Root        []byte
	TxHash      []byte
	ReceiptHash []byte
	Bloom       []byte
	Number      *big.Int
	GasLimit    *big.Int
	GasUsed     *big.Int
	Time        *big.Int
	ExtraData   []byte
	MixDigest   []byte
	Nonce       []byte
	BaseFee     *big.Int
}

func ConvertHeader

func ConvertHeader(header *types.Header) *BlockHeader

type BlockHeaderLite

type BlockHeaderLite struct {
	InnerLite     InnerLite `json:"inner_lite"`
	InnerRestHash string    `json:"inner_rest_hash"`
	PrevBlockHash string    `json:"prev_block_hash"`
}

type BlockProof

type BlockProof struct {
	Direction string `json:"direction"`
	Hash      string `json:"hash"`
}

type ExecutionOutcomeView

type ExecutionOutcomeView struct {
	ExecutorID  types.AccountID          `json:"executor_id"`
	GasBurnt    types.Gas                `json:"gas_burnt"`
	Logs        []string                 `json:"logs"`
	Metadata    Metadata                 `json:"metadata"`
	ReceiptIDs  []hash.CryptoHash        `json:"receipt_ids"`
	Status      client.TransactionStatus `json:"status"`
	TokensBurnt string                   `json:"tokens_burnt"` // "242953087248000000000"
}

type ExecutionOutcomeWithIdView

type ExecutionOutcomeWithIdView struct {
	BlockHash hash.CryptoHash      `json:"block_hash"`
	ID        hash.CryptoHash      `json:"id"`
	Outcome   ExecutionOutcomeView `json:"outcome"`
	Proof     MerklePath           `json:"proof"`
}

type G2

type G2 struct {
	Xr *big.Int
	Xi *big.Int
	Yr *big.Int
	Yi *big.Int
}

func GetAggPK

func GetAggPK(cli *ethclient.Client, number *big.Int, extra []byte) (*G2, *types.IstanbulExtra, []byte, error)

type GasProfile

type GasProfile struct {
	Cost         string `json:"cost"`
	CostCategory string `json:"cost_category"`
	GasUsed      string `json:"gas_used"`
}

type GetHeight

type GetHeight func() (*big.Int, error)

func Map2EthHeight

func Map2EthHeight(fromUser string, lightNode common.Address, client *ethclient.Client) GetHeight

func Map2NearHeight

func Map2NearHeight(lightNode string, client *nearclient.Client) GetHeight

type GetVerifyRange

type GetVerifyRange func() (*big.Int, *big.Int, error)

func Map2EthVerifyRange

func Map2EthVerifyRange(fromUser string, lightNode common.Address, client *ethclient.Client) GetVerifyRange

func Map2NearVerifyRange

func Map2NearVerifyRange(lightNode string, client *nearclient.Client) GetVerifyRange

type IndexerChunkView

type IndexerChunkView struct {
	Author   types.AccountID        `json:"author"`
	Header   client.ChunkHeaderView `json:"header"`
	Receipts []ReceiptView          `json:"receipts"`
}

type IndexerExecutionOutcomeWithOptionalReceipt

type IndexerExecutionOutcomeWithOptionalReceipt struct {
	ExecutionOutcome ExecutionOutcomeWithIdView `json:"execution_outcome"`
	Receipt          *client.ReceiptView        `json:"receipt"`
}

type IndexerExecutionOutcomeWithReceipt

type IndexerExecutionOutcomeWithReceipt struct {
	ExecutionOutcome ExecutionOutcomeWithIdView `json:"execution_outcome"`
	Receipt          ReceiptView                `json:"receipt"`
}

type IndexerShard

type IndexerShard struct {
	Chunk                    *IndexerChunkView                    `json:"chunk"`
	ReceiptExecutionOutcomes []IndexerExecutionOutcomeWithReceipt `json:"receipt_execution_outcomes"`
	ShardID                  types.ShardID                        `json:"shard_id"`
	StateChanges             StateChangesView                     `json:"state_changes"`
}

type IndexerTransactionWithOutcome

type IndexerTransactionWithOutcome struct {
	Outcome     IndexerExecutionOutcomeWithOptionalReceipt `json:"outcome"`
	Transaction SignedTransactionView                      `json:"transaction"`
}

type InnerLite

type InnerLite struct {
	BlockMerkleRoot  string `json:"block_merkle_root"`
	EpochID          string `json:"epoch_id"`
	Height           int    `json:"height"`
	NextBpHash       string `json:"next_bp_hash"`
	NextEpochID      string `json:"next_epoch_id"`
	OutcomeRoot      string `json:"outcome_root"`
	PrevStateRoot    string `json:"prev_state_root"`
	Timestamp        int64  `json:"timestamp"`
	TimestampNanosec string `json:"timestamp_nanosec"`
}

type IstanbulAggregatedSeal

type IstanbulAggregatedSeal struct {
	Bitmap    *big.Int
	Signature []byte
	Round     *big.Int
}

type IstanbulExtra

type IstanbulExtra struct {
	// Validators are the validators that have been added in the block
	Validators []common.Address
	// AddedPubKey are the BLS public keys for the validators added in the block
	AddedPubKey [][]byte
	// AddedG1PubKey are the BLS public keys for the validators added in the block
	AddedG1PubKey [][]byte
	// RemoveList is a bitmap having an active bit for each removed validator in the block
	RemoveList *big.Int
	// Seal is an ECDSA signature by the proposer
	Seal []byte
	// AggregatedSeal contains the aggregated BLS signature created via IBFT consensus.
	AggregatedSeal IstanbulAggregatedSeal
	// ParentAggregatedSeal contains and aggregated BLS signature for the previous block.
	ParentAggregatedSeal IstanbulAggregatedSeal
}

func ConvertIstanbulExtra

func ConvertIstanbulExtra(istanbulExtra *types.IstanbulExtra) *IstanbulExtra

type MapTxReceipt

type MapTxReceipt struct {
	PostStateOrStatus []byte
	CumulativeGasUsed *big.Int
	Bloom             []byte
	Logs              []TxLog
}

type MerklePath

type MerklePath = []MerklePathItem

type MerklePathItem

type MerklePathItem struct {
	Hash      hash.CryptoHash `json:"hash"`
	Direction string          `json:"direction"`
}

type Metadata

type Metadata struct {
	GasProfile []GasProfile `json:"gas_profile"`
	Version    int          `json:"version"`
}

type NearNeedHeader

type NearNeedHeader struct {
	ParentHash  common.Hash      `json:"parentHash"       gencodec:"required"`
	Coinbase    common.Address   `json:"coinbase"            gencodec:"required"`
	Root        common.Hash      `json:"root"         gencodec:"required"`
	TxHash      common.Hash      `json:"txHash" gencodec:"required"`
	ReceiptHash common.Hash      `json:"receiptHash"     gencodec:"required"`
	Bloom       types.Bloom      `json:"bloom"        gencodec:"required"`
	Number      *hexutil.Big     `json:"number"           gencodec:"required"`
	GasLimit    hexutil.Uint64   `json:"gasLimit"         gencodec:"required"`
	GasUsed     hexutil.Uint64   `json:"gasUsed"          gencodec:"required"`
	Time        hexutil.Uint64   `json:"time"        gencodec:"required"`
	Extra       hexutil.Bytes    `json:"extra"        gencodec:"required"`
	MixDigest   common.Hash      `json:"mixDigest"`
	Nonce       types.BlockNonce `json:"nonce"`
	BaseFee     *hexutil.Big     `json:"baseFee" rlp:"optional"`
	Hash        common.Hash      `json:"hash"`
}

func ConvertNearNeedHeader

func ConvertNearNeedHeader(h *types.Header) *NearNeedHeader

type NearReceiptProof

type NearReceiptProof struct {
	BlockHeaderLite  BlockHeaderLite    `json:"block_header_lite"`
	BlockProof       []BlockProof       `json:"block_proof"`
	OutcomeProof     OutcomeProof       `json:"outcome_proof"`
	OutcomeRootProof []OutcomeRootProof `json:"outcome_root_proof"`
}

type NewMapReceiptProof

type NewMapReceiptProof struct {
	Header       *BlockHeader
	AggPk        *G2
	KeyIndex     []byte
	Proof        [][]byte
	Ist          IstanbulExtra
	TxReceiptRlp TxReceiptRlp
}

type NewReceiptProof

type NewReceiptProof struct {
	Router   common.Address
	Coin     common.Address
	SrcChain *big.Int
	DstChain *big.Int
	TxProve  []byte
}

type Outcome

type Outcome struct {
	ExecutorID  string        `json:"executor_id"`
	GasBurnt    int64         `json:"gas_burnt"`
	Logs        []interface{} `json:"logs"`
	Metadata    Metadata      `json:"metadata"`
	ReceiptIds  []string      `json:"receipt_ids"`
	Status      Status        `json:"status"`
	TokensBurnt string        `json:"tokens_burnt"`
}

type OutcomeProof

type OutcomeProof struct {
	BlockHash string  `json:"block_hash"`
	ID        string  `json:"id"`
	Outcome   Outcome `json:"outcome"`
	Proof     []Proof `json:"proof"`
}

type OutcomeRootProof

type OutcomeRootProof struct {
	Direction string `json:"direction"`
	Hash      string `json:"hash"`
}

type Proof

type Proof struct {
	Direction string `json:"direction"`
	Hash      string `json:"hash"`
}

type Receipt

type Receipt struct {
	Action Action `json:"Action"`
}

type ReceiptProof

type ReceiptProof struct {
	Header   *BlockHeader
	AggPk    *G2
	Receipt  *TxReceipt
	KeyIndex []byte
	Proof    [][]byte
}

type ReceiptView

type ReceiptView struct {
	PredecessorId types.AccountID `json:"predecessor_id"`
	ReceiverID    types.AccountID `json:"receiver_id"`
	ReceiptID     hash.CryptoHash `jsom:"receipt_id"`
	Receipt       Receipt         `json:"receipt"`
}

type Role

type Role string
var (
	RoleOfMaintainer Role = "maintainer"
	RoleOfMessenger  Role = "messenger"
	RoleOfOracle     Role = "oracle"
)

type SignedTransactionView

type SignedTransactionView struct {
	SignerID   types.AccountID           `json:"signer_id"`
	PublicKey  key.Base58PublicKey       `json:"public_key"`
	Nonce      types.Nonce               `json:"nonce"`
	ReceiverID types.AccountID           `json:"receiver_id"`
	Actions    []interface{}             `json:"actions"`
	Signature  signature.Base58Signature `json:"signature"`
	Hash       hash.CryptoHash           `json:"hash"`
}

type StateChangeCauseView

type StateChangeCauseView struct {
	ReceiptHash string `json:"receipt_hash"`
	Type        string `json:"type"`
}

type StateChangeView

type StateChangeView struct {
	AccountId     types.AccountID `json:"account_id"`
	Amount        string          `json:"amount"`
	CodeHash      string          `json:"code_hash"`
	Locked        string          `json:"locked"`
	StoragePaidAt int64           `json:"storage_paid_at"`
	StorageUsage  int64           `json:"storage_usage"`
	CodeBase64    string          `json:"code_base_64"`
}

type StateChangeWithCauseView

type StateChangeWithCauseView struct {
	Type   TypeOfStateChange    `json:"type"`
	Cause  StateChangeCauseView `json:"cause"`
	Change StateChangeView      `json:"change"`
}

type StateChangesView

type StateChangesView []StateChangeWithCauseView

type Status

type Status struct {
	SuccessValue string `json:"SuccessValue"`
}

type StreamerMessage

type StreamerMessage struct {
	Block  client.BlockView `json:"block"`
	Shards []IndexerShard   `json:"shards"`
}

type TxLog

type TxLog struct {
	Addr   common.Address
	Topics [][]byte
	Data   []byte
}

type TxProve

type TxProve struct {
	Receipt     *ethtypes.Receipt
	Prove       light.NodeList
	BlockNumber uint64
	TxIndex     uint
}

type TxReceipt

type TxReceipt struct {
	ReceiptType       *big.Int
	PostStateOrStatus []byte
	CumulativeGasUsed *big.Int
	Bloom             []byte
	Logs              []TxLog
}

func GetTxReceipt

func GetTxReceipt(receipt *ethtypes.Receipt) (*TxReceipt, error)

type TxReceiptRlp

type TxReceiptRlp struct {
	ReceiptType *big.Int
	ReceiptRlp  []byte
}

type TypeOfStateChange

type TypeOfStateChange string

type Zk added in v1.2.0

type Zk struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		Height string `json:"height"`
		Status int    `json:"status"`
		Result struct {
			Proof struct {
				PiA      []string   `json:"pi_a"`
				PiB      [][]string `json:"pi_b"`
				PiC      []string   `json:"pi_c"`
				Protocol string     `json:"protocol"`
			} `json:"proof"`
			PublicInput []string `json:"public_input"`
		} `json:"result"`
		ErrorMsg string `json:"error_msg"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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