-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Networking and backend fixes #155
Conversation
substrate/client/db/src/lib.rs
Outdated
Ok(self.db.get(columns::BLOCK_INDEX, &number_to_db_key(number)) | ||
.map_err(db_err)? | ||
.map(|hash| block::HeaderHash::from_slice(&hash))) | ||
Ok(self.header(BlockId::Number(number))?.map(|hdr| hdr.blake2_256().into())) |
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.
this is fixed and tested in #152
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.
reverted
substrate/network/src/consensus.rs
Outdated
}, | ||
Ok(status) => { | ||
if status != BlockStatus::InChain { | ||
trace!(target:"sync", "Ignored unknown parent BFT message from {}, hash={}", peer_id, message.parent_hash); |
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.
this doesn't seem right.
- we are building on parent
A
- our peers produce
B
and begin building onB
. Due to latency we still think the chain head is A. - we shouldn't ignore messages about that consensus just because there was latency in delivering
B
to us.
Or imagine if we're syncing and well behind the chain head. our peers might think we have those messages but we just ignored them! then things will stall again.
note that the property for correctness of the BFT implementation is that messages eventually reach and are processed by the other validators. In practice, "eventually" isn't possible, but we can at least make a best-effort of 10 minutes or so.
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.
what we want to keep:
- unrecognized
parent_hash
messages (for some time) parent_hash == chain head
messages
what we don't want to keep
parent_hash
in chain but has children already
substrate/network/src/protocol.rs
Outdated
} | ||
} | ||
|
||
self.consensus.lock().collect_garbage(Some(header.parent_hash)); |
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.
if this doesn't fire every block then we will have a lot of garbage piling up.
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.
seems better to keep track of the header hash of the last notification and pass all the parent headers since then.
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.
That list would be huge if this is called at block 0 before connecting to any peers and then at the end of the full sync. For now I'll just clear all messages if there is a gap.
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.
fairly dangerous but fine if we can assume there are always enough validators at the head of the chain to complete consensus.
substrate/network/src/consensus.rs
Outdated
self.messages.retain(|_, &mut (timestamp, _)| timestamp < now + expiration); | ||
let hashes = &mut self.message_hashes; | ||
self.messages.retain(|&(ref hash, ref message)| { | ||
best_block_parent.map_or(true, |parent_hash| { |
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.
is this not a no-op when None
is passed?
substrate/client/db/src/lib.rs
Outdated
transaction.put(columns::JUSTIFICATION, &key, &justification.encode()); | ||
} | ||
transaction.put(columns::BLOCK_INDEX, &hash, &key); | ||
transaction.put(columns::BLOCK_INDEX, &key, &hash); |
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 think this breaks #152 fix.
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.
and almost definitely breaks fn id
which looks up by hash.
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.
(...this is why unit tests are useful)
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.
screwed up when reverting my fix
* Add fn to validate egress routes * Add blank tests * Reject routing to non existent parachains * Reject if routing to self * Reject if egress route parachain ids out of order * Extract method for checking egress routes * Reject empty egress routes * Extract test method * Generate empty trie root constant in build script * Remove unwraps * Hardcode EMPTY_TRIE_ROOT and add test to verify * Const not pu
* Adds script to test gas from a loop contract * Better load gas test
* refactor for multisig remove doublemap for multisig * Feature/linked node (paritytech#79) provide linked node data struct for runtime module storage this linked node support option data or no option data * provide linkednode struct in cxsupport * refactor linked node * add option for LinkedNode * refactor linkednode remove template mode, use associate type to replace it * Fix static net address (paritytech#80) * Feature/linked_node provide multinodexindex (paritytech#82) provide multinodexindex * fix bug for linked_node when add same index node, do nothing for this node * refactor financialrecords to support withdraw cache refactor financialrecords to support withdraw cache and remove deposit fee * btc bridge * rename num/hash relationship data (NumberForHash/HashsForNumber) * let HashsForNumber map to a vec to get all forked block * add blocknumber in BlockHeaderFor * tokenbalances refactor tokenbalances to support issue token in genesis * reject issue chainx token and provide u32, usize as for tokenbalance * Perfect deposit (paritytech#83) * Add deposit cache * Perfect deposit * Perfect withdraw (paritytech#84) * Perfect withdraw * add network check in btc bridge * when meet testnet, jump header bit check * check the bit change block in genesis * Fix test build * Feature/refactor match (paritytech#86) * matchorder and pendingorders * Fix op_return account id parse * tokenbalances: provide reserved type for reservedtoken * Fix merge error * update genesis_config * Update genesis_config * x-btc * provide codec for btreemap due to orphan for mod, use local struct named `CodecBTreeMap` * Update latest bitcoin-rust dependeces * Implement initial vote weight via coin age (paritytech#87) * Use struct instead of map as much as possible * Unchecked initial version * All intentions except these validators are candidates * Add harsh test * Put candidates into stats * Rename unstake to deactive * Revert StakeWeight * Remove useless code * Remove MAX_INTENTIONS * Refactor with btreemap (paritytech#88) * Refactor NominationRecordsOf to NominationRecords using BTreeMap * Remove candidate_count * Rename deactive to deactivate * optimization match (paritytech#89) * remove ensureaccountliquid in tokenbalances and support for ensureaccountliquied has changed in staking module * Hotfix/fix stakeweight type (paritytech#90) * Revert StakeWeight type * Change Balance to u64 * Fix total_minted and remove valid_cands_weight * Fix insert registration information failure (paritytech#91) * Change receive_address type * Update exterbn * update secp256k1 dependency (paritytech#94) * Fix receive_address bug * Support new substrate in cxrml * update rust-secp256k1 dependeces * Runtime build ok * Build ok * New runtime interface * Update all runtime module * Runtime build ok * All build ok * Add node runtime to support chainx runtime * Update new runtime
* Integrate pallet-authorship So that we can know how many blocks a validator authored in some session. * Support nested structs * Sort manual json * . * Fix types_gen.py the disorder of fields * . * . * Add some missing types in chainx_types_manual.json
…-fork-tree Work around stack overflow by faking block finalization in pruning code
* Update to rc6. * Fix clippy warnings.
Fixed an issue with the DB backend implementation