Documentation ¶
Index ¶
- Constants
- func StartBridge() error
- func StartBridge3() error
- func StopBridge() error
- func StopBridge3() error
- func WaitGRPCHealthy(address string) error
- func WaitRestHealthy(address string) error
- func WaitTxToBeMined(ctx context.Context, client *ethclient.Client, tx *types.Transaction, ...) error
- type BridgeServiceInterface
- type Config
- type Manager
- func (m *Manager) AddFunds(ctx context.Context) error
- func (m *Manager) ApproveERC20(ctx context.Context, erc20Addr, bridgeAddr common.Address, amount *big.Int, ...) error
- func (m *Manager) CheckAccountBalance(ctx context.Context, network NetworkSID, account *common.Address) (*big.Int, error)
- func (m *Manager) CheckAccountTokenBalance(ctx context.Context, network NetworkSID, tokenAddr common.Address, ...) (*big.Int, error)
- func (m *Manager) CheckClaim(ctx context.Context, deposit *pb.Deposit) error
- func (m *Manager) CustomCheckClaim(ctx context.Context, deposit *pb.Deposit, interval, deadline time.Duration) error
- func (m *Manager) DeployBridgeMessageReceiver(ctx context.Context, network NetworkSID) (common.Address, error)
- func (m *Manager) DeployERC20(ctx context.Context, name, symbol string, network NetworkSID) (common.Address, *ERC20.ERC20, error)
- func (m *Manager) ERC20Transfer(ctx context.Context, erc20Addr, to common.Address, amount *big.Int, ...) error
- func (m *Manager) GetBalances(ctx context.Context, originalNetwork uint32, ...) (l1Balance, l2Balance *big.Int, err error)
- func (m *Manager) GetBridgeInfoByDestAddr(ctx context.Context, addr *common.Address) ([]*pb.Deposit, error)
- func (m *Manager) GetClaimData(ctx context.Context, networkID, depositCount uint) ([mtHeight][bridgectrl.KeyLen]byte, [mtHeight][bridgectrl.KeyLen]byte, ...)
- func (m *Manager) GetCurrentGlobalExitRootFromSmc(ctx context.Context) (*etherman.GlobalExitRoot, error)
- func (m *Manager) GetL1Balance(ctx context.Context, originalNetwork uint32, ...) (*big.Int, error)
- func (m *Manager) GetL2Balance(ctx context.Context, originalNetwork uint32, ...) (*big.Int, error)
- func (m *Manager) GetLatestGlobalExitRootFromL1(ctx context.Context) (*etherman.GlobalExitRoot, error)
- func (m *Manager) GetLatestMonitoredTxGroupID(ctx context.Context) (uint64, error)
- func (m *Manager) GetNumberClaims(ctx context.Context, destAddr string) (int, error)
- func (m *Manager) GetTokenAddress(ctx context.Context, network NetworkSID, originalNetwork uint, ...) (common.Address, error)
- func (m *Manager) GetTokenWrapped(ctx context.Context, originNetwork uint, originalTokenAddr common.Address, ...) (*etherman.TokenWrapped, error)
- func (m *Manager) GetTrustedGlobalExitRootSynced(ctx context.Context, networkID uint) (*etherman.GlobalExitRoot, error)
- func (m *Manager) MintERC20(ctx context.Context, erc20Addr common.Address, amount *big.Int, ...) error
- func (m *Manager) MintPOL(ctx context.Context, erc20Addr common.Address, amount *big.Int, ...) error
- func (m *Manager) SendL1BridgeMessage(ctx context.Context, destAddr common.Address, destNetwork uint32, ...) error
- func (m *Manager) SendL1Claim(ctx context.Context, deposit *pb.Deposit, ...) error
- func (m *Manager) SendL1Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int, ...) error
- func (m *Manager) SendL2BridgeMessage(ctx context.Context, destAddr common.Address, destNetwork uint32, ...) error
- func (m *Manager) SendL2Claim(ctx context.Context, deposit *pb.Deposit, ...) error
- func (m *Manager) SendL2Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int, ...) error
- func (m *Manager) SendMultipleL1Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int, ...) error
- func (m *Manager) Setup() error
- func (m *Manager) UpdateBlocksForTesting(ctx context.Context, networkID uint, blockNum uint64) error
- func (m *Manager) WaitExitRootToBeSynced(ctx context.Context, orgExitRoot *etherman.GlobalExitRoot, ...) error
- type NetworkSID
- type StorageInterface
Constants ¶
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 WaitGRPCHealthy ¶
WaitGRPCHealthy waits for a gRPC endpoint to be responding according to the health standard in package grpc.health.v1
func WaitRestHealthy ¶
WaitRestHealthy waits for a rest endpoint to be ready
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 NewManager ¶
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) 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
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 (*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 (*Manager) GetL2Balance ¶ added in v0.5.0
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 (*Manager) GetNumberClaims ¶ added in v0.5.0
GetNumberClaims get the number of claim events synced
func (*Manager) GetTokenAddress ¶ added in v0.5.0
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 ¶
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