operations

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PolTokenAddress token address
	PolTokenAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" //nolint:gosec

)

Variables

This section is empty.

Functions

func StopBridge

func StopBridge() error

StopBridge stops the bridge service.

func Teardown

func Teardown() error

Teardown stops all the components.

func WaitGRPCHealthy

func WaitGRPCHealthy(address string) error

WaitGRPCHealthy waits for a gRPC endpoint to be responding according to the health standard in package grpc.health.v1

func WaitRestHealthy

func WaitRestHealthy(address string) error

WaitRestHealthy waits for a rest endpoint to be ready

func WaitTxToBeMined

func WaitTxToBeMined(ctx context.Context, client *ethclient.Client, tx *types.Transaction, timeout time.Duration) error

WaitTxToBeMined waits until a tx is mined or forged.

Types

type BridgeServiceInterface added in v0.1.0

type BridgeServiceInterface interface {
	GetBridges(ctx context.Context, req *pb.GetBridgesRequest) (*pb.GetBridgesResponse, error)
	GetProof(ctx context.Context, req *pb.GetProofRequest) (*pb.GetProofResponse, error)
}

BridgeServiceInterface is an interface for the bridge service.

type Config

type Config struct {
	Storage db.Config
	BT      bridgectrl.Config
	BS      server.Config
}

Config is the main Manager configuration.

type Manager

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

Manager controls operations and has knowledge about how to set up and tear down a functional environment.

func NewManager

func NewManager(ctx context.Context, cfg *Config) (*Manager, error)

NewManager returns a manager ready to be used and a potential error caused during its creation (which can come from the setup of the db connection).

func (*Manager) AddFunds

func (m *Manager) AddFunds(ctx context.Context) error

AddFunds adds pol and eth to the zkevm node wallet.

func (*Manager) ApproveERC20

func (m *Manager) ApproveERC20(ctx context.Context, erc20Addr, bridgeAddr common.Address, amount *big.Int, network NetworkSID) error

ApproveERC20 approves erc20 tokens

func (*Manager) CheckAccountBalance

func (m *Manager) CheckAccountBalance(ctx context.Context, network NetworkSID, account *common.Address) (*big.Int, error)

CheckAccountBalance checks the balance by address

func (*Manager) CheckAccountTokenBalance

func (m *Manager) CheckAccountTokenBalance(ctx context.Context, network NetworkSID, tokenAddr common.Address, account *common.Address) (*big.Int, error)

CheckAccountTokenBalance checks the balance by address

func (*Manager) CheckL2Claim added in v0.1.0

func (m *Manager) CheckL2Claim(ctx context.Context, networkID, depositCnt uint) error

CheckL2Claim checks if the claim is already in the L2 network.

func (*Manager) DeployBridgeMessageReceiver

func (m *Manager) DeployBridgeMessageReceiver(ctx context.Context, network NetworkSID) (common.Address, error)

DeployBridgeMessageReceiver deploys the brdige message receiver smc.

func (*Manager) DeployERC20

func (m *Manager) DeployERC20(ctx context.Context, name, symbol string, network NetworkSID) (common.Address, *ERC20.ERC20, error)

DeployERC20 deploys erc20 smc

func (*Manager) GetBridgeInfoByDestAddr

func (m *Manager) GetBridgeInfoByDestAddr(ctx context.Context, addr *common.Address) ([]*pb.Deposit, error)

GetBridgeInfoByDestAddr gets the bridge info

func (*Manager) GetClaimData

func (m *Manager) GetClaimData(ctx context.Context, networkID, depositCount uint) ([mtHeight][bridgectrl.KeyLen]byte, [mtHeight][bridgectrl.KeyLen]byte, *etherman.GlobalExitRoot, error)

GetClaimData gets the claim data

func (*Manager) GetCurrentGlobalExitRootFromSmc

func (m *Manager) GetCurrentGlobalExitRootFromSmc(ctx context.Context) (*etherman.GlobalExitRoot, error)

GetCurrentGlobalExitRootFromSmc reads the globalexitroot from the smc

func (*Manager) GetLatestGlobalExitRootFromL1

func (m *Manager) GetLatestGlobalExitRootFromL1(ctx context.Context) (*etherman.GlobalExitRoot, error)

GetLatestGlobalExitRootFromL1 reads the latest synced globalexitroot in l1 from db

func (*Manager) GetTokenWrapped

func (m *Manager) GetTokenWrapped(ctx context.Context, originNetwork uint, originalTokenAddr common.Address, isCreated bool) (*etherman.TokenWrapped, error)

GetTokenWrapped get token wrapped info

func (*Manager) GetTrustedGlobalExitRootSynced

func (m *Manager) GetTrustedGlobalExitRootSynced(ctx context.Context) (*etherman.GlobalExitRoot, error)

GetTrustedGlobalExitRootSynced reads the latest globalexitroot of a batch proposal from db

func (*Manager) MintERC20

func (m *Manager) MintERC20(ctx context.Context, erc20Addr common.Address, amount *big.Int, network NetworkSID) error

MintERC20 mint erc20 tokens

func (*Manager) SendL1BridgeMessage

func (m *Manager) SendL1BridgeMessage(ctx context.Context, destAddr common.Address, destNetwork uint32, amount *big.Int, metadata []byte, privKey *string) error

SendL1BridgeMessage bridges a message from l1 to l2.

func (*Manager) SendL1Claim

func (m *Manager) SendL1Claim(ctx context.Context, deposit *pb.Deposit, smtProof, smtRollupProof [mtHeight][32]byte, globalExitRoot *etherman.GlobalExitRoot) error

SendL1Claim send an L1 claim

func (*Manager) SendL1Deposit

func (m *Manager) SendL1Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int,
	destNetwork uint32, destAddr *common.Address,
) error

SendL1Deposit sends a deposit from l1 to l2.

func (*Manager) SendL2BridgeMessage

func (m *Manager) SendL2BridgeMessage(ctx context.Context, destAddr common.Address, destNetwork uint32, amount *big.Int, metadata []byte) error

SendL2BridgeMessage bridges a message from l2 to l1.

func (*Manager) SendL2Claim

func (m *Manager) SendL2Claim(ctx context.Context, deposit *pb.Deposit, smtProof, smtRollupProof [mtHeight][32]byte, globalExitRoot *etherman.GlobalExitRoot) error

SendL2Claim send an L2 claim

func (*Manager) SendL2Deposit

func (m *Manager) SendL2Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int,
	destNetwork uint32, destAddr *common.Address,
) error

SendL2Deposit sends a deposit from l2 to l1.

func (*Manager) Setup

func (m *Manager) Setup() error

Setup creates all the required components and initializes them according to the manager config.

func (*Manager) StartBridge

func (m *Manager) StartBridge() error

StartBridge restarts the bridge service.

func (*Manager) UpdateBlocksForTesting

func (m *Manager) UpdateBlocksForTesting(ctx context.Context, networkID uint, blockNum uint64) error

UpdateBlocksForTesting updates the hash of blocks.

func (*Manager) WaitExitRootToBeSynced

func (m *Manager) WaitExitRootToBeSynced(ctx context.Context, orgExitRoot *etherman.GlobalExitRoot, isRollup bool) error

WaitExitRootToBeSynced waits until new exit root is synced.

type NetworkSID

type NetworkSID string

NetworkSID is used to identify the network.

const (
	L1 NetworkSID = "l1"
	L2 NetworkSID = "l2"
)

NetworkSID constants

type StorageInterface added in v0.1.0

type StorageInterface interface {
	GetLastBlock(ctx context.Context, networkID uint, dbTx pgx.Tx) (*etherman.Block, error)
	GetLatestExitRoot(ctx context.Context, isRollup bool, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error)
	GetLatestL1SyncedExitRoot(ctx context.Context, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error)
	GetLatestTrustedExitRoot(ctx context.Context, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error)
	GetTokenWrapped(ctx context.Context, originalNetwork uint, originalTokenAddress common.Address, dbTx pgx.Tx) (*etherman.TokenWrapped, error)
	GetDepositCountByRoot(ctx context.Context, root []byte, network uint8, dbTx pgx.Tx) (uint, error)
	UpdateBlocksForTesting(ctx context.Context, networkID uint, blockNum uint64, dbTx pgx.Tx) error
	GetClaim(ctx context.Context, depositCount, networkID uint, dbTx pgx.Tx) (*etherman.Claim, error)
	UpdateDepositsStatusForTesting(ctx context.Context, dbTx pgx.Tx) error
	// synchronizer
	AddBlock(ctx context.Context, block *etherman.Block, dbTx pgx.Tx) (uint64, error)
	AddGlobalExitRoot(ctx context.Context, exitRoot *etherman.GlobalExitRoot, dbTx pgx.Tx) error
	AddTrustedGlobalExitRoot(ctx context.Context, trustedExitRoot *etherman.GlobalExitRoot, dbTx pgx.Tx) (bool, error)
	AddDeposit(ctx context.Context, deposit *etherman.Deposit, dbTx pgx.Tx) (uint64, error)
	AddClaim(ctx context.Context, claim *etherman.Claim, dbTx pgx.Tx) error
	AddTokenWrapped(ctx context.Context, tokenWrapped *etherman.TokenWrapped, dbTx pgx.Tx) error
	// atomic
	Rollback(ctx context.Context, dbTx pgx.Tx) error
	BeginDBTransaction(ctx context.Context) (pgx.Tx, error)
	Commit(ctx context.Context, dbTx pgx.Tx) error
}

StorageInterface is a storage interface.

func RunMockServer added in v0.1.0

func RunMockServer(dbType string, height uint8, networks []uint) (*bridgectrl.BridgeController, StorageInterface, error)

RunMockServer runs mock server

Jump to

Keyboard shortcuts

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