ethadapter

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

README

This package contains the Ethereum integration logic.

  1. The RPC connection to a geth node
  2. The ABIs for the smart contracts which the platform needs to know about.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthClient

type EthClient interface {
	BlockByHash(id gethcommon.Hash) (*types.Block, error)                         // retrieves a block given a hash
	BlockByNumber(n *big.Int) (*types.Block, error)                               // retrieves a block given a number - returns head block if n is nil
	SendTransaction(signedTx *types.Transaction) error                            // issues an ethereum transaction (expects signed tx)
	TransactionReceipt(hash gethcommon.Hash) (*types.Receipt, error)              // fetches the ethereum transaction receipt
	Nonce(address gethcommon.Address) (uint64, error)                             // fetches the account nonce to use in the next transaction
	BalanceAt(account gethcommon.Address, blockNumber *big.Int) (*big.Int, error) // fetches the balance of the account

	Info() Info                                                         // retrieves the node Info
	FetchHeadBlock() *types.Block                                       // retrieves the block at head height
	BlocksBetween(block *types.Block, head *types.Block) []*types.Block // returns the blocks between two blocks
	IsBlockAncestor(block *types.Block, proof common.L1RootHash) bool   // returns if the node considers a block the ancestor
	BlockListener() (chan *types.Header, ethereum.Subscription)         // subscribes to new blocks and returns a listener with the blocks heads and the subscription handler

	CallContract(msg ethereum.CallMsg) ([]byte, error) // Runs the provided call message on the latest block.

	Stop() // tries to cleanly stop the client and release any resources

	EthClient() *ethclient.Client // returns the underlying eth client
}

EthClient defines the interface for RPC communications with the ethereum nodes TODO Some of these methods are composed calls that should be decoupled in the future (ie: BlocksBetween or IsBlockAncestor)

func NewEthClient

func NewEthClient(ipaddress string, port uint, timeout time.Duration, l2ID gethcommon.Address, logger gethlog.Logger) (EthClient, error)

NewEthClient instantiates a new ethadapter.EthClient that connects to an ethereum node

type Info

type Info struct {
	L2ID gethcommon.Address // the address of the Obscuro node this client is dedicated to
}

Info forces the RPC EthClient to return the data in the same format (independently of its implementation)

type L1DepositTx

type L1DepositTx struct {
	Amount        *big.Int            // Amount to be deposited
	To            *gethcommon.Address // Address the ERC20 Transfer was made to (always be the Management Contract Addr)
	Sender        *gethcommon.Address // Address that issued the ERC20, the token holder or tx.origin
	TokenContract *gethcommon.Address // Address of the ERC20 Contract address that was executed
}

type L1InitializeSecretTx

type L1InitializeSecretTx struct {
	AggregatorID  *gethcommon.Address
	InitialSecret []byte
	HostAddress   string
	Attestation   common.EncodedAttestationReport
}

type L1RequestSecretTx

type L1RequestSecretTx struct {
	Attestation common.EncodedAttestationReport
}

type L1RespondSecretTx

type L1RespondSecretTx struct {
	Secret      []byte
	RequesterID gethcommon.Address
	AttesterID  gethcommon.Address
	AttesterSig []byte
	HostAddress string
}

func (*L1RespondSecretTx) Sign

func (l *L1RespondSecretTx) Sign(privateKey *ecdsa.PrivateKey) *L1RespondSecretTx

Sign signs the payload with a given private key

type L1RollupTx

type L1RollupTx struct {
	Rollup common.EncodedRollup
}

type L1Transaction

type L1Transaction interface{}

L1Transaction is an abstraction that transforms an Ethereum transaction into a format that can be consumed more easily by Obscuro.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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