mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
Sync ethereum headers using unsigned (substrate) transactions (#45)
* reward submitters on finalization * PoA -> Substrate: unsigned_import_header API * fix grumble * make submitter part of ImportContext * verify using next validators set + tests * fix nostd compilation * add sub-tx-mode argument * support sub-tx-mode * impl ValidateUnsigned for Runtime * do not submit too much transactions to the pool * cargo fmt * fix bad merge * revert license fix * Update modules/ethereum/src/lib.rs Co-Authored-By: Hernando Castano <HCastano@users.noreply.github.com> * Update modules/ethereum/src/verification.rs Co-Authored-By: Hernando Castano <HCastano@users.noreply.github.com> * updated comment * validate receipts before accepting unsigned tx to pool * cargo fmt * fix comment * fix grumbles * Update modules/ethereum/src/verification.rs Co-Authored-By: Hernando Castano <HCastano@users.noreply.github.com> * cargo fmt --all * struct ChangeToEnact * updated doc * fix doc * add docs to the code method * simplify fn ancestry * finish incomplete docs * Update modules/ethereum/src/lib.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update modules/ethereum/src/lib.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * return err from unsigned_import_header * get header once * Update relays/ethereum/src/ethereum_sync.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * fix * UnsignedTooFarInTheFuture -> Custom(err.code()) * updated ImportContext::last_signal_block * cargo fmt --all * rename runtime calls Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
b055027161
commit
c6c46462ab
@@ -17,45 +17,49 @@
|
||||
use sp_runtime::RuntimeDebug;
|
||||
|
||||
/// Header import error.
|
||||
#[derive(RuntimeDebug)]
|
||||
#[derive(Clone, Copy, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(PartialEq))]
|
||||
pub enum Error {
|
||||
/// The header is beyound last finalized and can not be imported.
|
||||
AncientHeader,
|
||||
/// The header is beyond last finalized and can not be imported.
|
||||
AncientHeader = 0,
|
||||
/// The header is already imported.
|
||||
KnownHeader,
|
||||
KnownHeader = 1,
|
||||
/// Seal has an incorrect format.
|
||||
InvalidSealArity,
|
||||
InvalidSealArity = 2,
|
||||
/// Block number isn't sensible.
|
||||
RidiculousNumber,
|
||||
RidiculousNumber = 3,
|
||||
/// Block has too much gas used.
|
||||
TooMuchGasUsed,
|
||||
TooMuchGasUsed = 4,
|
||||
/// Gas limit header field is invalid.
|
||||
InvalidGasLimit,
|
||||
InvalidGasLimit = 5,
|
||||
/// Extra data is of an invalid length.
|
||||
ExtraDataOutOfBounds,
|
||||
ExtraDataOutOfBounds = 6,
|
||||
/// Timestamp header overflowed.
|
||||
TimestampOverflow,
|
||||
TimestampOverflow = 7,
|
||||
/// The parent header is missing from the blockchain.
|
||||
MissingParentBlock,
|
||||
MissingParentBlock = 8,
|
||||
/// The header step is missing from the header.
|
||||
MissingStep,
|
||||
MissingStep = 9,
|
||||
/// The header signature is missing from the header.
|
||||
MissingSignature,
|
||||
MissingSignature = 10,
|
||||
/// Empty steps are missing from the header.
|
||||
MissingEmptySteps,
|
||||
MissingEmptySteps = 11,
|
||||
/// The same author issued different votes at the same step.
|
||||
DoubleVote,
|
||||
DoubleVote = 12,
|
||||
/// Validation proof insufficient.
|
||||
InsufficientProof,
|
||||
InsufficientProof = 13,
|
||||
/// Difficulty header field is invalid.
|
||||
InvalidDifficulty,
|
||||
InvalidDifficulty = 14,
|
||||
/// The received block is from an incorrect proposer.
|
||||
NotValidator,
|
||||
NotValidator = 15,
|
||||
/// Missing transaction receipts for the operation.
|
||||
MissingTransactionsReceipts,
|
||||
MissingTransactionsReceipts = 16,
|
||||
/// Redundant transaction receipts are provided.
|
||||
RedundantTransactionsReceipts = 17,
|
||||
/// Provided transactions receipts are not matching the header.
|
||||
TransactionsReceiptsMismatch,
|
||||
TransactionsReceiptsMismatch = 18,
|
||||
/// Can't accept unsigned header from the far future.
|
||||
UnsignedTooFarInTheFuture = 19,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@@ -78,7 +82,14 @@ impl Error {
|
||||
Error::InvalidDifficulty => "Header has invalid difficulty",
|
||||
Error::NotValidator => "Header is sealed by unexpected validator",
|
||||
Error::MissingTransactionsReceipts => "The import operation requires transactions receipts",
|
||||
Error::RedundantTransactionsReceipts => "Redundant transactions receipts are provided",
|
||||
Error::TransactionsReceiptsMismatch => "Invalid transactions receipts provided",
|
||||
Error::UnsignedTooFarInTheFuture => "The unsigned header is too far in future",
|
||||
}
|
||||
}
|
||||
|
||||
/// Return unique error code.
|
||||
pub fn code(&self) -> u8 {
|
||||
*self as u8
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user