This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Introduce code_substitute
#8898
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,7 @@ pub struct Client<B, E, Block, RA> where Block: BlockT { | |
importing_block: RwLock<Option<Block::Hash>>, | ||
block_rules: BlockRules<Block>, | ||
execution_extensions: ExecutionExtensions<Block>, | ||
config: ClientConfig, | ||
config: ClientConfig<Block>, | ||
telemetry: Option<TelemetryHandle>, | ||
_phantom: PhantomData<RA>, | ||
} | ||
|
@@ -159,10 +159,10 @@ pub fn new_in_mem<E, Block, S, RA>( | |
prometheus_registry: Option<Registry>, | ||
telemetry: Option<TelemetryHandle>, | ||
spawn_handle: Box<dyn SpawnNamed>, | ||
config: ClientConfig, | ||
config: ClientConfig<Block>, | ||
) -> sp_blockchain::Result<Client< | ||
in_mem::Backend<Block>, | ||
LocalCallExecutor<in_mem::Backend<Block>, E>, | ||
LocalCallExecutor<Block, in_mem::Backend<Block>, E>, | ||
Block, | ||
RA | ||
>> where | ||
|
@@ -183,14 +183,28 @@ pub fn new_in_mem<E, Block, S, RA>( | |
} | ||
|
||
/// Relevant client configuration items relevant for the client. | ||
#[derive(Debug,Clone,Default)] | ||
pub struct ClientConfig { | ||
#[derive(Debug, Clone)] | ||
pub struct ClientConfig<Block: BlockT> { | ||
/// Enable the offchain worker db. | ||
pub offchain_worker_enabled: bool, | ||
/// If true, allows access from the runtime to write into offchain worker db. | ||
pub offchain_indexing_api: bool, | ||
/// Path where WASM files exist to override the on-chain WASM. | ||
pub wasm_runtime_overrides: Option<PathBuf>, | ||
/// Map of WASM runtime substitute starting at the child of the given block until the runtime | ||
/// version doesn't match anymore. | ||
Comment on lines
+194
to
+195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be good to point out that the |
||
pub wasm_runtime_substitutes: HashMap<Block::Hash, Vec<u8>>, | ||
} | ||
|
||
impl<Block: BlockT> Default for ClientConfig<Block> { | ||
fn default() -> Self { | ||
Self { | ||
offchain_worker_enabled: false, | ||
offchain_indexing_api: false, | ||
wasm_runtime_overrides: None, | ||
wasm_runtime_substitutes: HashMap::new(), | ||
} | ||
} | ||
} | ||
|
||
/// Create a client with the explicitly provided backend. | ||
|
@@ -204,8 +218,8 @@ pub fn new_with_backend<B, E, Block, S, RA>( | |
spawn_handle: Box<dyn SpawnNamed>, | ||
prometheus_registry: Option<Registry>, | ||
telemetry: Option<TelemetryHandle>, | ||
config: ClientConfig, | ||
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<B, E>, Block, RA>> | ||
config: ClientConfig<Block>, | ||
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<Block, B, E>, Block, RA>> | ||
where | ||
E: CodeExecutor + RuntimeInfo, | ||
S: BuildStorage, | ||
|
@@ -308,7 +322,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where | |
execution_extensions: ExecutionExtensions<Block>, | ||
prometheus_registry: Option<Registry>, | ||
telemetry: Option<TelemetryHandle>, | ||
config: ClientConfig, | ||
config: ClientConfig<Block>, | ||
) -> sp_blockchain::Result<Self> { | ||
if backend.blockchain().header(BlockId::Number(Zero::zero()))?.is_none() { | ||
let genesis_storage = build_genesis_storage.build_storage() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future pr I would like to replace
String
with something that directly checks that we got here some hex value.