executor

package
v0.0.0-...-b770cea Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 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

func AddNewLeafOpt(ethAddress string, tokenId, accountId uint64, amount string, chainAddr string) []*types.KeyValue

func BuildHistoryAccountByProof

func BuildHistoryAccountByProof(db dbm.KV, proofId uint64, reqRootHash string, feeAddrs *zt.ZkFeeAddrs) (*zt.HistoryAccountProofInfo, error)

BuildHistoryAccountByProof 根据ProofId构建截止到当前proof的account tree,以此账户构建证明,适用于截止到某个proof的证明

func BuildStateDbHistoryAccount

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

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

func CalcLatestAccountIDKey

func CalcLatestAccountIDKey() []byte

func CalcNewAccountIDkv

func CalcNewAccountIDkv(accounID int64) *types.KeyValue

func GetAccountIdPrimaryKey

func GetAccountIdPrimaryKey(accountId uint64) []byte

func GetAccountIdPrimaryKeyPrefix

func GetAccountIdPrimaryKeyPrefix() string

func GetAccountTreeKey

func GetAccountTreeKey() []byte

func GetAmountWithFee

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

func GetChainEthPrimaryKey

func GetChainEthPrimaryKey(chainAddr string, ethAddr string) []byte

func GetFeeData

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

该接口需要被zkrelayer使用

func GetHistoryAccountProof

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

func GetL2FirstQueueId

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

func GetL2LastQueueId

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

L2 queue id 从1开始编号,跟L1 priority 不同,后者为了和eth合约编号保持一致

func GetL2QueueIdOp

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

func GetLeafByAccountId

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

func GetLeafByChainAddress

func GetLeafByChainAddress(db dbm.KV, chainAddr string) ([]*zt.Leaf, error)

func GetLeafByChainAndEthAddress

func GetLeafByChainAndEthAddress(db dbm.KV, chainAddr, ethAddress string) (*zt.Leaf, error)

func GetLeafByEthAddress

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

func GetLocalChainEthPrimaryKey

func GetLocalChainEthPrimaryKey(chainAddr string, ethAddr string) []byte

func GetNFTHashPrimaryKey

func GetNFTHashPrimaryKey(nftHash string) []byte

func GetNFTIdPrimaryKey

func GetNFTIdPrimaryKey(nftTokenId uint64) []byte

func GetName

func GetName() string

GetName get driver name

func GetPriority2QueueId

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

func GetPriorityDepositData

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

func GetProofId2QueueId

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

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

func GetTokenByTokenId

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

func GetTokenPrimaryKey

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

func GetTokenPrimaryKeyPrefix

func GetTokenPrimaryKeyPrefix() string

func GetTokenSymbolIdKey

func GetTokenSymbolIdKey(symbol string) []byte

GetTokenSymbolIdKey token symbol 对应id

func GetTokenSymbolKey

func GetTokenSymbolKey(tokenId string) []byte

GetTokenSymbolKey tokenId 对应symbol

func GetTreeSideAmount

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.ChainConfig, sub []byte)

Init register dapp

func InitExecType

func InitExecType()

InitExecType Init Exec Type

func MakeSetTokenSymbolReceipt

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

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

func NewZksync

func NewZksync() drivers.Driver

NewExchange ...

func NewZksyncInfoTable

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

NewZksyncInfoTable ...

func TransferDecimalAmount

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

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

func (*Action) AssetTransferToExec

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

func (*Action) AssetWithdraw

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

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

func (*Action) ProxyExit

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

func (*Action) SetDefultPubKey

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

func (*Action) SetProxyPubKey

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

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

func (*Action) ZkTransfer

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

func (*Action) ZkWithdraw

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