Conversation
substrate/rpc/src/chain/mod.rs
Outdated
| /// Polkadot blockchain API | ||
| pub trait ChainApi { | ||
| type Metadata; | ||
| ASSOCIATED type Header; |
There was a problem hiding this comment.
to distinguish from the rust-like grammar. happy to change though.
There was a problem hiding this comment.
Ok, I might not understand how this works. What's really the difference between declaring type Header and type Metadata?
There was a problem hiding this comment.
type Metadata; already existed; it's some sort of marker that the macro uses to change the code that's generated.
i had to add the ASSOCIATED tag in order to allow for doc-comments of the type, since otherwise the grammar is ambiguous.
There was a problem hiding this comment.
seems like it should be reversed, that the "weird" associated type carries the non-standard grammar. I'm fine for now as long as we file to patch the JSONRPC crate at some point.
| } | ||
|
|
||
| /// Abstraction around hashing | ||
| pub trait Hashing { |
There was a problem hiding this comment.
more idiomatic to call it Hash since it describes a hash function
There was a problem hiding this comment.
it's actually just moving existing code around, so rather out of scope for this pr
| } | ||
|
|
||
| /// Produce the patricia-trie root of a mapping from indices to byte slices. | ||
| fn enumerated_trie_root(items: &[&[u8]]) -> Self::Output; |
There was a problem hiding this comment.
this and other trie_root functions should be able to go away with upcoming generalization. Although it will use a slightly different Hash trait
There was a problem hiding this comment.
agree. one for a later refactoring pr though.
| >(input: I) -> Self::Output; | ||
|
|
||
| /// Acquire the global storage root. | ||
| fn storage_root() -> Self::Output; |
There was a problem hiding this comment.
that doesn't seem like something that belongs in a hash trait, rather it should be some functionality which is parameterized by it
There was a problem hiding this comment.
was already there and being used, so if there's any refactoring to be done, i would prefer to leave it for another pr.
|
icing until #113 is in (some conflicting changes) |
| #[cfg(feature = "std")] | ||
| impl<Block: BlockT> fmt::Display for Id<Block> { | ||
| fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { | ||
| format!("{:?}", self) |
There was a problem hiding this comment.
should be write!(f, "{:?}", self), currently it just creates a string on the heap and drops it.
|
Trying to build this I get a compilation error like so: I suspect it's because |
|
@dvdplm this is very much inprogress - not expected to build quite yet. here just to show off direction. |
|
that particular issue was fixed in the latest commit, fwiw; |
Yeah, came here to look for some inspiration on generics as I struggle a bit with this stuff. |
should be a major change if we follow semver |
it was pre-1.0, so i think minor bumps for breaking changes are the convention. |
| state: B::State, | ||
| changes: state_machine::OverlayedChanges, | ||
| // will probably need PhantomData<Hashing> here... | ||
| dummy: PhantomData<Hashing>, |
There was a problem hiding this comment.
The block (or even header) type ought to specify what hash algorithm it's using. Otherwise you need to specify Hashing everywhere you want to do a simple transformation from block header to hash.
|
Posting here so it's not hidden: The block (or even header) type ought to specify what hash algorithm it's using. Otherwise you need to specify Hashing everywhere you want to do a simple transformation from block header to hash. |
|
Yup - should indeed be the Header so it's available within the runtime in the appropriate modules. |
|
Ready for review. Substrate is fully generic at compile-time, but the polkadot-runtime, in order to maintain on-chain upgradeability, has to use runtime polymorphism of the extrinsic type.
All the generic client code used in polkadot is instantiated with |
gavofyork
left a comment
There was a problem hiding this comment.
Would be really nice to ensure that test_runtime remained actually trivial rather than forcing the Call model onto it. Fact is that protocols like Blitz and a Z-cash UXTO chain (and many chains that are being prepped as a parachain) won't have a "Call" type - it's pretty specific to Polkadot/Edgware chains.
polkadot/primitives/src/lib.rs
Outdated
| } | ||
|
|
||
| /// Parachain data types. | ||
| pub mod parachain { |
There was a problem hiding this comment.
Any reason to inline this rather than leave as a separate file?
|
|
||
| /// Provides a type-safe wrapper around a structurally valid block. | ||
| #[cfg(feature = "std")] | ||
| pub struct CheckedBlock { |
There was a problem hiding this comment.
Could do to be in separate file?
There was a problem hiding this comment.
the runtime file isn't that big, I don't see any reason to extract yet
polkadot/service/src/lib.rs
Outdated
| let id = self.api.check_id(BlockId::Hash(best_block)).expect("Best block is always valid; qed."); | ||
| let id = match self.api.check_id(BlockId::hash(best_block)) { | ||
| Ok(id) => id, | ||
| Err(_) => { |
There was a problem hiding this comment.
Curlies are unneeded and, from what I've seen recently, non-idiomatic
polkadot/transaction-pool/src/lib.rs
Outdated
| match xt.check() { | ||
| Ok(xt) => { | ||
| let hash = substrate_primitives::hashing::blake2_256(&message); | ||
| let hash = BlakeTwo256::hash_of(&message); |
There was a problem hiding this comment.
i think this should be BlakeTwo256::hash (hash_of first encodes using Slicable which would add a length prefix).
| enum BlockRangeState { | ||
| enum BlockRangeState<B: BlockT> { | ||
| Downloading { | ||
| len: BlockNumber, |
There was a problem hiding this comment.
Why not <B::Header as HeaderT>::Number?
There was a problem hiding this comment.
Needs to be able to convert safely between it and usize.
| type Call: AuxDispatchable + Slicable + Clone + PartialEq + Eq; | ||
| } | ||
|
|
||
| // dirty hack to work around serde_derive issue. |
There was a problem hiding this comment.
Would be good to know more about this issue - a link & description of what to do when the issue is sorted.
There was a problem hiding this comment.
see the linked serde issue
| } | ||
|
|
||
| /// Type alias for extracting message type from block. | ||
| pub type MessageFor<B> = Message<B, <B as ::traits::Block>::Hash>; |
There was a problem hiding this comment.
What does "message" mean here? What if the block type doesn't have the notion of "message"?
There was a problem hiding this comment.
Since it's in the bft module, it's fair to assume that this is a BFT message. The BFT subsystem is something that operates over block types as opposed to being a property of them.
| Hash: Member + Slicable, | ||
| DigestItem: Member + Slicable, | ||
| // Hack to work around the fact that deriving deserialize doesn't work nicely with | ||
| // the `hashing` trait used as a parameter. |
There was a problem hiding this comment.
Link to issue + description of how to change once issue sorted would be good.
| /// Verify a signature on an encoded value in a lazy manner. This can be | ||
| /// an optimization if the signature scheme has an "unsigned" escape hash. | ||
| pub fn verify_encoded_lazy<V: Verify, T: codec::Slicable>(sig: &V, item: &T, signer: &V::Signer) -> bool { | ||
| // TODO: unfortunately this is a lifetime relationship that can't |
There was a problem hiding this comment.
Issue link + description of how to change once issue is sorted would be good.
There was a problem hiding this comment.
we would need rust-lang/rust#44265 and then the Fn* traits would have to be extended to use it somehow. I don't think it's likely to be something we can work around until a few more epochs of Rust. I'll remove the TODO because it's not reasonable to do in the near future.
| fn state_root(&self) -> &Self::Hash { &self.state_root } | ||
| fn parent_hash(&self) -> &Self::Hash { &self.parent_hash } | ||
| fn digest(&self) -> &Self::Digest { &self.digest } | ||
| fn new( |
* Rebuild runtime * Remove invalid value from chainspec (paritytech#68) * service: use grandpa block import for locally sealed aura blocks (paritytech#85) * bump version to v0.3.1 * Update lock file. * limit number of transactions when building blocks (paritytech#91) * Update to latest Substrate * Bump to 0.3.2 * Actually bump. * v0.3.2 (paritytech#98) * bump substrate version * fix polkadot-collator * point to alexander-backports of substrate * bump version * cli: fix node shutdown (paritytech#100) * update to latest substrate, change to v0.3.4 * update to latest substrate, bump version to 0.3.5 * v0.3.6 * try to build on every v0.3 commit and update alexander-backports * bump to v0.3.7 * bump to 0.3.8 * Bump to 0.3.9: network and pruning improvements * Bump to 0.3.10: reduce network bandwidth usage * Use libp2p-kad 0.3.2 (paritytech#122) * Bump libp2p-identify to 0.3.1 (paritytech#123) * Bump to 0.3.12 (paritytech#127) * Update Substrate again (paritytech#128) * update substrate and bump version to v0.3.13 * bump version to v0.3.14: fix --reserved-nodes * add a manually curated grandpa module (paritytech#136) * updating v0.3 to use substrate v0.10 (paritytech#146) * updating to latest substrate v0.10 * better handling of outer poll * nit * fix tests * remove comment * reduce indentation * use self.poll * bring oneshot into scope * spaces * wrap * remove match * wrap * Update primitives/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update test-parachains/adder/collator/src/main.rs Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * indent * add paranthese * config: fix wrong ip for alexander bootnode (paritytech#161) * fix curated-grandpa and rebuild wasm (paritytech#162) * [v0.3] Integrates new gossip system into Polkadot (paritytech#166) * new gossip validation in network * integrate new gossip into service * network: guard validation network future under exit signal (paritytech#168) * bump version to v0.3.15: substrate v0.10 * [v0.3] update to substrate master (paritytech#175) * update to substrate master * fix test * service: fix telemetry endpoints on alexander chainspec (paritytech#169) (paritytech#178) * Update v0.3 to latest Substrate master (paritytech#177) * update substrate v0.3 to latest master * bump spec version * update to latest master: remove fees module * update runtime blobs * bump version to 0.3.16 * replace sr25519 accountid with anysigner * bump version to v0.3.17 * Some PoC-3 GRANDPA tweaks (paritytech#181) * call on_finalise after triggering curated_grandpa change * make grandpa rounds shorter for faster finalization * use authorities when calculating duty roster (paritytech#185) * [v0.3] Update to substrate master (paritytech#183) * update to latest substrate master * bump version to 0.3.18 * update to latest substrate master * bump spec version * update runtime wasm blobs * remove current_offline_slash from chain spec * update to substrate master: bump version to v0.3.19 (paritytech#188) * update to substrate master: bump version to v0.3.19 libp2p network improvements * network: replace NodeIndex with PeerId * network: fix tests * polkadot v0.3.20 (paritytech#190) * update to substrate master: bump version to 0.3.20 * runtime: add offchain worker trait * runtime: rebuild wasm blobs * bump spec version (paritytech#191) * Fix compilation * Update version to 0.4.0 * Switch to use `polkadot-master` branch from substrate * Remove unused struct * Remove `grandpa::SyncedAuthorities` from `OnSessionChange`
* Initial sketch * Override relay spec for well-known para specs * Update existing spec generation scripts * Update specs/README.md Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Prettier * note * Better naming * cargo fmt But actually, I don't like converting to and from String like this anyway. * Clean tests readme * Newlines at end of spec files * line length * cleaner way to associate a relay spec. * Newer spec files. These are mocks * oops import * cargo fmt * prettier spec * Fix type Basti confirmed I "should" use the rococo one here. He also mentioned it didn't really matter when using a raw spec. * use specs for alphanet blue * remove spec publishing from CI * Fixes staking parameter to include 18 decimals * fix previous formatting issue * Forces ts target to 2020 for tests Co-authored-by: Amar Singh <asinghchrony@protonmail.com> Co-authored-by: crystalin <alan.sapede@gmail.com> Co-authored-by: Crystalin <alan@purestake.com>
* Split out xp-runtime * Commit xp-runtime * Move xss_check() to xp-runtime
With the eventual aim to remove
substrate/primitives/block.rsentirely. This will mean making thebftmodules generic since they have substantial dependencies on several of the types inherent inHeader. Yet to do:Hashingtype inHeaderin favour of Hash;substrate_primitives::bftmodule intosubstrate_runtime_primitivesand make generic oversubstrate_runtime_primitives::{Block, Header, Hashing}traits;substrate/bftsimilarly generic;substrate/networksimilarly generic;polkadotcode'sBlock,Header&c;polkadot/consensusmodule to use the new types.