ethereum

package
v0.0.0-...-8201b66 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllReceipts

func GetAllReceipts(ctx context.Context, conn *Connection, block *etypes.Block) (etypes.Receipts, error)

Fetch all receipts for the given block in batches of `receiptFetchBatchSize`

func MakeHeaderFromEthHeader

func MakeHeaderFromEthHeader(
	gethheader *etypes.Header,
	proofcache *ethashproof.DatasetMerkleTreeCache,
	log *logrus.Entry,
) (*chain.Header, error)

func MakeMessageFromEvent

func MakeMessageFromEvent(mapping map[common.Address]string, event *etypes.Log, receiptsTrie *etrie.Trie, log *logrus.Entry) (*chain.EthereumOutboundMessage, error)

Types

type BlockCache

type BlockCache struct {
	// contains filtered or unexported fields
}

Keeps the blocks and receipts for the latest block heights / numbers in memory (up to `capacity` block numbers)

func NewBlockCache

func NewBlockCache(capacity int) *BlockCache

func (*BlockCache) Get

func (bc *BlockCache) Get(hash gethCommon.Hash) (*gethTypes.Block, *gethTrie.Trie, bool)

func (*BlockCache) Insert

func (bc *BlockCache) Insert(block *gethTypes.Block, receiptTrie *gethTrie.Trie)

type BlockLoader

type BlockLoader interface {
	GetBlock(ctx context.Context, hash gethCommon.Hash) (*gethTypes.Block, error)
	GetAllReceipts(ctx context.Context, block *gethTypes.Block) (gethTypes.Receipts, error)
}

type ChannelConfig

type ChannelConfig struct {
	Inbound  string `mapstructure:"inbound"`
	Outbound string `mapstructure:"outbound"`
}

type ChannelsConfig

type ChannelsConfig struct {
	Basic        ChannelConfig `mapstructure:"basic"`
	Incentivized ChannelConfig `mapstructure:"incentivized"`
}

type Config

type Config struct {
	Endpoint string `mapstructure:"endpoint"`
	// 	BeefyPrivateKey                string         `mapstructure:"beefy-private-key"`
	// 	ParachainCommitmentsPrivateKey string         `mapstructure:"parachain-commitments-private-key"`
	DescendantsUntilFinal byte `mapstructure:"descendants-until-final"`
	// 	Channels                       ChannelsConfig `mapstructure:"channels"`
	// 	BeefyLightClient               string         `mapstructure:"beefylightclient"`
	StartBlock uint64 `mapstructure:"startblock"`
}

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(endpoint string, kp *secp256k1.Keypair, log *logrus.Entry) *Connection

func (*Connection) Close

func (co *Connection) Close()

func (*Connection) Connect

func (co *Connection) Connect(ctx context.Context) error

func (*Connection) GetClient

func (co *Connection) GetClient() *ethclient.Client

func (*Connection) GetKP

func (co *Connection) GetKP() *secp256k1.Keypair

type DefaultBlockLoader

type DefaultBlockLoader struct {
	Conn *Connection
}

func (*DefaultBlockLoader) GetAllReceipts

func (d *DefaultBlockLoader) GetAllReceipts(ctx context.Context, block *gethTypes.Block) (gethTypes.Receipts, error)

func (*DefaultBlockLoader) GetBlock

type DefaultCacheLoader

type DefaultCacheLoader struct{}

func (*DefaultCacheLoader) MakeCache

type DoubleNodeWithMerkleProof

type DoubleNodeWithMerkleProof struct {
	DagNodes [2]types.H512
	Proof    [][16]byte
}

func MakeProofData

func MakeProofData(
	gethheader *etypes.Header,
	proofcache *ethashproof.DatasetMerkleTreeCache,
) ([]DoubleNodeWithMerkleProof, error)

type EthashproofCacheLoader

type EthashproofCacheLoader interface {
	MakeCache(epoch uint64) (*ethashproof.DatasetMerkleTreeCache, error)
}

type EthashproofCacheState

type EthashproofCacheState struct {
	sync.Mutex
	// contains filtered or unexported fields
}
type Header struct {
	Fields headerSCALE
	// contains filtered or unexported fields
}

func MakeHeaderData

func MakeHeaderData(gethheader *etypes.Header) (*Header, error)

func (*Header) Decode

func (h *Header) Decode(decoder scale.Decoder) error

func (Header) Encode

func (h Header) Encode(encoder scale.Encoder) error

func (*Header) ID

func (h *Header) ID() HeaderID

type HeaderCacheState

type HeaderCacheState struct {
	// contains filtered or unexported fields
}

HeaderCacheState fetches and caches data we need to construct proofs as we move along the Ethereum chain.

func NewHeaderCacheState

func NewHeaderCacheState(
	eg *errgroup.Group,
	initBlockHeight uint64,
	bl BlockLoader,
	ecl EthashproofCacheLoader,
) (*HeaderCacheState, error)

func (*HeaderCacheState) GetEthashproofCache

func (s *HeaderCacheState) GetEthashproofCache(number uint64) (*ethashproof.DatasetMerkleTreeCache, error)

GetEthashProofCache returns the cache used for proof generation. It will return immediately if `number` is in the current or next epoch. Outside that range, it might block for multiple minutes to generate the cache. Calling GetEthashproofCache will also update the current epoch to `number` / 30000.

func (*HeaderCacheState) GetReceiptTrie

func (s *HeaderCacheState) GetReceiptTrie(ctx context.Context, hash gethCommon.Hash) (*gethTrie.Trie, error)

GetReceiptTrie returns a Merkle Patricia trie constructed from the receipts of the block specified by `hash`. If the trie isn't cached, it will block for multiple seconds to fetch receipts and construct the trie.

type HeaderID

type HeaderID struct {
	Number types.U64
	Hash   types.H256
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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