This repository was archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
[COMP-1277] Replace miner env var with 'current validator' gateway address #396
Open
jflatow
wants to merge
1
commit into
develop
Choose a base branch
from
jflatow/pin-miner
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| use crate::{chains::ChainAccount, Call, Config, Miner, Module}; | ||
| use crate::{chains::ChainAccount, core, Call, Config, Miner, Module}; | ||
| use codec::{Decode, Encode}; | ||
| use frame_support::{inherent::ProvideInherent, storage::StorageValue}; | ||
| use sp_inherents::{InherentData, InherentIdentifier, IsFatalError}; | ||
|
|
@@ -39,10 +39,13 @@ impl InherentError { | |
|
|
||
| /// Provide chosen miner address. | ||
| #[cfg(feature = "std")] | ||
| pub struct InherentDataProvider; | ||
| // XXX how do we even get a T here? | ||
| pub struct InherentDataProvider<T: Config> { | ||
| sentinel: std::marker::PhantomData<T>, | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] | ||
| impl std::ops::Deref for InherentDataProvider { | ||
| impl<T: Config> std::ops::Deref for InherentDataProvider<T> { | ||
| type Target = (); | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
|
|
@@ -52,24 +55,16 @@ impl std::ops::Deref for InherentDataProvider { | |
|
|
||
| #[cfg(feature = "std")] | ||
| #[async_trait::async_trait] | ||
| impl sp_inherents::InherentDataProvider for InherentDataProvider { | ||
| impl<T: Config + std::marker::Sync + std::marker::Send> sp_inherents::InherentDataProvider | ||
| for InherentDataProvider<T> | ||
| { | ||
| fn provide_inherent_data( | ||
| &self, | ||
| inherent_data: &mut InherentData, | ||
| ) -> Result<(), sp_inherents::Error> { | ||
| let miner_address_str = runtime_interfaces::validator_config_interface::get_miner_address() | ||
| .ok_or(sp_inherents::Error::Application(Box::from( | ||
| "no miner address", | ||
| )))?; | ||
|
|
||
| let miner_address = our_std::str::from_utf8(&miner_address_str).map_err(|_| { | ||
| sp_inherents::Error::Application(Box::from("invalid miner address bytes")) | ||
| })?; | ||
|
|
||
| let chain_account: ChainAccount = our_std::str::FromStr::from_str(miner_address) | ||
| .map_err(|_| sp_inherents::Error::Application(Box::from("invalid miner address")))?; | ||
|
|
||
| inherent_data.put_data(INHERENT_IDENTIFIER, &chain_account) | ||
| let validator = core::get_current_validator::<T>() | ||
|
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. this is a function accessing runtime storage I assume? |
||
| .map_err(|_| sp_inherents::Error::Application(Box::from("no miner address")))?; | ||
| inherent_data.put_data(INHERENT_IDENTIFIER, &validator.miner_address()) | ||
| } | ||
|
|
||
| async fn try_handle_error( | ||
|
|
||
This file contains hidden or 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
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 principal you can depend on the
gateway-runtime::Runtimestruct and pass it to the generic here, that binds your node impl to a particular (set of) runtime version(s) though