Skip to content

Instantly share code, notes, and snippets.

View tomusdrw's full-sized avatar

Tomasz Drwięga tomusdrw

View GitHub Profile
type PayloadType = {
};
type EstimateFeeType = {};
class ApiCalls {
async estimateFee(chain: Chain, laneId: LaneId, payload: PayloadType): EstimateFeeType {
const payloadType = createType(chain, "OutboundPayload", payload);
/// A helper type to allow using arbitrary SCALE-encoded leaf data in the RuntimeApi.
///
/// The point is to be able to verify MMR proofs from external MMRs, where we don't
/// know the exact leaf type, but it's enough for us to have it SCALE-encoded.
///
/// Note the leaf type should be encoded in it's compact form when passed through this type.
/// See [FullLeaf] documentation for details.
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[derive(RuntimeDebug, Clone, PartialEq)]
pub struct OpaqueLeaf(
// creating a state dump file (one time job), later on it's uploaded to S3 or something.
// We could build an API service with an archive node that can compute state dumps at any block you request and then cache them.
remote_externalities::Builder::new()
.module("PhragmenElection")
.uri(URI.to_owned())
.at(now)
.dump_to_file(format!("PhragmenElection-at-{}-polkadot.statedump", now, URI))
.await;
/// actual test (can be re-run as many times you want, without the need to access an actual node)
#[tokio::test]
fn should_read_state() {
// given
// This starts a special "test node" in the background. We communicate with the node over RPC.
let mut test = test::deterministic(PolkadotRuntime.into());
type Balances = pallet_balances::Module<Runtime>;
// This uses ManualSeal consensus (might require conditional compilation of Runtime though :()
{
"name": "BridgePoa",
"engine": {
"authorityRound": {
"params": {
"stepDuration": 5,
"startStep": 2,
"validators": {
"list": [
"0x005e714f896a8b7cede9d38688c1a81de72a58e4",
pub type AccountId = u64;
mod sp_core_crypto_dummy {
use primitives::crypto::*;
use codec::{Encode, Decode};
/// Dummy cryptography. Doesn't do anything.
#[derive(Clone, Hash, Default, Eq, PartialEq, Encode, Decode, Debug, Ord, PartialOrd)]
pub struct Dummy;

Multi-threaded:

  • importing (write lock)
  • getting pending set (read lock)

Background task:

  • removing invalid
  • culling // needs to be informed about major sync
  • managing revalidation
  • Locks:
2019-03-27 15:40:32 Pre-sealed block for proposal at 21. Hash now 0xf94984b222db72952956e247066511089cdb5ee240ceb386373ba01d27c6675a, previously 0x02c6fdb1656f01af72c788c0c74b7ae802a6f76265ae07b3e925dceda53ed8ff.
Hash: given=1d202ef43070d026bd5ff79e41222d9d1560c4ba90446fe119dac2cf68ce62fe, expected=4a65837bb3c6aea26cfbedda19f3fcb8a2ee34b11a767d04ee1640b76dd05a97
====================
stack backtrace:
0: substrate_panic_handler::panic_hook::h8bacb1ac4e7c6655 (0x5601c3b99add)
at core/panic-handler/src/lib.rs:82
1: substrate_panic_handler::set::{{closure}}::hb14e1cf94b23162b (0x5601c3b9abf6)
at core/panic-handler/src/lib.rs:31
logs.txt:2019-03-27 13:32:06.938 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 1, ready_bytes: 139, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.944 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 2, ready_bytes: 278, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.950 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 3, ready_bytes: 417, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.954 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 4, ready_bytes: 556, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.959 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 5, ready_bytes: 695, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.964 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 6, ready_bytes: 834, future: 0, future_bytes: 0 }
logs.txt:2019-03-27 13:32:06.969 jsonrpc-eventloop-0 DEBUG txpool Pool Status: Status { ready: 7, ready_bytes: 973, future: 0, future_bytes: 0 }
lo
tomusdrw@t ~/workspace/substrate gav-fixes $ ./target/debug/substrate --dev --block-construction-execution=Wasm --other-execution=Wasm --importing-execution=Wasm --syncing-execution=Wasm
2019-03-19 11:43:34 Substrate Node
2019-03-19 11:43:34 version 0.10.0-e263901b-x86_64-linux-gnu
2019-03-19 11:43:34 by Parity Technologies, 2017-2019
2019-03-19 11:43:34 Chain specification: Development
2019-03-19 11:43:34 Node name: bustling-snow-7464
2019-03-19 11:43:34 Roles: AUTHORITY
2019-03-19 11:43:37 Initialising Genesis block/state (state: 0x0872…abc6, header-hash: 0x6e88…85e7)
2019-03-19 11:43:37 Loaded block-time = 4 seconds from genesis on first-launch
2019-03-19 11:43:37 Loading GRANDPA authority set from genesis on what appears to be first startup.