executor

package
v1.67.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KeyPrefixStateDB state db key必须前缀
	KeyPrefixStateDB = "mavl-zksync-"
	//KeyPrefixLocalDB local db的key必须前缀
	KeyPrefixLocalDB = "LODB-zksync"
)

Variables

This section is empty.

Functions

func AddNewLeafOpt added in v1.67.5

func AddNewLeafOpt(statedb dbm.KV, ethAddress string, tokenId, accountId uint64, amount string, chain33Addr string) ([]*types.KeyValue, error)

func BuildStateDbHistoryAccount added in v1.67.5

func BuildStateDbHistoryAccount(db dbm.KV, reqRootHash string) (*zt.HistoryAccountProofInfo, error)

BuildStateDbHistoryAccount 从statedb中构建账户tree,以此构建证明

func CalcLatestAccountIDKey added in v1.67.5

func CalcLatestAccountIDKey() []byte

func CalcNewAccountIDkv added in v1.67.5

func CalcNewAccountIDkv(accounID int64) *types.KeyValue

func GetAccountIdPrimaryKey

func GetAccountIdPrimaryKey(accountId uint64) []byte

func GetAccountIdPrimaryKeyPrefix added in v1.67.5

func GetAccountIdPrimaryKeyPrefix() string

func GetAccountTreeKey

func GetAccountTreeKey() []byte

func GetAmountWithFee added in v1.67.5

func GetAmountWithFee(db dbm.KV, actionTy int32, amount string, tokenId uint64) (amountPlusFee, fee string, err error)

func GetChain33EthPrimaryKey

func GetChain33EthPrimaryKey(chain33Addr string, ethAddr string) []byte

func GetFeeData added in v1.67.5

func GetFeeData(db dbm.KV, actionTy int32, tokenId uint64) (*zt.ZkFee, error)

该接口需要被zkrelayer使用

func GetHistoryAccountProof added in v1.67.4

func GetHistoryAccountProof(historyAccountInfo *zt.HistoryAccountProofInfo, targetAccountID, targetTokenID uint64) (*zt.ZkProofWitness, error)

func GetL2FirstQueueId added in v1.67.5

func GetL2FirstQueueId(db dbm.KV) (int64, error)

func GetL2LastQueueId added in v1.67.5

func GetL2LastQueueId(db dbm.KV) (int64, error)

func GetL2QueueIdOp added in v1.67.5

func GetL2QueueIdOp(db dbm.KV, id int64) (*zt.ZkOperation, error)

func GetLeafByAccountId

func GetLeafByAccountId(db dbm.KV, accountId uint64) (*zt.Leaf, error)

func GetLeafByChain33Address

func GetLeafByChain33Address(db dbm.KV, chain33Addr string) ([]*zt.Leaf, error)

func GetLeafByChain33AndEthAddress

func GetLeafByChain33AndEthAddress(db dbm.KV, chain33Addr, ethAddress string) (*zt.Leaf, error)

func GetLeafByEthAddress

func GetLeafByEthAddress(db dbm.KV, ethAddress string) ([]*zt.Leaf, error)

func GetLocalChain33EthPrimaryKey

func GetLocalChain33EthPrimaryKey(chain33Addr string, ethAddr string) []byte

func GetNFTHashPrimaryKey added in v1.67.4

func GetNFTHashPrimaryKey(nftHash string) []byte

func GetNFTIdPrimaryKey added in v1.67.4

func GetNFTIdPrimaryKey(nftTokenId uint64) []byte

func GetName

func GetName() string

GetName get driver name

func GetPriority2QueueId added in v1.67.5

func GetPriority2QueueId(db dbm.KV, priorityId int64) (int64, error)

func GetPriorityDepositData added in v1.67.5

func GetPriorityDepositData(db dbm.KV, priorityId int64) (*zt.ZkDepositWitnessInfo, error)

func GetProofId2QueueId added in v1.67.5

func GetProofId2QueueId(db dbm.KV, id uint64) (*zt.ProofId2QueueIdData, error)

GetProofId2QueueId proof中的pubdata 对应的operation的start/end queueId

func GetRootIndexPrimaryKey

func GetRootIndexPrimaryKey(rootIndex uint64) []byte

func GetTokenByAccountIdAndTokenId

func GetTokenByAccountIdAndTokenId(db dbm.KV, accountId uint64, tokenId uint64) (*zt.TokenBalance, error)

func GetTokenByAccountIdAndTokenIdInDB

func GetTokenByAccountIdAndTokenIdInDB(db dbm.KV, accountId uint64, tokenId uint64) (*zt.TokenBalance, error)

func GetTokenBySymbol added in v1.67.5

func GetTokenBySymbol(db dbm.KV, symbol string) (*zt.ZkTokenSymbol, error)

func GetTokenByTokenId added in v1.67.5

func GetTokenByTokenId(db dbm.KV, tokenId string) (*zt.ZkTokenSymbol, error)

func GetTokenPrimaryKey

func GetTokenPrimaryKey(accountId uint64, tokenId uint64) []byte

func GetTokenPrimaryKeyPrefix added in v1.67.5

func GetTokenPrimaryKeyPrefix() string

func GetTokenSymbolIdKey added in v1.67.4

func GetTokenSymbolIdKey(symbol string) []byte

GetTokenSymbolIdKey token symbol 对应id

func GetTokenSymbolKey added in v1.67.4

func GetTokenSymbolKey(tokenId string) []byte

GetTokenSymbolKey tokenId 对应symbol

func GetTreeSideAmount added in v1.67.5

func GetTreeSideAmount(amount, totalAmount, fee string, sysDecimal, tokenDecimal int) (amount4Tree, totalAmount4Tree, feeAmount4Tree string, err error)

根据系统和token精度,计算合约转化为二层tree侧的amount,合约侧amount都是系统精度

func Init

func Init(name string, cfg *types.Chain33Config, sub []byte)

Init register dapp

func InitExecType

func InitExecType()

InitExecType Init Exec Type

func MakeSetTokenSymbolReceipt added in v1.67.5

func MakeSetTokenSymbolReceipt(id string, oldVal, newVal *zt.ZkTokenSymbol) *types.Receipt

func NewAccountTreeTable

func NewAccountTreeTable(kvdb db.KV) *table.Table

NewAccountTreeTable ...

func NewCommitProofTable

func NewCommitProofTable(kvdb db.KV) *table.Table

NewCommitProofTable ...

func NewInitAccount added in v1.67.5

func NewInitAccount(ethFeeAddr, chain33FeeAddr string) ([]*types.KeyValue, error)

func NewZksync

func NewZksync() drivers.Driver

NewExchange ...

func NewZksyncInfoTable

func NewZksyncInfoTable(kvdb db.KV) *table.Table

NewZksyncInfoTable ...

func TransferDecimalAmount added in v1.67.5

func TransferDecimalAmount(amount string, fromDecimal, toDecimal int) (string, error)

from向to小数对齐,如果from>to, 需要裁减掉差别部分,且差别部分需要全0,如果from<to,差别部分需要补0

func UpdatePubKey

func UpdatePubKey(statedb dbm.KV, localdb dbm.KV, pubKeyTy uint64, pubKey *zt.ZkPubKey, accountId uint64) ([]*types.KeyValue, []*types.KeyValue, error)

Types

type AccountTreeRow

type AccountTreeRow struct {
	*zt.Leaf
}

AccountTreeRow table meta 结构

func NewAccountTreeRow

func NewAccountTreeRow() *AccountTreeRow

func (*AccountTreeRow) CreateRow

func (r *AccountTreeRow) CreateRow() *table.Row

CreateRow 新建数据行

func (*AccountTreeRow) Get

func (r *AccountTreeRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*AccountTreeRow) SetPayload

func (r *AccountTreeRow) SetPayload(data types.Message) error

SetPayload 设置数据

type Action

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

Action action struct

func NewAction

func NewAction(z *zksync, tx *types.Transaction, index int) *Action

NewAction ...

func (*Action) AssetTransfer added in v1.67.4

func (a *Action) AssetTransfer(transfer *types.AssetsTransfer, tx *types.Transaction, index int) (*types.Receipt, error)

func (*Action) AssetTransferToExec added in v1.67.4

func (a *Action) AssetTransferToExec(transfer *types.AssetsTransferToExec, tx *types.Transaction, index int) (*types.Receipt, error)

func (*Action) AssetWithdraw added in v1.67.4

func (a *Action) AssetWithdraw(withdraw *types.AssetsWithdraw, tx *types.Transaction, index int) (*types.Receipt, error)

func (*Action) ContractToTree

func (a *Action) ContractToTree(payload *zt.ZkContractToTree) (*types.Receipt, error)

func (*Action) Deposit

func (a *Action) Deposit(payload *zt.ZkDeposit) (*types.Receipt, error)

TODO:HexAddr2Decimal 地址的转换在确认其必要性,最后在合约内部进行清理,

func (*Action) GetIndex

func (a *Action) GetIndex() int64

GetIndex get index

func (*Action) MakeFeeLog

func (a *Action) MakeFeeLog(amount string, tokenId uint64) (*types.Receipt, *zt.ZkOperation, error)

func (*Action) MintNFT added in v1.67.4

func (a *Action) MintNFT(payload *zt.ZkMintNFT) (*types.Receipt, error)

func (*Action) ProxyExit added in v1.67.4

func (a *Action) ProxyExit(payload *zt.ZkProxyExit) (*types.Receipt, error)

func (*Action) SetDefultPubKey added in v1.67.4

func (a *Action) SetDefultPubKey(payload *zt.ZkSetPubKey) ([]*types.KeyValue, []*types.KeyValue, error)

func (*Action) SetProxyPubKey added in v1.67.4

func (a *Action) SetProxyPubKey(payload *zt.ZkSetPubKey, leaf *zt.Leaf) ([]*types.KeyValue, []*types.KeyValue, error)

设置代理地址的公钥

func (*Action) SetPubKey

func (a *Action) SetPubKey(payload *zt.ZkSetPubKey) (*types.Receipt, error)

func (*Action) TransferToNew

func (a *Action) TransferToNew(payload *zt.ZkTransferToNew) (*types.Receipt, error)

func (*Action) TreeToContract

func (a *Action) TreeToContract(payload *zt.ZkTreeToContract) (*types.Receipt, error)

L2 ----> 合约账户(树) 操作1. FromAccountId -----> SystemTree2ContractAcctId,执行ZkTransfer 操作2. UpdateContractAccount,在合约内部的铸币操作

func (*Action) UpdateContractAccount

func (a *Action) UpdateContractAccount(amount, symbol string, option int32, execName string) (*types.Receipt, error)

func (*Action) UpdateExecAccount added in v1.67.4

func (a *Action) UpdateExecAccount(accountdb *account.DB, amount int64, option int32, execName string) (*types.Receipt, error)

func (*Action) ZkTransfer added in v1.67.4

func (a *Action) ZkTransfer(payload *zt.ZkTransfer, actionTy int32) (*types.Receipt, error)

func (*Action) ZkWithdraw added in v1.67.4

func (a *Action) ZkWithdraw(payload *zt.ZkWithdraw) (*types.Receipt, error)

type CommitProofRow

type CommitProofRow struct {
	*zt.ZkCommitProof
}

CommitProofRow table meta 结构

func NewCommitProofRow

func NewCommitProofRow() *CommitProofRow

func (*CommitProofRow) CreateRow

func (r *CommitProofRow) CreateRow() *table.Row

CreateRow 新建数据行

func (*CommitProofRow) Get

func (r *CommitProofRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*CommitProofRow) SetPayload

func (r *CommitProofRow) SetPayload(data types.Message) error

SetPayload 设置数据

type TreeUpdateInfo

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

TreeUpdateInfo 更新信息,用于查询

type ZksyncInfoRow

type ZksyncInfoRow struct {
	*zt.AccountTokenBalanceReceipt
}

AccountTreeRow table meta 结构

func NewZksyncInfoRow

func NewZksyncInfoRow() *ZksyncInfoRow

func (*ZksyncInfoRow) CreateRow

func (r *ZksyncInfoRow) CreateRow() *table.Row

CreateRow 新建数据行

func (*ZksyncInfoRow) Get

func (r *ZksyncInfoRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*ZksyncInfoRow) SetPayload

func (r *ZksyncInfoRow) SetPayload(data types.Message) error

SetPayload 设置数据

Jump to

Keyboard shortcuts

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