operations

package
v0.5.0-RC11 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// PolTokenAddress token address
	PolTokenAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" //nolint:gosec

)

Variables

This section is empty.

Functions

func StartBridge added in v0.5.0

func StartBridge() error

StartBridge restarts the bridge service.

func StartBridge3 added in v0.5.0

func StartBridge3() error

StartBridge3 restarts the bridge service.

func StopBridge

func StopBridge() error

StopBridge stops the bridge service.

func StopBridge3 added in v0.5.0

func StopBridge3() error

StopBridge3 stops the bridge service.

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)
	GetClaims(ctx context.Context, req *pb.GetClaimsRequest) (*pb.GetClaimsResponse, error)
	GetProof(ctx context.Context, req *pb.GetProofRequest) (*pb.GetProofResponse, error)
}

BridgeServiceInterface is an interface for the bridge service.

type Config

type Config struct {
	L1NetworkURL string
	L2NetworkURL string
	L2NetworkID  uint
	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 GetOpsman added in v0.5.0

func GetOpsman(ctx context.Context, l2NetworkURL, dbName, bridgeServiceHTTPPort, bridgeServiceGRPCPort, port string, networkID uint) (*Manager, error)

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) CheckClaim added in v0.5.0

func (m *Manager) CheckClaim(ctx context.Context, deposit *pb.Deposit) error

CheckClaim checks if the claim is already in the network

func (*Manager) CustomCheckClaim added in v0.5.0

func (m *Manager) CustomCheckClaim(ctx context.Context, deposit *pb.Deposit, interval, deadline time.Duration) error

CustomCheckClaim 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) ERC20Transfer added in v0.5.0

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

ERC20Transfer send tokens

func (*Manager) GetBalances added in v0.5.0

func (m *Manager) GetBalances(ctx context.Context, originalNetwork uint32, originalTokenAddr, l1Holder, l2Holder common.Address) (l1Balance, l2Balance *big.Int, err error)

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) GetL1Balance added in v0.5.0

func (m *Manager) GetL1Balance(ctx context.Context, originalNetwork uint32, originalTokenAddr, holder common.Address) (*big.Int, error)

func (*Manager) GetL2Balance added in v0.5.0

func (m *Manager) GetL2Balance(ctx context.Context, originalNetwork uint32, originalTokenAddr, holder common.Address) (*big.Int, error)

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) GetLatestMonitoredTxGroupID added in v0.5.0

func (m *Manager) GetLatestMonitoredTxGroupID(ctx context.Context) (uint64, error)

func (*Manager) GetNumberClaims added in v0.5.0

func (m *Manager) GetNumberClaims(ctx context.Context, destAddr string) (int, error)

GetNumberClaims get the number of claim events synced

func (*Manager) GetTokenAddress added in v0.5.0

func (m *Manager) GetTokenAddress(ctx context.Context, network NetworkSID, originalNetwork uint, originalTokenAddr common.Address) (common.Address, error)

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, networkID uint) (*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) MintPOL added in v0.5.0

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

MintPOL mint POL 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, l2 NetworkSID) 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, l2 NetworkSID) error

SendL2Deposit sends a deposit from l2 to l1.

func (*Manager) SendMultipleL1Deposit added in v0.5.0

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

SendMultipleL1Deposit sends a deposit from l1 to l2.

func (*Manager) Setup

func (m *Manager) Setup() error

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

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, networkID, destNetwork uint) 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"
	L22 NetworkSID = "l22"
)

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, networkID, destNetwork uint, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error)
	GetLatestL1SyncedExitRoot(ctx context.Context, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error)
	GetLatestTrustedExitRoot(ctx context.Context, networkID uint, 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, origNetworkID, networkID uint, dbTx pgx.Tx) (*etherman.Claim, error)
	GetClaims(ctx context.Context, destAddr string, limit uint, offset uint, dbTx pgx.Tx) ([]*etherman.Claim, error)
	UpdateDepositsStatusForTesting(ctx context.Context, dbTx pgx.Tx) error
	GetLatestMonitoredTxGroupID(ctx context.Context, dbTx pgx.Tx) (uint64, 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