mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +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
@@ -15,15 +15,18 @@
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::{ancestry, Storage};
|
||||
use crate::Storage;
|
||||
use primitives::{public_to_address, Address, Header, SealedEmptyStep, H256};
|
||||
use sp_io::crypto::secp256k1_ecdsa_recover;
|
||||
use sp_std::collections::{
|
||||
btree_map::{BTreeMap, Entry},
|
||||
btree_set::BTreeSet,
|
||||
vec_deque::VecDeque,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{
|
||||
collections::{
|
||||
btree_map::{BTreeMap, Entry},
|
||||
btree_set::BTreeSet,
|
||||
vec_deque::VecDeque,
|
||||
},
|
||||
iter::from_fn,
|
||||
};
|
||||
|
||||
/// Tries to finalize blocks when given block is imported.
|
||||
///
|
||||
@@ -190,6 +193,24 @@ fn empty_step_signer(empty_step: &SealedEmptyStep, parent_hash: &H256) -> Option
|
||||
.map(|public| public_to_address(&public))
|
||||
}
|
||||
|
||||
/// Return iterator of given header ancestors.
|
||||
pub(crate) fn ancestry<'a, S: Storage>(
|
||||
storage: &'a S,
|
||||
header: &Header,
|
||||
) -> impl Iterator<Item = (H256, Header, Option<S::Submitter>)> + 'a {
|
||||
let mut parent_hash = header.parent_hash.clone();
|
||||
from_fn(move || {
|
||||
let (header, submitter) = storage.header(&parent_hash)?;
|
||||
if header.number == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let hash = parent_hash.clone();
|
||||
parent_hash = header.parent_hash.clone();
|
||||
Some((hash, header, submitter))
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user