ulxly

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArgGasLimit         = "gas-limit"
	ArgChainID          = "chain-id"
	ArgPrivateKey       = "private-key"
	ArgValue            = "value"
	ArgRPCURL           = "rpc-url"
	ArgBridgeAddress    = "bridge-address"
	ArgDestNetwork      = "destination-network"
	ArgDestAddress      = "destination-address"
	ArgForceUpdate      = "force-update-root"
	ArgCallData         = "call-data"
	ArgCallDataFile     = "call-data-file"
	ArgTimeout          = "transaction-receipt-timeout"
	ArgDepositCount     = "deposit-count"
	ArgDepositNetwork   = "deposit-network"
	ArgBridgeServiceURL = "bridge-service-url"
	ArgFileName         = "file-name"
	ArgFromBlock        = "from-block"
	ArgToBlock          = "to-block"
	ArgFilterSize       = "filter-size"
	ArgTokenAddress     = "token-address"
	ArgGlobalIndex      = "global-index"
	ArgDryRun           = "dry-run"
	ArgGasPrice         = "gas-price"
	ArgBridgeMappings   = "bridge-service-map"
	ArgBridgeLimit      = "bridge-limit"
	ArgBridgeOffset     = "bridge-offset"
	ArgWait             = "wait"
)
View Source
const (
	// TreeDepth of 32 is pulled directly from the
	// _DEPOSIT_CONTRACT_TREE_DEPTH from the smart contract. We
	// could make this a variable as well
	// https://github.com/0xPolygonHermez/zkevm-contracts/blob/54f58c8b64806429bc4d5c52248f29cf80ba401c/contracts/v2/lib/DepositContractBase.sol#L15
	TreeDepth = 32
)

Variables

View Source
var (
	ErrNotReadyForClaim      = errors.New("the claim transaction is not yet ready to be claimed, try again in a few blocks")
	ErrDepositAlreadyClaimed = errors.New("the claim transaction has already been claimed")
)
View Source
var ULxLyCmd = &cobra.Command{
	Use:   "ulxly",
	Short: "Utilities for interacting with the uLxLy bridge",
	Long:  "Basic utility commands for interacting with the bridge contracts, bridge services, and generating proofs",
	Args:  cobra.NoArgs,
}

Functions

func WaitMineTransaction added in v0.1.67

func WaitMineTransaction(ctx context.Context, client *ethclient.Client, tx *types.Transaction, txTimeout uint64) error

Wait for the transaction to be mined

Types

type BridgeDeposit added in v0.1.67

type BridgeDeposit struct {
	LeafType      uint8  `json:"leaf_type"`
	OrigNet       uint32 `json:"orig_net"`
	OrigAddr      string `json:"orig_addr"`
	Amount        string `json:"amount"`
	DestNet       uint32 `json:"dest_net"`
	DestAddr      string `json:"dest_addr"`
	BlockNum      string `json:"block_num"`
	DepositCnt    uint32 `json:"deposit_cnt"`
	NetworkID     uint32 `json:"network_id"`
	TxHash        string `json:"tx_hash"`
	ClaimTxHash   string `json:"claim_tx_hash"`
	Metadata      string `json:"metadata"`
	ReadyForClaim bool   `json:"ready_for_claim"`
	GlobalIndex   string `json:"global_index"`
}

type BridgeDepositResponse added in v0.1.67

type BridgeDepositResponse struct {
	Deposit BridgeDeposit `json:"deposit"`
	Code    *int          `json:"code"`
	Message *string       `json:"message"`
}

type BridgeProof

type BridgeProof struct {
	Proof struct {
		MerkleProof       []string `json:"merkle_proof"`
		RollupMerkleProof []string `json:"rollup_merkle_proof"`
		MainExitRoot      string   `json:"main_exit_root"`
		RollupExitRoot    string   `json:"rollup_exit_root"`
	} `json:"proof"`
}

type DepositID added in v0.1.67

type DepositID struct {
	DepositCnt uint32 `json:"deposit_cnt"`
	NetworkID  uint32 `json:"network_id"`
}

type IMT

type IMT struct {
	Branches   map[uint32][]common.Hash
	Leaves     map[uint32]common.Hash
	Roots      []common.Hash
	ZeroHashes []common.Hash
	Proofs     map[uint32]Proof
}

func (*IMT) AddLeaf

func (s *IMT) AddLeaf(deposit *ulxly.UlxlyBridgeEvent)

AddLeaf will take a given deposit and add it to the collection of leaves. It will also update the

func (*IMT) GetProof

func (s *IMT) GetProof(depositNum uint32) Proof

GetProof will return an object containing the proof data necessary for verification

func (*IMT) GetRoot

func (s *IMT) GetRoot(depositNum uint32) common.Hash

GetRoot will return the root for a particular deposit

func (*IMT) Init

func (s *IMT) Init()

Init will allocate the objects in the IMT

type JsonError added in v0.1.67

type JsonError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type Proof

type Proof struct {
	Siblings     [TreeDepth]common.Hash
	Root         common.Hash
	DepositCount uint32
	LeafHash     common.Hash
}

func (*Proof) Check

func (p *Proof) Check(roots []common.Hash) (common.Hash, error)

Check is a sanity check of a proof in order to make sure that the proof that was generated creates a root that we recognize. This was useful while testing in order to avoid verifying that the proof works or doesn't work onchain

func (*Proof) String

func (p *Proof) String() string

String will create the json representation of the proof

Jump to

Keyboard shortcuts

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