-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container candidates in dev service #747
Open
girazoki
wants to merge
14
commits into
master
Choose a base branch
from
girazoki-dev-service-comp
base: master
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.
+609
−50
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e76d50b
wip
girazoki 9b39ff1
wip
girazoki cae06bc
add flume for messages
girazoki d46adf8
wip
girazoki 72d8875
wip
girazoki f17e131
Merge remote-tracking branch 'origin/master' into girazoki-dev-servic…
girazoki 3c32ffc
test related to validator rewards
girazoki 673aeae
toml·
girazoki 0de39fc
clippy
girazoki debc746
linting
girazoki aefd1c6
more lint
girazoki 7a77f45
start cleaning
girazoki 5d4929d
work
girazoki eb45d5f
Merge branch 'master' into girazoki-dev-service-comp
girazoki 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (C) Moondance Labs Ltd. | ||
// This file is part of Tanssi. | ||
|
||
// Tanssi is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Tanssi is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Tanssi. If not, see <http://www.gnu.org/licenses/> | ||
|
||
//! Development Polkadot service. Adapted from `polkadot_service` crate | ||
//! and removed un-necessary components which are not required in dev node. | ||
|
||
use codec::Encode; | ||
use jsonrpsee::{ | ||
core::RpcResult, | ||
proc_macros::rpc, | ||
types::{ | ||
error::{INTERNAL_ERROR_CODE, INTERNAL_ERROR_MSG}, | ||
ErrorObjectOwned, | ||
}, | ||
}; | ||
|
||
/// This RPC interface is used to provide methods in dev mode only | ||
#[rpc(server)] | ||
#[jsonrpsee::core::async_trait] | ||
pub trait DevApi { | ||
/// Indicate the mock parachain candidate insertion to be active | ||
#[method(name = "mock_enableParaInherentCandidate")] | ||
async fn enable_para_inherent_candidate(&self) -> RpcResult<()>; | ||
|
||
/// Indicate the mock parachain candidate insertion to be disabled | ||
#[method(name = "mock_disableParaInherentCandidate")] | ||
async fn disable_para_inherent_candidate(&self) -> RpcResult<()>; | ||
} | ||
|
||
pub struct DevRpc { | ||
pub mock_para_inherent_channel: flume::Sender<Vec<u8>>, | ||
} | ||
|
||
#[jsonrpsee::core::async_trait] | ||
impl DevApiServer for DevRpc { | ||
async fn enable_para_inherent_candidate(&self) -> RpcResult<()> { | ||
log::info!("entering here"); | ||
let mock_para_inherent_channel = self.mock_para_inherent_channel.clone(); | ||
// Push the message to the shared channel where it will be queued up | ||
// to be injected in to an upcoming block. | ||
mock_para_inherent_channel | ||
.send_async(true.encode()) | ||
.await | ||
.map_err(|err| internal_err(err.to_string()))?; | ||
|
||
log::info!("SENEDING ENABLE"); | ||
Ok(()) | ||
} | ||
|
||
async fn disable_para_inherent_candidate(&self) -> RpcResult<()> { | ||
let mock_para_inherent_channel = self.mock_para_inherent_channel.clone(); | ||
// Push the message to the shared channel where it will be queued up | ||
// to be injected in to an upcoming block. | ||
mock_para_inherent_channel | ||
.send_async(false.encode()) | ||
.await | ||
.map_err(|err| internal_err(err.to_string()))?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
// This bit cribbed from frontier. | ||
pub fn internal_err<T: ToString>(message: T) -> ErrorObjectOwned { | ||
ErrorObjectOwned::owned( | ||
INTERNAL_ERROR_CODE, | ||
INTERNAL_ERROR_MSG, | ||
Some(message.to_string()), | ||
) | ||
} |
Oops, something went wrong.
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.
I don't understand why does this need to be a channel, I would simply use an
AtomicBool
, or if you need to clone itArc<AtomicBool>
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.
The intention of this channel is to not write to the storage item every block, but rather only when the user requests it through the rpc. hence the channel