Documentation ¶
Index ¶
- Constants
- func StopBridge() error
- func Teardown() 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) CheckL2Claim(ctx context.Context, networkID, depositCnt uint) 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) GetBridgeInfoByDestAddr(ctx context.Context, addr *common.Address) ([]*pb.Deposit, error)
- func (m *Manager) GetClaimData(ctx context.Context, networkID, depositCount uint) ([mtHeight][bridgectrl.KeyLen]byte, *etherman.GlobalExitRoot, error)
- func (m *Manager) GetCurrentGlobalExitRootFromSmc(ctx context.Context) (*etherman.GlobalExitRoot, error)
- func (m *Manager) GetLastBatchNumber(ctx context.Context) (uint64, error)
- func (m *Manager) GetLatestGlobalExitRootFromL1(ctx context.Context) (*etherman.GlobalExitRoot, error)
- func (m *Manager) GetTokenWrapped(ctx context.Context, originNetwork uint, originalTokenAddr common.Address, ...) (*etherman.TokenWrapped, error)
- func (m *Manager) GetTrustedGlobalExitRootSynced(ctx context.Context) (*etherman.GlobalExitRoot, error)
- func (m *Manager) MintERC20(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, smtProof [mtHeight][32]byte, ...) 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, smtProof [mtHeight][32]byte, ...) error
- func (m *Manager) SendL2Deposit(ctx context.Context, tokenAddr common.Address, amount *big.Int, ...) error
- func (m *Manager) Setup() error
- func (m *Manager) StartBridge() error
- func (m *Manager) UpdateBatchesForTesting(ctx context.Context, batchNum uint64) error
- func (m *Manager) UpdateBlocksForTesting(ctx context.Context, networkID uint, blockNum uint64) error
- func (m *Manager) WaitExitRootToBeSynced(ctx context.Context, orgExitRoot *etherman.GlobalExitRoot, isRollup bool) error
- type NetworkSID
- type StorageInterface
Constants ¶
const ( // MaticTokenAddress token address MaticTokenAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" //nolint:gosec )
Variables ¶
This section is empty.
Functions ¶
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 enpoint to be ready
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 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) CheckL2Claim ¶ added in v0.1.0
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, *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) GetLastBatchNumber ¶
GetLastBatchNumber returns the last batch number.
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) error
SendL1BridgeMessage bridges a message from l1 to l2.
func (*Manager) SendL1Claim ¶
func (m *Manager) SendL1Claim(ctx context.Context, deposit *pb.Deposit, smtProof [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 [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 ¶
Setup creates all the required components and initializes them according to the manager config.
func (*Manager) StartBridge ¶
StartBridge restarts the bridge service.
func (*Manager) UpdateBatchesForTesting ¶
UpdateBatchesForTesting updates batches for testing.
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 unitl 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 GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) UpdateBatchesForTesting(ctx context.Context, batchNum 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) AddBatch(ctx context.Context, batch *etherman.Batch, dbTx pgx.Tx) error AddVerifiedBatch(ctx context.Context, verifiedBatch *etherman.VerifiedBatch, dbTx pgx.Tx) 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