mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
ed25519_verify: Support using dalek for historical blocks (#12661)
* ed25519_verify: Support using dalek for historical blocks The switch from `ed25519-dalek` to `ed25519-zebra` was actually a breaking change. `ed25519-zebra` is more permissive. To support historical blocks when syncing a chain this pull request introduces an externalities extension `UseDalekExt`. This extension is just used as a signaling mechanism to `ed25519_verify` to use `ed25519-dalek` when it is present. Together with `ExtensionBeforeBlock` it can be used to setup a node in way to sync historical blocks that require `ed25519-dalek`, because they included a transaction that verified differently as when using `ed25519-zebra`. This feature can be enabled in the following way. In the chain service file, directly after the client is created, the following code should be added: ``` use sc_client_api::ExecutorProvider; client.execution_extensions().set_extensions_factory( sc_client_api::execution_extensions::ExtensionBeforeBlock::<Block, sp_io::UseDalekExt>::new(BLOCK_NUMBER_UNTIL_DALEK_SHOULD_BE_USED) ); ``` * Fix doc * More fixes * Update client/api/src/execution_extensions.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Fix merge and warning * Fix docs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -89,6 +89,19 @@ macro_rules! decl_extension {
|
||||
Self(inner)
|
||||
}
|
||||
}
|
||||
};
|
||||
(
|
||||
$( #[ $attr:meta ] )*
|
||||
$vis:vis struct $ext_name:ident;
|
||||
) => {
|
||||
$( #[ $attr ] )*
|
||||
$vis struct $ext_name;
|
||||
|
||||
impl $crate::Extension for $ext_name {
|
||||
fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +125,7 @@ pub trait ExtensionStore {
|
||||
extension: Box<dyn Extension>,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
/// Deregister extension with speicifed 'type_id' and drop it.
|
||||
/// Deregister extension with specified 'type_id' and drop it.
|
||||
///
|
||||
/// It should return error if extension is not registered.
|
||||
fn deregister_extension_by_type_id(&mut self, type_id: TypeId) -> Result<(), Error>;
|
||||
@@ -179,6 +192,13 @@ impl Extensions {
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<Extensions> for Extensions {
|
||||
fn extend<T: IntoIterator<Item = Extensions>>(&mut self, iter: T) {
|
||||
iter.into_iter()
|
||||
.for_each(|ext| self.extensions.extend(ext.extensions.into_iter()));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user