Conversation
| } | ||
|
|
||
| impl<Block: BlockT, Status: BlockStatus<Block>, I> Stream for UntilImported<Block, Status, I> | ||
| where I: Stream<Item=SignedMessage<Block>,Error=Error> |
There was a problem hiding this comment.
(nitpick) would space after comma be appropriate?
There was a problem hiding this comment.
i don't think so, it's not typical for these kinds of bounds
| // the output stream checks signatures also. | ||
| fn checked_message_stream<Block: BlockT, S>(inner: S, voters: Vec<AuthorityId>) | ||
| -> impl Stream<Item=SignedMessage<Block>,Error=Error> where | ||
| S: Stream<Item=Vec<u8>,Error=()> |
There was a problem hiding this comment.
(nitpick) space after comma on 300 and 301?
| network: N, | ||
| ) -> ( | ||
| impl Stream<Item=SignedMessage<Block>,Error=Error>, | ||
| impl Sink<SinkItem=Message<Block>,SinkError=Error>, |
There was a problem hiding this comment.
(nitpick) space after comma on 337 and 338?
| client: Arc<Client<B, E, Block>>, | ||
| voters: HashMap<AuthorityId, usize>, | ||
| network: N, | ||
| ) -> Result<impl Future<Item=(),Error=()>,client::error::Error> where |
There was a problem hiding this comment.
(nitpick) spaces after commas
| } | ||
|
|
||
| impl Network for TestGrandpaNetwork { | ||
| type In = Box<Stream<Item=Vec<u8>,Error=()>>; |
There was a problem hiding this comment.
(nitpick) space after comma
| pub fn collect_garbage(&mut self, best_hash: Option<&B::Hash>) { | ||
| /// Prune old or no longer relevant consensus messages. Provide a predicate | ||
| /// for pruning, which returns `true` when the items with a given topic should be pruned. | ||
| pub fn collect_garbage<P: Fn(&B::Hash) -> bool>(&mut self, predicate: P) { |
core/finality-grandpa/src/lib.rs
Outdated
| N::In: 'static, | ||
| NumberFor<Block>: As<u32>, | ||
| { | ||
| type Timer = Box<Future<Item = (), Error = Self::Error>>; |
core/finality-grandpa/src/lib.rs
Outdated
|
|
||
| voter::RoundData { | ||
| prevote_timer: Box::new(prevote_timer.map_err(Error::Timer)), | ||
| precommit_timer: Box::new(precommit_timer.map_err(Error::Timer)), |
gnunicorn
left a comment
There was a problem hiding this comment.
Minor nitpicks and an interface naming question. Aside from that, LGTM.
core/finality-grandpa/src/lib.rs
Outdated
| @@ -0,0 +1,767 @@ | |||
| // Copyright 2017 Parity Technologies (UK) Ltd. | |||
| } | ||
|
|
||
| /// Run a GRANDPA voter as a task. The returned future should be executed in a tokio runtime. | ||
| pub fn run_voter<B, E, Block: BlockT, N>( |
There was a problem hiding this comment.
Isn't this the Voter we can/should run in order to just observe the GRANDPA-Process taking place without actually voting ourselves? I understand in that case I'd just provide a dummy Network, which isn't actually sending messages, but giving us information about potential misbehavior we could flag, but I feel like the function name and docs might already want to anticipate that, don't you think? Something more generic like run_grandpa instead (and maybe add a TODO to the docs to add example usage of both cases?). What do you think?
There was a problem hiding this comment.
this is a voter that can send messages and cast votes. it can be a non-active voter. changing it to run_grandpa is uncontroversial to me
| /// Return `Ok(Some(number))` or `Ok(None)` depending on whether the block | ||
| /// is definitely known and has been imported. | ||
| /// If an unexpected error occurs, return that. | ||
| fn block_number(&self, hash: Block::Hash) -> Result<Option<u32>, Error>; |
There was a problem hiding this comment.
the grandpa crate isn't generic over number and just uses u32
There was a problem hiding this comment.
can we file an issue for that?
| inner: Fuse<I>, | ||
| ready: VecDeque<SignedMessage<Block>>, | ||
| check_pending: Interval, | ||
| pending: HashMap<Block::Hash, Vec<SignedMessage<Block>>>, |
There was a problem hiding this comment.
Can this be attacked to grow indefinitely?
There was a problem hiding this comment.
potentially yes. i'm not sure what the mitigation strategy is there, other than to move the deferment of processing into the grandpa crate (i.e. catch equivocations before waiting for blocks to arrive)
There was a problem hiding this comment.
i'll file that as an issue
| if let Err(e) = self.inner.backend() | ||
| .insert_aux(&[(LAST_COMPLETED_KEY, &encoded_state[..])], &[]) | ||
| { | ||
| warn!(target: "afg", "Error bookkeeping last completed round in DB: {:?}", e); |
There was a problem hiding this comment.
Error here is quite possible. Out of disk for example. Is simple warning enough?
…ech#866) * Allow disabling ink-alloc-related features for assets module * .
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.39 to 1.0.40. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](dtolnay/thiserror@1.0.39...1.0.40) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me>
This adds a wrapper (currently unused) for the finality gadget in the
substrate-finality-grandpacrate, providing the necessary scaffolding to cast votes, integrate in the network, and finalize blocks. It currently hinges on a fixed list of validators, but a follow-up PR will include validator-set handoffs.Most of the work is implementing the
grandpa::voter::Environmenttrait, which does the work of setting up timers and actually finalizing blocks when GRANDPA says they should be.This also exposes a bunch of test helpers from the
substrate-networkcrate.