Documentation ¶
Index ¶
- Constants
- Variables
- func SeedHash(block uint64) []byte
- func TrimBlock(chain consensus.ChainHeaderReader, batch ethdb.Batch, denomination uint8, ...) [][]byte
- func UpdateTrimDepths(trimDepths map[uint8]uint64, utxoSetSize uint64) bool
- type Config
- type Mode
- type Progpow
- func New(config Config, notify []string, noverify bool, logger *log.Logger) *Progpow
- func NewFakeDelayer(delay time.Duration) *Progpow
- func NewFakeFailer(fail uint64) *Progpow
- func NewFaker() *Progpow
- func NewFullFaker() *Progpow
- func NewShared() *Progpow
- func NewTester(notify []string, noverify bool) *Progpow
- func (progpow *Progpow) Author(header *types.WorkObject) (common.Address, error)
- func (progpow *Progpow) CalcDifficulty(chain consensus.ChainHeaderReader, parent *types.WorkObjectHeader, ...) *big.Int
- func (progpow *Progpow) CalcOrder(chain consensus.BlockReader, header *types.WorkObject) (*big.Int, int, error)
- func (progpow *Progpow) CalcRank(chain consensus.ChainHeaderReader, header *types.WorkObject) (int, error)
- func (progpow *Progpow) CheckIfValidWorkShare(workShare *types.WorkObjectHeader) types.WorkShareValidity
- func (progpow *Progpow) CheckWorkThreshold(workShare *types.WorkObjectHeader, workShareThresholdDiff int) bool
- func (progpow *Progpow) ComputePowHash(header *types.WorkObjectHeader) (common.Hash, error)
- func (progpow *Progpow) ComputePowLight(header *types.WorkObjectHeader) (mixHash, powHash common.Hash)
- func (progpow *Progpow) DeltaLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
- func (progpow *Progpow) Finalize(chain consensus.ChainHeaderReader, batch ethdb.Batch, header *types.WorkObject, ...) (*multiset.MultiSet, uint64, error)
- func (progpow *Progpow) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.WorkObject, ...) (*types.WorkObject, error)
- func (progpow *Progpow) IntrinsicLogEntropy(powHash common.Hash) *big.Int
- func (progpow *Progpow) IsDomCoincident(chain consensus.ChainHeaderReader, header *types.WorkObject) bool
- func (progpow *Progpow) Mine(workObject *types.WorkObject, abort <-chan struct{}, ...)
- func (progpow *Progpow) MineToThreshold(workObject *types.WorkObject, workShareThreshold int, abort <-chan struct{}, ...)
- func (progpow *Progpow) NodeLocation() common.Location
- func (progpow *Progpow) Prepare(chain consensus.ChainHeaderReader, header *types.WorkObject, ...) error
- func (progpow *Progpow) Seal(header *types.WorkObject, results chan<- *types.WorkObject, ...) error
- func (progpow *Progpow) SetThreads(threads int)
- func (progpow *Progpow) Threads() int
- func (progpow *Progpow) TotalLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
- func (progpow *Progpow) UncledDeltaLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
- func (progpow *Progpow) UncledLogEntropy(block *types.WorkObject) *big.Int
- func (progpow *Progpow) VerifyHeader(chain consensus.ChainHeaderReader, header *types.WorkObject) error
- func (progpow *Progpow) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.WorkObject) (chan<- struct{}, <-chan error)
- func (progpow *Progpow) VerifySeal(header *types.WorkObjectHeader) (common.Hash, error)
- func (progpow *Progpow) VerifyUncles(chain consensus.ChainReader, block *types.WorkObject) error
- func (progpow *Progpow) WorkShareLogEntropy(chain consensus.ChainHeaderReader, wo *types.WorkObject) (*big.Int, error)
Constants ¶
const (
C_epochLength = math.MaxUint64 // Blocks per epoch
)
Variables ¶
var ( ContextTimeFactor = big10 ZoneBlockReward = big.NewInt(5e+18) RegionBlockReward = new(big.Int).Mul(ZoneBlockReward, big3) PrimeBlockReward = new(big.Int).Mul(RegionBlockReward, big3) )
Progpow proof-of-work protocol constants.
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
Functions ¶
func SeedHash ¶
SeedHash is the seed to use for generating a verification cache and the mining dataset.
func TrimBlock ¶ added in v0.35.0
func TrimBlock(chain consensus.ChainHeaderReader, batch ethdb.Batch, denomination uint8, checkDenom bool, blockHeight uint64, blockHash common.Hash, utxosDelete *[]common.Hash, trimmedUtxos *[]*types.SpentUtxoEntry, collidingKeys [][]byte, utxoSetSize *uint64, deleteFromDb bool, lock *sync.Mutex, logger *log.Logger) [][]byte
TrimBlock trims all UTXOs of a given denomination that were created in a given block. In the event of an attacker intentionally creating too many 9-byte keys that collide, we return the colliding keys to be trimmed in the next block.
Types ¶
type Config ¶
type Config struct { PowMode Mode CacheDir string CachesInMem int CachesOnDisk int CachesLockMmap bool DurationLimit *big.Int GasCeil uint64 MinDifficulty *big.Int NodeLocation common.Location // When set, notifications sent by the remote sealer will // be block header JSON objects instead of work package arrays. NotifyFull bool Log *log.Logger `toml:"-"` // Number of threads to mine on if mining NumThreads int }
Config are the configuration parameters of the progpow.
type Mode ¶
type Mode uint
Mode defines the type and amount of PoW verification a progpow engine makes.
type Progpow ¶
type Progpow struct {
// contains filtered or unexported fields
}
Progpow is a proof-of-work consensus engine using the blake3 hash algorithm
func New ¶
New creates a full sized progpow PoW scheme and starts a background thread for remote mining, also optionally notifying a batch of remote services of new work packages.
func NewFakeDelayer ¶
NewFakeDelayer creates a progpow 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 Quai consensus rules.
func NewFakeFailer ¶
NewFakeFailer creates a progpow 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 Quai consensus rules.
func NewFaker ¶
func NewFaker() *Progpow
NewFaker creates a progpow consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Quai consensus rules.
func NewFullFaker ¶
func NewFullFaker() *Progpow
NewFullFaker creates an progpow consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewShared ¶
func NewShared() *Progpow
NewShared creates a full sized progpow PoW shared between all requesters running in the same process.
func NewTester ¶
NewTester creates a small sized progpow PoW scheme useful only for testing purposes.
func (*Progpow) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Progpow) CalcDifficulty ¶
func (progpow *Progpow) CalcDifficulty(chain consensus.ChainHeaderReader, parent *types.WorkObjectHeader, expansionNum uint8) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.
func (*Progpow) CalcOrder ¶
func (progpow *Progpow) CalcOrder(chain consensus.BlockReader, header *types.WorkObject) (*big.Int, int, error)
CalcOrder returns the order of the block within the hierarchy of chains
func (*Progpow) CalcRank ¶ added in v0.29.0
func (progpow *Progpow) CalcRank(chain consensus.ChainHeaderReader, header *types.WorkObject) (int, error)
CalcRank returns the rank of the block within the hierarchy of chains, this determines the level of the interlink
func (*Progpow) CheckIfValidWorkShare ¶ added in v0.29.0
func (progpow *Progpow) CheckIfValidWorkShare(workShare *types.WorkObjectHeader) types.WorkShareValidity
func (*Progpow) CheckWorkThreshold ¶ added in v0.32.0
func (progpow *Progpow) CheckWorkThreshold(workShare *types.WorkObjectHeader, workShareThresholdDiff int) bool
func (*Progpow) ComputePowHash ¶ added in v0.29.0
func (*Progpow) ComputePowLight ¶
func (progpow *Progpow) ComputePowLight(header *types.WorkObjectHeader) (mixHash, powHash common.Hash)
func (*Progpow) DeltaLogEntropy ¶ added in v0.33.0
func (progpow *Progpow) DeltaLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
func (*Progpow) Finalize ¶
func (progpow *Progpow) Finalize(chain consensus.ChainHeaderReader, batch ethdb.Batch, header *types.WorkObject, state *state.StateDB, setRoots bool, utxoSetSize uint64, utxosCreate, utxosDelete []common.Hash) (*multiset.MultiSet, uint64, error)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state on the header Finalize returns the new MuHash of the UTXO set, the new size of the UTXO set and an error if any
func (*Progpow) FinalizeAndAssemble ¶
func (progpow *Progpow) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.WorkObject, state *state.StateDB, txs []*types.Transaction, uncles []*types.WorkObjectHeader, etxs []*types.Transaction, subManifest types.BlockManifest, receipts []*types.Receipt, parentUtxoSetSize uint64, utxosCreate, utxosDelete []common.Hash) (*types.WorkObject, error)
FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Progpow) IntrinsicLogEntropy ¶ added in v0.33.0
IntrinsicLogEntropy returns the logarithm of the intrinsic entropy reduction of a PoW hash
func (*Progpow) IsDomCoincident ¶
func (progpow *Progpow) IsDomCoincident(chain consensus.ChainHeaderReader, header *types.WorkObject) bool
func (*Progpow) Mine ¶ added in v0.32.0
func (progpow *Progpow) Mine(workObject *types.WorkObject, abort <-chan struct{}, found chan *types.WorkObject)
func (*Progpow) MineToThreshold ¶ added in v0.32.0
func (progpow *Progpow) MineToThreshold(workObject *types.WorkObject, workShareThreshold int, abort <-chan struct{}, found chan *types.WorkObject)
func (*Progpow) NodeLocation ¶ added in v0.29.0
func (*Progpow) Prepare ¶
func (progpow *Progpow) Prepare(chain consensus.ChainHeaderReader, header *types.WorkObject, parent *types.WorkObject) error
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the progpow protocol. The changes are done inline.
func (*Progpow) Seal ¶
func (progpow *Progpow) Seal(header *types.WorkObject, results chan<- *types.WorkObject, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to find a nonce that satisfies the header's difficulty requirements.
func (*Progpow) SetThreads ¶
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 (*Progpow) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Progpow) TotalLogEntropy ¶ added in v0.33.0
func (progpow *Progpow) TotalLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
TotalLogEntropy returns the total entropy reduction if the chain since genesis to the given header
func (*Progpow) UncledDeltaLogEntropy ¶ added in v0.33.0
func (progpow *Progpow) UncledDeltaLogEntropy(chain consensus.ChainHeaderReader, header *types.WorkObject) *big.Int
func (*Progpow) UncledLogEntropy ¶ added in v0.33.0
func (progpow *Progpow) UncledLogEntropy(block *types.WorkObject) *big.Int
func (*Progpow) VerifyHeader ¶
func (progpow *Progpow) VerifyHeader(chain consensus.ChainHeaderReader, header *types.WorkObject) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Quai progpow engine.
func (*Progpow) VerifyHeaders ¶
func (progpow *Progpow) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.WorkObject) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.
func (*Progpow) VerifySeal ¶ added in v0.20.0
VerifySeal returns the PowHash and the verifySeal output
func (*Progpow) VerifyUncles ¶
func (progpow *Progpow) VerifyUncles(chain consensus.ChainReader, block *types.WorkObject) error
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Quai progpow engine.
func (*Progpow) WorkShareLogEntropy ¶ added in v0.33.0
func (progpow *Progpow) WorkShareLogEntropy(chain consensus.ChainHeaderReader, wo *types.WorkObject) (*big.Int, error)