ethash

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package ethash implements the ethash proof-of-work consensus engine.

Index

Constants

View Source
const EthashABI = "" /* 2093-byte string literal not displayed */

EthashABI is the input ABI used to generate the binding from.

Variables

View Source
var (
	Instance   = New(defaultDir(), 3, 3, defaultDir(), 0, 3)
	DefaultDir = defaultDir()
)
View Source
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
View Source
var EthashBin = "" /* 25556-byte string literal not displayed */

EthashBin is the compiled bytecode used for deploying new contracts.

Functions

func BuildDagTrees

func BuildDagTrees(metaDataArray []*BlockMetaData)

make sure to only call with meta data of same epoch

func DAGSize

func DAGSize(blockNum uint64) uint64

func GenerateEpochData

func GenerateEpochData(epoch uint64) typedefs.EpochData

func MakeCache

func MakeCache(block uint64, dir string)

MakeCache generates a new ethash cache and optionally stores it to disk.

func MakeDAG

func MakeDAG(block uint64, dir string)

func MakeDataset

func MakeDataset(block uint64, dir string)

MakeDataset generates a new ethash dataset and optionally stores it to disk.

func PathToDAG

func PathToDAG(epoch uint64, dir string) string

func ProcessAllDuringRead

func ProcessAllDuringRead(
	datasetPath string, metaDataArray []*BlockMetaData)

func ProcessBufferedDag

func ProcessBufferedDag(bufferedDag *BufferedDag, mt *mtree.DagTree)

func ProcessDuringRead

func ProcessDuringRead(
	datasetPath string, mt *mtree.DagTree)

func SeedHash

func SeedHash(block uint64) []byte

SeedHash is the seed to use for generating a verification cache and the mining dataset.

Types

type BlockMetaData

type BlockMetaData struct {
	DagTree *mtree.DagTree
	// contains filtered or unexported fields
}

func NewBlockMetaData

func NewBlockMetaData(blockNumber uint64, nonce uint64, rlpHeaderHashWithoutNonce [32]byte) *BlockMetaData

func (*BlockMetaData) BuildDagTree

func (s *BlockMetaData) BuildDagTree(dag *BufferedDag)

func (*BlockMetaData) DAGElementArray

func (s *BlockMetaData) DAGElementArray() []*big.Int

func (*BlockMetaData) DAGProofArray

func (s *BlockMetaData) DAGProofArray() []*big.Int

type BufferedDag

type BufferedDag struct {
	Buf      []byte
	Indices  []uint32
	IndexCnt uint
}

type Ethash

type Ethash struct {
	EthashCaller     // Read-only binding to the contract
	EthashTransactor // Write-only binding to the contract
	EthashFilterer   // Log filterer for contract events
}

Ethash is an auto generated Go binding around an Ethereum contract.

func DeployEthash

func DeployEthash(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Ethash, error)

DeployEthash deploys a new Ethereum contract, binding an instance of Ethash to it.

func NewEthash

func NewEthash(address common.Address, backend bind.ContractBackend) (*Ethash, error)

NewEthash creates a new instance of Ethash, bound to a specific deployed contract.

type EthashCaller

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

EthashCaller is an auto generated read-only Go binding around an Ethereum contract.

func NewEthashCaller

func NewEthashCaller(address common.Address, caller bind.ContractCaller) (*EthashCaller, error)

NewEthashCaller creates a new read-only instance of Ethash, bound to a specific deployed contract.

func (*EthashCaller) IsEpochDataSet

func (_Ethash *EthashCaller) IsEpochDataSet(opts *bind.CallOpts, epochIndex *big.Int) (bool, error)

IsEpochDataSet is a free data retrieval call binding the contract method 0xc7b81f4f.

Solidity: function isEpochDataSet(uint256 epochIndex) view returns(bool)

func (*EthashCaller) VerifyPoW

func (_Ethash *EthashCaller) VerifyPoW(opts *bind.CallOpts, blockNumber *big.Int, rlpHeaderHashWithoutNonce [32]byte, nonce *big.Int, difficulty *big.Int, dataSetLookup []*big.Int, witnessForLookup []*big.Int) (*big.Int, *big.Int, error)

VerifyPoW is a free data retrieval call binding the contract method 0x29e265df.

Solidity: function verifyPoW(uint256 blockNumber, bytes32 rlpHeaderHashWithoutNonce, uint256 nonce, uint256 difficulty, uint256[] dataSetLookup, uint256[] witnessForLookup) view returns(uint256, uint256)

type EthashCallerRaw

type EthashCallerRaw struct {
	Contract *EthashCaller // Generic read-only contract binding to access the raw methods on
}

EthashCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.

func (*EthashCallerRaw) Call

func (_Ethash *EthashCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error

Call invokes the (constant) contract method with params as input values and sets the output to result. The result type might be a single field for simple returns, a slice of interfaces for anonymous returns and a struct for named returns.

type EthashCallerSession

type EthashCallerSession struct {
	Contract *EthashCaller // Generic contract caller binding to set the session for
	CallOpts bind.CallOpts // Call options to use throughout this session
}

EthashCallerSession is an auto generated read-only Go binding around an Ethereum contract, with pre-set call options.

func (*EthashCallerSession) IsEpochDataSet

func (_Ethash *EthashCallerSession) IsEpochDataSet(epochIndex *big.Int) (bool, error)

IsEpochDataSet is a free data retrieval call binding the contract method 0xc7b81f4f.

Solidity: function isEpochDataSet(uint256 epochIndex) view returns(bool)

func (*EthashCallerSession) VerifyPoW

func (_Ethash *EthashCallerSession) VerifyPoW(blockNumber *big.Int, rlpHeaderHashWithoutNonce [32]byte, nonce *big.Int, difficulty *big.Int, dataSetLookup []*big.Int, witnessForLookup []*big.Int) (*big.Int, *big.Int, error)

VerifyPoW is a free data retrieval call binding the contract method 0x29e265df.

Solidity: function verifyPoW(uint256 blockNumber, bytes32 rlpHeaderHashWithoutNonce, uint256 nonce, uint256 difficulty, uint256[] dataSetLookup, uint256[] witnessForLookup) view returns(uint256, uint256)

type EthashFilterer

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

EthashFilterer is an auto generated log filtering Go binding around an Ethereum contract events.

func NewEthashFilterer

func NewEthashFilterer(address common.Address, filterer bind.ContractFilterer) (*EthashFilterer, error)

NewEthashFilterer creates a new log filterer instance of Ethash, bound to a specific deployed contract.

func (*EthashFilterer) FilterSetEpochData

func (_Ethash *EthashFilterer) FilterSetEpochData(opts *bind.FilterOpts, sender []common.Address) (*EthashSetEpochDataIterator, error)

FilterSetEpochData is a free log retrieval operation binding the contract event 0x5cd723400be8430351b9cbaa5ea421b3fb2528c6a7650c493f895e7d97750da1.

Solidity: event SetEpochData(address indexed sender, uint256 error, uint256 errorInfo)

func (*EthashFilterer) ParseSetEpochData

func (_Ethash *EthashFilterer) ParseSetEpochData(log types.Log) (*EthashSetEpochData, error)

ParseSetEpochData is a log parse operation binding the contract event 0x5cd723400be8430351b9cbaa5ea421b3fb2528c6a7650c493f895e7d97750da1.

Solidity: event SetEpochData(address indexed sender, uint256 error, uint256 errorInfo)

func (*EthashFilterer) WatchSetEpochData

func (_Ethash *EthashFilterer) WatchSetEpochData(opts *bind.WatchOpts, sink chan<- *EthashSetEpochData, sender []common.Address) (event.Subscription, error)

WatchSetEpochData is a free log subscription operation binding the contract event 0x5cd723400be8430351b9cbaa5ea421b3fb2528c6a7650c493f895e7d97750da1.

Solidity: event SetEpochData(address indexed sender, uint256 error, uint256 errorInfo)

type EthashMetaData

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

Ethash is a consensus engine based on proot-of-work implementing the ethash algorithm.

func New

func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinmem, dagsondisk int) *EthashMetaData

New creates a full sized ethash PoW scheme.

func NewFakeDelayer

func NewFakeDelayer(delay time.Duration) *EthashMetaData

NewFakeDelayer creates a ethash consensus engine with a fake PoW scheme that accepts all blocks as valid, but delays verifications by some time, though they still have to conform to the Ethereum consensus rules.

func NewFakeFailer

func NewFakeFailer(fail uint64) *EthashMetaData

NewFakeFailer creates a ethash consensus engine with a fake PoW scheme that accepts all blocks as valid apart from the single one specified, though they still have to conform to the Ethereum consensus rules.

func NewFaker

func NewFaker() *EthashMetaData

NewFaker creates a ethash consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Ethereum consensus rules.

func NewFullFaker

func NewFullFaker() *EthashMetaData

NewFullFaker creates a ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.

func NewShared

func NewShared() *EthashMetaData

NewShared creates a full sized ethash PoW shared between all requesters running in the same process.

func NewTester

func NewTester() *EthashMetaData

NewTester creates a small sized ethash PoW scheme useful only for testing purposes.

func (*EthashMetaData) APIs

func (ethash *EthashMetaData) APIs(chain consensus.ChainReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC APIs. Currently that is empty.

func (*EthashMetaData) GetVerificationIndices

func (ethash *EthashMetaData) GetVerificationIndices(blockNumber uint64, hash common.Hash, nonce uint64) []uint32

func (*EthashMetaData) Hashrate

func (ethash *EthashMetaData) Hashrate() float64

Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute.

func (*EthashMetaData) SetThreads

func (ethash *EthashMetaData) SetThreads(threads int)

SetThreads updates the number of mining threads currently enabled. Calling this method does not start mining, only sets the thread count. If zero is specified, the miner will use all cores of the machine. Setting a thread count below zero is allowed and will cause the miner to idle, without any work being done.

func (*EthashMetaData) Threads

func (ethash *EthashMetaData) Threads() int

Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!

type EthashRaw

type EthashRaw struct {
	Contract *Ethash // Generic contract binding to access the raw methods on
}

EthashRaw is an auto generated low-level Go binding around an Ethereum contract.

func (*EthashRaw) Call

func (_Ethash *EthashRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error

Call invokes the (constant) contract method with params as input values and sets the output to result. The result type might be a single field for simple returns, a slice of interfaces for anonymous returns and a struct for named returns.

func (*EthashRaw) Transact

func (_Ethash *EthashRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*EthashRaw) Transfer

func (_Ethash *EthashRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type EthashSession

type EthashSession struct {
	Contract     *Ethash           // Generic contract binding to set the session for
	CallOpts     bind.CallOpts     // Call options to use throughout this session
	TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}

EthashSession is an auto generated Go binding around an Ethereum contract, with pre-set call and transact options.

func (*EthashSession) IsEpochDataSet

func (_Ethash *EthashSession) IsEpochDataSet(epochIndex *big.Int) (bool, error)

IsEpochDataSet is a free data retrieval call binding the contract method 0xc7b81f4f.

Solidity: function isEpochDataSet(uint256 epochIndex) view returns(bool)

func (*EthashSession) SetEpochData

func (_Ethash *EthashSession) SetEpochData(epoch *big.Int, fullSizeIn128Resultion *big.Int, branchDepth *big.Int, merkleNodes []*big.Int, start *big.Int, numElems *big.Int) (*types.Transaction, error)

SetEpochData is a paid mutator transaction binding the contract method 0xc891a29d.

Solidity: function setEpochData(uint256 epoch, uint256 fullSizeIn128Resultion, uint256 branchDepth, uint256[] merkleNodes, uint256 start, uint256 numElems) returns()

func (*EthashSession) VerifyPoW

func (_Ethash *EthashSession) VerifyPoW(blockNumber *big.Int, rlpHeaderHashWithoutNonce [32]byte, nonce *big.Int, difficulty *big.Int, dataSetLookup []*big.Int, witnessForLookup []*big.Int) (*big.Int, *big.Int, error)

VerifyPoW is a free data retrieval call binding the contract method 0x29e265df.

Solidity: function verifyPoW(uint256 blockNumber, bytes32 rlpHeaderHashWithoutNonce, uint256 nonce, uint256 difficulty, uint256[] dataSetLookup, uint256[] witnessForLookup) view returns(uint256, uint256)

type EthashSetEpochData

type EthashSetEpochData struct {
	Sender    common.Address
	Error     *big.Int
	ErrorInfo *big.Int
	Raw       types.Log // Blockchain specific contextual infos
}

EthashSetEpochData represents a SetEpochData event raised by the Ethash contract.

type EthashSetEpochDataIterator

type EthashSetEpochDataIterator struct {
	Event *EthashSetEpochData // Event containing the contract specifics and raw log
	// contains filtered or unexported fields
}

EthashSetEpochDataIterator is returned from FilterSetEpochData and is used to iterate over the raw logs and unpacked data for SetEpochData events raised by the Ethash contract.

func (*EthashSetEpochDataIterator) Close

func (it *EthashSetEpochDataIterator) Close() error

Close terminates the iteration process, releasing any pending underlying resources.

func (*EthashSetEpochDataIterator) Error

func (it *EthashSetEpochDataIterator) Error() error

Error returns any retrieval or parsing error occurred during filtering.

func (*EthashSetEpochDataIterator) Next

func (it *EthashSetEpochDataIterator) Next() bool

Next advances the iterator to the subsequent event, returning whether there are any more events found. In case of a retrieval or parsing error, false is returned and Error() can be queried for the exact failure.

type EthashTransactor

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

EthashTransactor is an auto generated write-only Go binding around an Ethereum contract.

func NewEthashTransactor

func NewEthashTransactor(address common.Address, transactor bind.ContractTransactor) (*EthashTransactor, error)

NewEthashTransactor creates a new write-only instance of Ethash, bound to a specific deployed contract.

func (*EthashTransactor) SetEpochData

func (_Ethash *EthashTransactor) SetEpochData(opts *bind.TransactOpts, epoch *big.Int, fullSizeIn128Resultion *big.Int, branchDepth *big.Int, merkleNodes []*big.Int, start *big.Int, numElems *big.Int) (*types.Transaction, error)

SetEpochData is a paid mutator transaction binding the contract method 0xc891a29d.

Solidity: function setEpochData(uint256 epoch, uint256 fullSizeIn128Resultion, uint256 branchDepth, uint256[] merkleNodes, uint256 start, uint256 numElems) returns()

type EthashTransactorRaw

type EthashTransactorRaw struct {
	Contract *EthashTransactor // Generic write-only contract binding to access the raw methods on
}

EthashTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.

func (*EthashTransactorRaw) Transact

func (_Ethash *EthashTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*EthashTransactorRaw) Transfer

func (_Ethash *EthashTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type EthashTransactorSession

type EthashTransactorSession struct {
	Contract     *EthashTransactor // Generic contract transactor binding to set the session for
	TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}

EthashTransactorSession is an auto generated write-only Go binding around an Ethereum contract, with pre-set transact options.

func (*EthashTransactorSession) SetEpochData

func (_Ethash *EthashTransactorSession) SetEpochData(epoch *big.Int, fullSizeIn128Resultion *big.Int, branchDepth *big.Int, merkleNodes []*big.Int, start *big.Int, numElems *big.Int) (*types.Transaction, error)

SetEpochData is a paid mutator transaction binding the contract method 0xc891a29d.

Solidity: function setEpochData(uint256 epoch, uint256 fullSizeIn128Resultion, uint256 branchDepth, uint256[] merkleNodes, uint256 start, uint256 numElems) returns()

Jump to

Keyboard shortcuts

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