Skip to content

Commit

Permalink
Merge pull request #14 from ideal-lab5/jg/use-latest-pallet-drand
Browse files Browse the repository at this point in the history
feat: use latest drand pallet
  • Loading branch information
juangirini authored Dec 4, 2024
2 parents 84cbc3b + d586f5b commit 1d0b98e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 46 deletions.
80 changes: 51 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = ["Ideal Labs <hello@idealabs.network>"]
repository = "https://github.com/ideal-lab5/ideal-network"
homepage = "https://idealabs.network"
license = "Apache-2.0"
version = "0.1.2"
version = "0.1.3"

[workspace.lints.rust]
suspicious_double_ref_op = { level = "allow", priority = 2 }
Expand All @@ -34,7 +34,7 @@ futures = { version = "0.3.30" }
ideal-nw-runtime = { path = "runtime", default-features = false }

# Ideal Network
pallet-drand = { git = "https://github.com/ideal-lab5/pallets", default-features = false }
pallet-drand = { git = "https://github.com/ideal-lab5/idn-sdk", default-features = false }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-crates-io-v1.14.0", default-features = false }
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains implementations of the Ideal Network parachain node.

**WARNING**: This is a work in progress and is not ready for production use as it is based on an [unsafe version of the Drand pallet](https://github.com/ideal-lab5/pallet-drand/blob/main/docs/how_it_works.md#assumption-and-limitations).
**WARNING**: This is a work in progress and is not ready for production use as it is based on an [unsafe version of the Drand pallet](https://github.com/ideal-lab5/idn-sdk/blob/7ea5ef08cf138cb571304f21bb389fbdcd05bd41/pallets/drand/docs/how_it_works.md#assumption-and-limitations).

## Build

Expand Down Expand Up @@ -31,7 +31,7 @@ docker build -f Dockerfile.arm64 . # for arm64 architecture
#### Run the image

If you have built your image, replace `[image]` with the image name you have built.
If you are using the pre-built image, replace `[image]` with `ideallabs/idn:testnet-0.1.0-amd64` for amd64 architecture or `ideallabs/idn:testnet-0.1.0-arm64` for arm64 architecture.
If you are using the pre-built image, replace `[image]` with `ideallabs/idn:0.1.3-amd64` for amd64 architecture or `ideallabs/idn:0.1.3-arm64` for arm64 architecture.

```sh
docker run [image] [options]
Expand Down Expand Up @@ -93,18 +93,16 @@ It should output something like this:
│ logs: tail -f /var/folders/_y/qwer/T/zombie-asdf/bob/bob.log
│ ⛓️ dev: 1000
│ collator-01:
│ portal: https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:51553#/explorer
│ portal: https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:1234#/explorer
│ logs: tail -f /var/folders/_y/qwer/T/zombie-asdf/collator-01/collator-01.log
```

You can see here that the parachain node `collator-01` is running on `ws://127.0.0.1:51553`.
Take note of the parachain WS port, in this case `51553`, as you will need it to interact with the parachain in the next step.

3. Insert the Drand pallet's authority keys. For Alice it can be done by running the following command:
3. Insert the Drand pallet's authority keys. For Alice it can be done by running the following command on a separate terminal:

```sh
chmod +x insert_alice_drand_key.sh
./insert_alice_drand_key.sh <PARACHAIN_WS_PORT>
./insert_alice_drand_key.sh
```

4. Done, you can now interact with the parachain using the "portal" link provided by the `pop` CLI tool (see the output from step 2).
4. Done, you can now interact with the parachain using this link https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:1234#/explorer.
Bear in mind that you may need to wait a few seconds for the block production to start.
2 changes: 1 addition & 1 deletion insert_alice_drand_key.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Parameters
NODE_URL="http://127.0.0.1:$1"
NODE_URL="http://127.0.0.1:1234"
KEY_TYPE="drnd"
SEED="//Alice"
PUBLIC_KEY="0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
Expand Down
1 change: 1 addition & 0 deletions network.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ chain = "dev"
[[parachains.collators]]
name = "collator-01"
command = "./target/release/ideal-nw-node"
rpc_port = 1234
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ideal-nw-runtime"
description = "Ideal Network Runtime"
version = "0.1.2"
version = "0.1.3"
license.workspace = true
authors.workspace = true
homepage.workspace = true
Expand Down
13 changes: 10 additions & 3 deletions runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,20 @@ impl pallet_collator_selection::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const UnsignedPriority: u64 = 1 << 20;
pub const HttpFetchTimeout: u64 = 2_000;
pub const ApiEndpoint: &'static str = "https://drand.cloudflare.com";
}

impl pallet_drand::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_drand::weights::SubstrateWeight<Runtime>;
type AuthorityId = pallet_drand::crypto::TestAuthId;
type Verifier = pallet_drand::UnsafeSkipVerifier;
type UnsignedPriority = ConstU64<{ 1 << 20 }>;
type HttpFetchTimeout = ConstU64<2_000>;
type Verifier = pallet_drand::verifier::UnsafeSkipVerifier;
type UnsignedPriority = UnsignedPriority;
type HttpFetchTimeout = HttpFetchTimeout;
type ApiEndpoint = ApiEndpoint;
}

impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("ideal-nw-runtime"),
impl_name: create_runtime_str!("ideal-nw-runtime"),
authoring_version: 1,
spec_version: 2,
spec_version: 3,
impl_version: 0,
apis: apis::RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit 1d0b98e

Please sign in to comment.