Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4f03019
update basic_add wasm
rphmeier Jul 18, 2018
82def8c
Merge remote-tracking branch 'upstream/master' into basic-add-collator
rphmeier Jul 18, 2018
6d7a112
wasm feature and collator feature
rphmeier Jul 18, 2018
7a2b86a
move test parachains around a little
rphmeier Jul 20, 2018
78c0226
fix wasm build for basic_add
rphmeier Jul 20, 2018
18dfc62
move basic_add to adder, introduce README
rphmeier Jul 20, 2018
2bdcaf9
minimal basic_add collator
rphmeier Jul 23, 2018
9083847
ensure collator messages are sent in the right order
rphmeier Jul 23, 2018
c157c4c
more logging
rphmeier Jul 23, 2018
6b5f5ff
route consensus statements to all peers
rphmeier Jul 23, 2018
957f69e
minor bugfixes for parachains
rphmeier Jul 23, 2018
d9e1c77
genesis builder accounts for parachain heads
rphmeier Jul 23, 2018
53889d7
Merge remote-tracking branch 'upstream/master' into rh-simple-parachain
rphmeier Jul 24, 2018
d628c3d
fix parachains tests
rphmeier Jul 24, 2018
5653984
targets for txpool
rphmeier Jul 24, 2018
6888a5b
tweak runtime + collator
rphmeier Jul 25, 2018
beded4c
Merge remote-tracking branch 'upstream/master' into rh-simple-parachain
rphmeier Jul 26, 2018
ec68919
fix version in adder-collator
rphmeier Jul 27, 2018
5c633ea
Merge remote-tracking branch 'upstream/master' into rh-simple-parachain
rphmeier Jul 27, 2018
5625a81
consistency for overflowing
rphmeier Jul 27, 2018
b8e9dfc
Merge branch 'master' into rh-simple-parachain
gavofyork Jul 29, 2018
2e7d5c8
Merge remote-tracking branch 'upstream/master' into rh-simple-parachain
rphmeier Jul 30, 2018
55cbde1
Merge branch 'rh-simple-parachain' of github.com:paritytech/polkadot …
rphmeier Jul 30, 2018
1ebdd12
adjust comment
rphmeier Jul 30, 2018
65112b3
fix stable test run
rphmeier Jul 30, 2018
5e50c6a
remove dummy registration test
rphmeier Jul 30, 2018
b393ae9
final grumbles
rphmeier Jul 31, 2018
b1e3250
Merge remote-tracking branch 'upstream/master' into rh-simple-parachain
rphmeier Aug 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor bugfixes for parachains
  • Loading branch information
rphmeier committed Jul 23, 2018
commit 957f69ef51df460bb5250b84f3918fa2e98f1f47
64 changes: 46 additions & 18 deletions polkadot/consensus/src/shared_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ impl SharedTableInner {
fetch_block_data,
fetch_extrinsic,
evaluate: checking_validity,
ensure_available: checking_availability,
})
}
}
Expand Down Expand Up @@ -206,6 +207,7 @@ struct Work<D: Future, E: Future> {
fetch_block_data: future::Fuse<D>,
fetch_extrinsic: Option<future::Fuse<E>>,
evaluate: bool,
ensure_available: bool,
}

/// Primed statement producer.
Expand Down Expand Up @@ -235,31 +237,35 @@ impl<D, E, C, Err> Future for PrimedStatementProducer<D, E, C>
});

let hash = work.candidate_receipt.hash();

debug!(target: "consensus", "Making validity statement about candidate {}: is_good? {:?}", hash, is_good);
self.inner.produced_statements.validity = match is_good {
Some(true) => Some(GenericStatement::Valid(hash)),
Some(false) => Some(GenericStatement::Invalid(hash)),
None => None,
};
}
}

if let Some(ref mut fetch_extrinsic) = work.fetch_extrinsic {
if let Async::Ready(extrinsic) = fetch_extrinsic.poll()? {
self.inner.produced_statements.extrinsic = Some(extrinsic);
work.evaluate = false;
}
}

let done = self.inner.produced_statements.block_data.is_some() && {
if work.evaluate {
true
} else if self.inner.produced_statements.extrinsic.is_some() {
if let Async::Ready(Some(extrinsic)) = work.fetch_extrinsic.poll()? {
if work.ensure_available {
let hash = work.candidate_receipt.hash();
debug!(target: "consensus", "Claiming candidate {} available.", hash);

// TODO: actually wait for block data and then ensure availability.
self.inner.produced_statements.extrinsic = Some(extrinsic);
self.inner.produced_statements.availability =
Some(GenericStatement::Available(work.candidate_receipt.hash()));
Some(GenericStatement::Available(hash));

true
} else {
false
work.ensure_available = false;
}
}

let done = match (work.evaluate, work.ensure_available) {
(false, false) => true,
_ => false,
};

if done {
Expand Down Expand Up @@ -356,10 +362,25 @@ impl SharedTable {
}

/// Sign and import a local statement.
pub fn sign_and_import(&self, statement: table::Statement) -> SignedStatement {
let proposed_digest = match statement {
GenericStatement::Candidate(ref c) => Some(c.hash()),
_ => None,
///
/// For candidate statements, this may also produce a second signed statement
/// concerning the availability of the candidate data.
pub fn sign_and_import(&self, statement: table::Statement)
-> (SignedStatement, Option<SignedStatement>)
{
let (proposed_digest, availability) = match statement {
GenericStatement::Candidate(ref c) => {
let mut availability = None;
let hash = c.hash();

// TODO: actually store the data in an availability store of some kind.
if self.context.is_availability_guarantor_of(&self.context.local_id(), &c.parachain_index) {
availability = Some(self.context.sign_statement(GenericStatement::Available(hash)));
}

(Some(hash), availability)
}
_ => (None, None),
};

let signed_statement = self.context.sign_statement(statement);
Expand All @@ -370,7 +391,13 @@ impl SharedTable {
}

inner.table.import_statement(&*self.context, signed_statement.clone());
signed_statement

// ensure the availability statement is imported after the candidate.
if let Some(a) = availability.clone() {
inner.table.import_statement(&*self.context, a);
}

(signed_statement, availability)
}

/// Execute a closure using a specific candidate.
Expand Down Expand Up @@ -543,5 +570,6 @@ mod tests {

assert!(producer.work.fetch_extrinsic.is_some(), "should fetch extrinsic when guaranteeing availability");
assert!(!producer.work.evaluate, "should not evaluate validity");
assert!(producer.work.ensure_available);
}
}
25 changes: 15 additions & 10 deletions polkadot/network/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ impl<P: LocalPolkadotApi + Send + Sync + 'static> Router<P> {
};

// prepend the candidate statement.
debug!(target: "consensus", "Importing statements about candidate {:?}", c_hash);
statements.insert(0, statement);
let producers: Vec<_> = self.table.import_remote_statements(
self,
statements.iter().cloned(),
);
// dispatch future work as necessary.
for (producer, statement) in producers.into_iter().zip(statements) {
let producer = match producer {
Some(p) => p,
None => continue, // statement redundant
};

self.knowledge.lock().note_statement(statement.sender, &statement.statement);
self.dispatch_work(c_hash, producer);

if let Some(producer) = producer {
trace!(target: "consensus", "driving statement work to completion");
self.dispatch_work(c_hash, producer);
}
}
}

Expand Down Expand Up @@ -162,12 +162,12 @@ impl<P: LocalPolkadotApi + Send + Sync + 'static> Router<P> {

// propagate the statements
if let Some(validity) = produced.validity {
let signed = table.sign_and_import(validity.clone());
let signed = table.sign_and_import(validity.clone()).0;
network.with_spec(|spec, ctx| spec.gossip_statement(ctx, parent_hash, signed));
}

if let Some(availability) = produced.availability {
let signed = table.sign_and_import(availability);
let signed = table.sign_and_import(availability).0;
network.with_spec(|spec, ctx| spec.gossip_statement(ctx, parent_hash, signed));
}
});
Expand All @@ -184,10 +184,15 @@ impl<P: LocalPolkadotApi + Send> TableRouter for Router<P> {
fn local_candidate(&self, receipt: CandidateReceipt, block_data: BlockData, extrinsic: Extrinsic) {
// give to network to make available.
let hash = receipt.hash();
let signed = self.table.sign_and_import(GenericStatement::Candidate(receipt));
let (candidate, availability) = self.table.sign_and_import(GenericStatement::Candidate(receipt));

self.knowledge.lock().note_candidate(hash, Some(block_data), Some(extrinsic));
self.network.with_spec(|spec, ctx| spec.gossip_statement(ctx, self.parent_hash, signed));
self.network.with_spec(|spec, ctx| {
spec.gossip_statement(ctx, self.parent_hash, candidate);
if let Some(availability) = availability {
spec.gossip_statement(ctx, self.parent_hash, availability);
}
});
}

fn fetch_block_data(&self, candidate: &CandidateReceipt) -> BlockDataReceiver {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn new_full(config: Configuration, executor: TaskExecutor)
consensus_net,
service.extrinsic_pool(),
executor,
::std::time::Duration::from_millis(4000), // TODO: dynamic
::std::time::Duration::from_secs(4), // TODO: dynamic
key,
))
} else {
Expand Down