mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
* New struct in consensus/XDPoS/utils/types.go, util functions, and test. (#14) * define vote, timeout, sync info, qc, tc, extra fields in types.go, add test in types_test.go * add json tag in types.go, refine encoder decoder of extra fields * refactor types.go utils.go * re-write types, comments * add Hash SigHash for types, and tests * define Round type * remove unnecessary logs * add v2 engine functions placeholder * typo fix on the consensus v2 function placeholders * add countdown timer * make initilised private to countdown * add v2 specific config struct * rename some config variables * Implement BFT Message receiver (#13) * fix or skip tests due to PR-136 changes * add bft receiver functions * add bft receiver functions * rename tc to TimeoutCert * implement more functions * New struct in consensus/XDPoS/utils/types.go, util functions, and test. (#14) * define vote, timeout, sync info, qc, tc, extra fields in types.go, add test in types_test.go * add json tag in types.go, refine encoder decoder of extra fields * refactor types.go utils.go * re-write types, comments * add Hash SigHash for types, and tests * define Round type * remove unnecessary logs * add temp functions * add v2 engine functions placeholder * typo fix on the consensus v2 function placeholders * add countdown timer * make initilised private to countdown * push verify function * add test on receiving vote * revert type change * add async on broadcast function * add quit initial * fix test Co-authored-by: Jianrong <wjrjerome@gmail.com> Co-authored-by: wgr523 <wgr523@gmail.com> * generate and verify timeout message * Consensus V2 variable, timeout pool (#19) * fill in XDPoS_v2 variables and processQC/TC * add timeout pool, refine engine variables * refactor type functions * solve a small pointer bug * create general pool and its test, refine engine * refine pool, add xdpos v2 config cert threshold * refine config * vote and timeout handlers * fix pool test * bft miner preparation * review comment improvement * update * relocate tests * add and remove comment * fix the syntax error * update network layer and add handler functions (#23) * update network layer and add handler functions * fix test syntax error * add ProcessQC implementation * add ProcessQC tests * add snapshot test * add wait qc process * remove testing files * add route snapshot * fix merge issue * add default v2 behaviour (#24) * add v2 ecrecover functions and refactor test * fix all the tests * put minimun lock variable * debugging prepare and seal v2 blocks * Trigger proposeBlockHandler after v2 block received and verified in fetcher * skip snapshot apply related tests * update test check * rename bfter to bft handler and ignore normal behviour * fix bugs during local 4 node run * fix test * fix sync info test * fix bugs during local 4 node run * rebase and fix bug * remove hook validators function" Co-authored-by: wgr523 <wgr523@gmail.com> Co-authored-by: Jianrong <wjrjerome@gmail.com>
89 lines
3.9 KiB
Go
89 lines
3.9 KiB
Go
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// Various error messages to mark blocks invalid. These should be private to
|
|
// prevent engine specific errors from being referenced in the remainder of the
|
|
// codebase, inherently breaking if the engine is swapped out. Please put common
|
|
// error types into the consensus package.
|
|
var (
|
|
// errUnknownBlock is returned when the list of signers is requested for a block
|
|
// that is not part of the local blockchain.
|
|
ErrUnknownBlock = errors.New("unknown block")
|
|
|
|
// errInvalidCheckpointBeneficiary is returned if a checkpoint/epoch transition
|
|
// block has a beneficiary set to non-zeroes.
|
|
ErrInvalidCheckpointBeneficiary = errors.New("beneficiary in checkpoint block non-zero")
|
|
|
|
// errInvalidVote is returned if a nonce value is something else that the two
|
|
// allowed constants of 0x00..0 or 0xff..f.
|
|
ErrInvalidVote = errors.New("vote nonce not 0x00..0 or 0xff..f")
|
|
|
|
// errInvalidCheckpointVote is returned if a checkpoint/epoch transition block
|
|
// has a vote nonce set to non-zeroes.
|
|
ErrInvalidCheckpointVote = errors.New("vote nonce in checkpoint block non-zero")
|
|
|
|
// errMissingVanity is returned if a block's extra-data section is shorter than
|
|
// 32 bytes, which is required to store the signer vanity.
|
|
ErrMissingVanity = errors.New("extra-data 32 byte vanity prefix missing")
|
|
|
|
// errMissingSignature is returned if a block's extra-data section doesn't seem
|
|
// to contain a 65 byte secp256k1 signature.
|
|
ErrMissingSignature = errors.New("extra-data 65 byte suffix signature missing")
|
|
|
|
// errExtraSigners is returned if non-checkpoint block contain signer data in
|
|
// their extra-data fields.
|
|
ErrExtraSigners = errors.New("non-checkpoint block contains extra signer list")
|
|
|
|
// errInvalidCheckpointSigners is returned if a checkpoint block contains an
|
|
// invalid list of signers (i.e. non divisible by 20 bytes, or not the correct
|
|
// ones).
|
|
ErrInvalidCheckpointSigners = errors.New("invalid signer list on checkpoint block")
|
|
|
|
ErrInvalidCheckpointPenalties = errors.New("invalid penalty list on checkpoint block")
|
|
|
|
// errInvalidMixDigest is returned if a block's mix digest is non-zero.
|
|
ErrInvalidMixDigest = errors.New("non-zero mix digest")
|
|
|
|
// errInvalidUncleHash is returned if a block contains an non-empty uncle list.
|
|
ErrInvalidUncleHash = errors.New("non empty uncle hash")
|
|
|
|
// errInvalidDifficulty is returned if the difficulty of a block is not either
|
|
// of 1 or 2, or if the value does not match the turn of the signer.
|
|
ErrInvalidDifficulty = errors.New("invalid difficulty")
|
|
|
|
// ErrInvalidTimestamp is returned if the timestamp of a block is lower than
|
|
// the previous block's timestamp + the minimum block period.
|
|
ErrInvalidTimestamp = errors.New("invalid timestamp")
|
|
|
|
// errInvalidVotingChain is returned if an authorization list is attempted to
|
|
// be modified via out-of-range or non-contiguous headers.
|
|
ErrInvalidVotingChain = errors.New("invalid voting chain")
|
|
|
|
ErrInvalidHeaderOrder = errors.New("invalid header order")
|
|
ErrInvalidChild = errors.New("invalid header child")
|
|
|
|
// errUnauthorized is returned if a header is signed by a non-authorized entity.
|
|
ErrUnauthorized = errors.New("unauthorized")
|
|
|
|
ErrFailedDoubleValidation = errors.New("wrong pair of creator-validator in double validation")
|
|
|
|
// errWaitTransactions is returned if an empty block is attempted to be sealed
|
|
// on an instant chain (0 second period). It's important to refuse these as the
|
|
// block reward is zero, so an empty block just bloats the chain... fast.
|
|
ErrWaitTransactions = errors.New("waiting for transactions")
|
|
|
|
ErrInvalidCheckpointValidators = errors.New("invalid validators list on checkpoint block")
|
|
)
|
|
|
|
type ErrIncomingMessageRoundNotEqualCurrentRound struct {
|
|
IncomingRound Round
|
|
CurrentRound Round
|
|
}
|
|
|
|
func (e *ErrIncomingMessageRoundNotEqualCurrentRound) Error() string {
|
|
return fmt.Sprintf("Timeout message round number: %v does not match currentRound: %v", e.IncomingRound, e.CurrentRound)
|
|
}
|