Skip to content

Commit

Permalink
feat: Implement p2p bootstrap improvement (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidan46 authored Feb 14, 2025
1 parent 543a168 commit 43105aa
Show file tree
Hide file tree
Showing 17 changed files with 554 additions and 168 deletions.
65 changes: 64 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async-trait = "0.1.80"
axum = "0.7.5"
base64 = "0.22.1"
beetswap = "0.4.0"
bincode = "1.3.3"
bitflags = "2.5.0"
blake2b_simd = { version = "1.0.2", default-features = false }
blockstore = "0.7.1"
Expand Down
15 changes: 11 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ release-testnet:
# run the testnet without building
run-testnet:
mkdir -p /tmp/zombienet
openssl genpkey -algorithm ED25519 -out /tmp/zombienet/private.pem
openssl pkey -in /tmp/zombienet/private.pem -pubout -out /tmp/zombienet/public.pem # Generate public key so script can get the Peer ID
openssl genpkey -algorithm ED25519 -out /tmp/zombienet/charlie-private.pem
openssl pkey -in /tmp/zombienet/charlie-private.pem -pubout -out /tmp/zombienet/charlie-public.pem # Generate public key so script can get the Peer ID
zombienet -p native spawn zombienet/local-testnet.toml

# Run a single collator
run-collator:
mkdir -p /tmp/zombienet
openssl genpkey -algorithm ED25519 -out /tmp/zombienet/david-private.pem
openssl pkey -in /tmp/zombienet/david-private.pem -pubout -out /tmp/zombienet/david-public.pem # Generate public key so script can get the Peer ID
zombienet -p native spawn zombienet/local-david-collator.toml

# Run the testing building it before
testnet: release-testnet run-testnet

Expand Down Expand Up @@ -165,8 +172,8 @@ load-to-minikube:

kube-testnet:
mkdir -p /tmp/zombienet
openssl genpkey -algorithm ED25519 -out /tmp/zombienet/private.pem
openssl pkey -in /tmp/zombienet/private.pem -pubout -out /tmp/zombienet/public.pem # Generate public key so script can get the Peer ID
openssl genpkey -algorithm ED25519 -out /tmp/zombienet/charlie-private.pem
openssl pkey -in /tmp/zombienet/charlie-private.pem -pubout -out /tmp/zombienet/charlie-public.pem # Generate public key so script can get the Peer ID
zombienet -p kubernetes spawn zombienet/local-kube-testnet.toml

# The tarpaulin calls for test coverage have the following options:
Expand Down
2 changes: 1 addition & 1 deletion examples/start_sp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PROVIDER="//Charlie"
P2P_ADDRESS="/ip4/127.0.0.1/tcp/62649"
P2P_PUBLIC_KEY="/tmp/polka-storage-provider/public.pem"
P2P_PRIVATE_KEY="/tmp/polka-storage-provider/private.pem"
P2P_BOOTSTRAP_PUBLIC_KEY="/tmp/zombienet/public.pem"
P2P_BOOTSTRAP_PUBLIC_KEY="/tmp/zombienet/charlie-public.pem"
# Config file location
CONFIG="/tmp/polka-storage-provider/config.toml"

Expand Down
16 changes: 14 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ frame-benchmarking = { workspace = true, default-features = true }
frame-benchmarking-cli = { workspace = true, default-features = true }
futures = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
libp2p = { workspace = true, features = ["identify", "macros", "noise", "rendezvous", "tcp", "tokio", "yamux"] }
log = { workspace = true, default-features = true }
libp2p = { workspace = true, features = [
"cbor",
"gossipsub",
"identify",
"macros",
"noise",
"rendezvous",
"request-response",
"tcp",
"tokio",
"yamux",
] }
log = { workspace = true, features = ["kv"], default-features = true }
pallet-transaction-payment-rpc = { workspace = true, default-features = true }
polkadot-cli = { features = ["rococo-native"], workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
Expand Down Expand Up @@ -69,6 +80,7 @@ sp-runtime = { workspace = true, default-features = true }
sp-timestamp = { workspace = true, default-features = true }
substrate-frame-rpc-system = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros"] }
xcm.workspace = true

[build-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ pub struct RunCmd {
/// that the bootstrap node binds to.
#[arg(long, required = false)]
pub p2p_listen_address: Option<Multiaddr>,

/// List of other bootstrap nodes
#[arg(long, required = false, num_args = 1..)]
pub bootstrap_addresses: Option<Vec<Multiaddr>>,
}
8 changes: 7 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ pub fn run() -> Result<()> {
.ok_or(
"This node is configured as authority, so it will be used as Bootstrap node for Storage Provider & Collator network, but the listen address is missing. Set the --p2p-listen-address argument of the node."
)?;
Some(BootstrapConfig::new(p2p_key, p2p_listen_address))
let bootstrap_addresses = cli
.run
.bootstrap_addresses
.ok_or(
"This node is configured as authority, so it will be used as Bootstrap node for Storage Provider & Collator network, but the bootstrap addresses are missing. Set the --bootstrap-addresses argument of the node."
)?;
Some(BootstrapConfig::new(p2p_key, p2p_listen_address, bootstrap_addresses))
} else {
None
};
Expand Down
Loading

0 comments on commit 43105aa

Please sign in to comment.