bridge

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

README

The Obscuro ledger is intimately coupled with the Layer 1 ledger. Rollup transactions, deposits, attestations, etc, are all executed through the L1.

This package implements the logic that integrates Obscuro with the Ethereum Layer 1.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BridgeAddress = gethcommon.BytesToAddress(gethcommon.Hex2Bytes(bridgeAddr))

BridgeAddress - address of the virtual bridge

HOCContract - address of the deployed "hocus" erc20 on the L2

View Source
var HOCOwner, _ = crypto.HexToECDSA(hocOwnerKeyHex)

POCContract - address of the deployed "pocus" erc20 on the L2

View Source
var POCOwner, _ = crypto.HexToECDSA(pocOwnerKeyHex)

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	SupportedTokens map[ERC20]*ERC20Mapping
	// BridgeAddress The address the bridge on the L2
	BridgeAddress gethcommon.Address

	MgmtContractLib  mgmtcontractlib.MgmtContractLib
	Erc20ContractLib erc20contractlib.ERC20ContractLib

	TransactionBlobCrypto crypto2.TransactionBlobCrypto

	ObscuroChainID  int64
	EthereumChainID int64
	// contains filtered or unexported fields
}

Bridge encapsulates all logic around processing the interactions with an L1

func New

func New(
	hocAddress *gethcommon.Address,
	pocAddress *gethcommon.Address,
	mgmtContractLib mgmtcontractlib.MgmtContractLib,
	erc20ContractLib erc20contractlib.ERC20ContractLib,
	transactionBlobCrypto crypto2.TransactionBlobCrypto,
	obscuroChainID int64,
	ethereumChainID int64,
	logger gethlog.Logger,
) *Bridge

func (*Bridge) BatchPostProcessingWithdrawals added in v0.8.0

func (bridge *Bridge) BatchPostProcessingWithdrawals(newHeadBatch *core.Batch, state *state.StateDB, receiptsMap map[gethcommon.Hash]*types.Receipt) []common.Withdrawal

Todo - this has to be implemented differently based on how we define the ObsERC20

func (*Bridge) ExtractDeposits

func (bridge *Bridge) ExtractDeposits(
	fromBlock *types.Block,
	toBlock *types.Block,
	blockResolver db.BlockResolver,
	rollupState *state.StateDB,
) []*common.L2Tx

ExtractDeposits returns a list of L2 deposit transactions generated from the L1 deposit transactions starting with the proof of the parent rollup(exclusive) to the proof of the current rollup

func (*Bridge) ExtractRollups

func (bridge *Bridge) ExtractRollups(b *types.Block, blockResolver db.BlockResolver) []*core.Rollup

ExtractRollups - returns a list of the rollups published in this block

func (*Bridge) GetMapping

func (bridge *Bridge) GetMapping(l1ContractAddress *gethcommon.Address) *ERC20Mapping

GetMapping - finds the mapping based on the address that was called in an L1 transaction

func (*Bridge) IsWithdrawal

func (bridge *Bridge) IsWithdrawal(address gethcommon.Address) bool

func (*Bridge) L1Address

func (bridge *Bridge) L1Address(l2Address *gethcommon.Address) *gethcommon.Address

L1Address - returns the L1 address of a token based on the mapping

func (*Bridge) NewDepositTx

func (bridge *Bridge) NewDepositTx(contract *gethcommon.Address, address gethcommon.Address, amount *big.Int, rollupState *state.StateDB, adjustNonce uint64) *common.L2Tx

NewDepositTx creates a synthetic Obscuro transfer transaction based on deposits into the L1 bridge. Todo - has to go through a few more iterations

type ERC20

type ERC20 string

ERC20 - the supported ERC20 tokens. A list of made-up tokens used for testing. Todo - this will be removed together will all the keys and addresses.

const (
	HOC     ERC20 = "HOC"
	POC     ERC20 = "POC"
	HOCAddr       = "f3a8bd422097bFdd9B3519Eaeb533393a1c561aC"
)

type ERC20Mapping

type ERC20Mapping struct {
	Name ERC20

	// L1Owner   wallet.Wallet
	L1Address *gethcommon.Address

	Owner     wallet.Wallet // for now the wrapped L2 version is owned by a wallet, but this will change
	L2Address *gethcommon.Address
}

ERC20Mapping - maps an L1 Erc20 to an L2 Erc20 address

Jump to

Keyboard shortcuts

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