Skip to content

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylar Simoncelli committed Sep 23, 2024
2 parents a746d83 + 3ce6a8c commit 8a8924f
Show file tree
Hide file tree
Showing 74 changed files with 617 additions and 531 deletions.
317 changes: 166 additions & 151 deletions Cargo.lock

Large diffs are not rendered by default.

144 changes: 73 additions & 71 deletions Cargo.toml

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.

## Changed

* Switched to paritytech/polkadot-sdk polkadot-stable2407-2. No migration is required because of this change.
* Reverted usage of custom Runner that allowed `async_run` with asynchronous initializer.
Now `Runner` code used is the same as in paritytech/polkadot-sdk.
This change requires updates in node: `new_partial` cannot be async.
Expand All @@ -18,6 +19,7 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.
to `sc-partner-chains-consensus-aura` and `sp-partner-chains-consensus-aura`.
This change requires migration of the node, PartnerChainsProposerFactory has to be used.
See `service.rs` in `partner-chains-node` crate for an example.
* renamed sidechain-main-cli and relevant naming to pc-contracts-cli

## Removed

Expand All @@ -27,6 +29,8 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.
* ETCM-7811 - native token movement observability components: `sp-native-token-management` and
`pallet-native-token-management` crates; data sources behind the `native-token` feature in
`main-chain-follower-api` and `db-sync-follower` crates.
* added helper functions to `SidechainParams` and all `MainChainScripts` types to read them from environment
* Extrinsic `set_main_chain_scripts` for migrating to new committee selection main chain scripts

# v1.0.0rc1

Expand Down Expand Up @@ -68,7 +72,7 @@ users in their runtime crate.
* ETCM-7762 - update to polkadot v1.13.0 - requires adaption in node code, because GenericChainSpec has lost one generic parameter
* ETCM-7759 - decoupled all crates that use chain follower data sources from the concrete `DataSources` type.
Now all logic accepts any type that implements one of the traits: `XXXDataSource` or `HasXXXDataSource`.
* ETCM-7766 - updates to accommodate to new version of trustless-sidechain: containers and devnet settings and utilities
* ETCM-7766 - updates to accommodate to new version of partner-chains-smart-contracts: containers and devnet settings and utilities
* BREAKING: ETCM-7818 read candidates related main chain configuration from ledger, not from environment. Migration for existing chains is to put proper configuration in the ledger and then export chain as a spec file.
* ETCM-7855 - removed all Active Flow-related components and features. This change should not affect
Partner Chains nodes that did not use Active Flow.
Expand Down Expand Up @@ -117,7 +121,7 @@ Cleaned `inherent_data.rs` which now contains only wiring and necessary minor he
* ETCM-7080: add aura and grandpa public keys to registrations data returned from RPC method

## Changed
* IMPORTANT: trustless-sidechain revision has been updated in flake.nix. Downstream projects, like Midnight, should keep using the previous value, to keep configuration utilities in sync with their testnets.
* IMPORTANT: partner-chains-smart-contracts revision has been updated in flake.nix. Downstream projects, like Midnight, should keep using the previous value, to keep configuration utilities in sync with their testnets.
* BREAKING: ETCM-5905 - remove all storage maps from pallet-active-flow

* ETCM-7136 - replaced the local partner-chains-session pallet with one from the SDK
Expand Down Expand Up @@ -151,7 +155,7 @@ hiding each data source type behind a feature
## Changed
* BREAKING: ETCM-5898 - remove storage maps from pallet-session-validator-management and simplify the committee rotation logic
* ETCM-6877 - improved the performance of getting the latest on chain committee hash, requires update in deployment configuration.
* ETCM-6822 - update trustless-sidechain revision to: 76f57380b6d85f2c1a1f212591a99ebd0db96213.
* ETCM-6822 - update partner-chains-smart-contracts revision to: 76f57380b6d85f2c1a1f212591a99ebd0db96213.
* ETCM-6816, ETCM-6813 - removed dependency on `sidechain-inherents`, `mock-types` and `sidechain-domain` from `pallet-session-validator-management` crate
* ETCM-6813 - moved authority selection code from `sidechain-inherents` to a new `authority-selection-inherents` crate
* ETCM-6813 - moved code shared between `authority-selection-inherents` and `pallet-session-validator-management`
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli-commands"
version = "0.1.0"
version = "1.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod key_params;
pub mod output;
pub mod registration_signatures;
pub mod sidechain_main_cli_params;
pub mod pc_contracts_cli_params;
pub mod signing;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::Parser;

#[derive(Clone, Debug, Default, Parser)]
pub struct SidechainMainCliParams {
pub struct PcContractsCliParams {
#[arg(long)]
pub ogmios_host: Option<String>,
#[arg(long)]
Expand All @@ -17,7 +17,7 @@ pub struct SidechainMainCliParams {
pub kupo_secure: bool,
}

impl SidechainMainCliParams {
impl PcContractsCliParams {
pub fn command_line_params(&self) -> Vec<Vec<String>> {
let mut args = vec![];
if let Some(ogmios_host) = &self.ogmios_host {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash

# Define release URLs as variables
PC_CONTRACTS_CLI_ZIP_URL="https://github.com/input-output-hk/partner-chains-smart-contracts/releases/download/v6.1.0/trustless-sidechain-cli-6.1.0-x86_64-linux.zip"
PARTNER_CHAINS_NODE_URL="https://github.com/input-output-hk/partner-chains/releases/download/1.1.1-rc1/partner-chains-node-1.1.1-rc1-x86_64-linux"
PARTNER_CHAINS_CLI_URL="https://github.com/input-output-hk/partner-chains/releases/download/1.1.1-rc1/partner-chains-cli-1.1.1-rc1-x86_64-linux"

# Initialize flags
PC_NODE_READY=0
PC_CLI_READY=0
Expand Down
5 changes: 4 additions & 1 deletion dev/local-environment/modules/pc-contracts-cli.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
- KUPO_PORT=${KUPO_PORT}
- OGMIOS_PORT=${OGMIOS_PORT}
- ARTIFACT_OVERRIDE=${ARTIFACT_OVERRIDE}
entrypoint: ["/bin/bash", "/entrypoint.sh"]
- PC_CONTRACTS_CLI_ZIP_URL=${PC_CONTRACTS_CLI_ZIP_URL}
- PARTNER_CHAINS_NODE_URL=${PARTNER_CHAINS_NODE_URL}
- PARTNER_CHAINS_CLI_URL=${PARTNER_CHAINS_CLI_URL}
entrypoint: ["/bin/bash", "/entrypoint.sh"]
6 changes: 6 additions & 0 deletions dev/local-environment/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ KUPO_IMAGE="cardanosolutions/kupo:v2.9.0"
OGMIOS_IMAGE="cardanosolutions/ogmios:v6.6.0"
POSTGRES_IMAGE="postgres:15.3"
SIDECHAIN_MAIN_CLI_IMAGE="node:22-bookworm"
PC_CONTRACTS_CLI_ZIP_URL="https://github.com/input-output-hk/partner-chains-smart-contracts/releases/download/v6.1.0/trustless-sidechain-cli-6.1.0-x86_64-linux.zip"
PARTNER_CHAINS_NODE_URL="https://github.com/input-output-hk/partner-chains/releases/download/1.1.1-rc1/partner-chains-node-1.1.1-rc1-x86_64-linux"
PARTNER_CHAINS_CLI_URL="https://github.com/input-output-hk/partner-chains/releases/download/1.1.1-rc1/partner-chains-cli-1.1.1-rc1-x86_64-linux"

display_banner() {
cat <<'EOF'
Expand Down Expand Up @@ -370,6 +373,9 @@ OGMIOS_IMAGE=$OGMIOS_IMAGE
POSTGRES_IMAGE=$POSTGRES_IMAGE
SIDECHAIN_MAIN_CLI_IMAGE=$SIDECHAIN_MAIN_CLI_IMAGE
PARTNER_CHAINS_NODE_IMAGE=${node_image:-$PARTNER_CHAINS_NODE_IMAGE}
PC_CONTRACTS_CLI_ZIP_URL=$PC_CONTRACTS_CLI_ZIP_URL
PARTNER_CHAINS_NODE_URL=$PARTNER_CHAINS_NODE_URL
PARTNER_CHAINS_CLI_URL=$PARTNER_CHAINS_CLI_URL
EOF

if [ "$mode" == "interactive" ]; then
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guides/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The main chain follower reads from **postgres** that **db-sync** writes to.
**db-sync** itself requires UDS connection to **cardano-node**.

For executing **partner-chains-smart-contracts** CLI commands **ogmios** and **kupo** are required.
Both of them open HTTP ports that `sidechain-main-cli` is looking for by default (1337 and 1442).
Both of them open HTTP ports that `pc-contracts-cli` is looking for by default (1337 and 1442).

This document will help you with spinning up the dependencies running in either docker; or
_process-compose_; the latter utilizing containerless, natively built binaries via nix.
Expand Down
8 changes: 4 additions & 4 deletions envs/devnet/.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export GOVERNANCE_AUTHORITY=76da17b2e3371ab7ca88ce0500441149f03cc5091009f99c99c0
export SIDECHAIN_BLOCK_BENEFICIARY="0x0000000000000000000000000000000000000000000000000000000000000001"

# below exports parse config/addresses.json file, which needs to regenerated for each new sidechain by running
# sidechain-main-cli addresses ... > config/addresses.json
export COMMITTEE_CANDIDATE_ADDRESS=$(jq -r '.addresses.CommitteeCandidateValidator' envs/devnet/addresses.json)
export D_PARAMETER_POLICY_ID=$(jq -r '.mintingPolicies.DParameterPolicy' envs/devnet/addresses.json)
export PERMISSIONED_CANDIDATES_POLICY_ID=$(jq -r '.mintingPolicies.PermissionedCandidatesPolicy' envs/devnet/addresses.json)
# pc-contracts-cli addresses ... > config/addresses.json
export COMMITTEE_CANDIDATE_ADDRESS=$(jq -r '.addresses.CommitteeCandidateValidator' devnet/addresses.json)
export D_PARAMETER_POLICY_ID=$(jq -r '.mintingPolicies.DParameterPolicy' devnet/addresses.json)
export PERMISSIONED_CANDIDATES_POLICY_ID=$(jq -r '.mintingPolicies.PermissionedCandidatesPolicy' devnet/addresses.json)

# native token observability
export NATIVE_TOKEN_POLICY_ID='ada83ddd029614381f00e28de0922ab0dec6983ea9dd29ae20eef9b4'
Expand Down
8 changes: 4 additions & 4 deletions envs/staging-preprod/.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export GOVERNANCE_AUTHORITY=1f0977bc0f57c67ca6d77296c1b575fe05a6dc2c5fa38056ba63
export SIDECHAIN_BLOCK_BENEFICIARY="0x0000000000000000000000000000000000000000000000000000000000000201"

# below exports parse config/addresses.json file, which needs to regenerated for each new sidechain by running
# sidechain-main-cli addresses ... > config/addresses.json
export COMMITTEE_CANDIDATE_ADDRESS=$(jq -r '.addresses.CommitteeCandidateValidator' envs/staging-preprod/addresses.json)
export D_PARAMETER_POLICY_ID=$(jq -r '.mintingPolicies.DParameterPolicy' envs/staging-preprod/addresses.json)
export PERMISSIONED_CANDIDATES_POLICY_ID=$(jq -r '.mintingPolicies.PermissionedCandidatesPolicy' envs/staging-preprod/addresses.json)
# pc-contracts-cli addresses ... > config/addresses.json
export COMMITTEE_CANDIDATE_ADDRESS=$(jq -r '.addresses.CommitteeCandidateValidator' staging/addresses.json)
export D_PARAMETER_POLICY_ID=$(jq -r '.mintingPolicies.DParameterPolicy' staging/addresses.json)
export PERMISSIONED_CANDIDATES_POLICY_ID=$(jq -r '.mintingPolicies.PermissionedCandidatesPolicy' staging/addresses.json)

# native token observability
export NATIVE_TOKEN_POLICY_ID='ada83ddd029614381f00e28de0922ab0dec6983ea9dd29ae20eef9b4'
Expand Down
7 changes: 3 additions & 4 deletions flake.lock

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

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

# Partner Chains deps
smart-contracts = {
url = "github:input-output-hk/partner-chains-smart-contracts/v6.1.0";
# Update to desired tag when ready for release
url = "github:input-output-hk/partner-chains-smart-contracts";
flake = false;
};
cardano-node = {
Expand Down
2 changes: 1 addition & 1 deletion mainchain-follower/db-sync-follower/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "db-sync-follower"
version = "0.1.0"
version = "1.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion mainchain-follower/main-chain-follower-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "main-chain-follower-api"
version = "0.0.1-dev"
version = "1.1.0"
authors = ["IOG"]
edition = "2021"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion mainchain-follower/main-chain-follower-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "main-chain-follower-cli"
version = "0.1.0"
version = "1.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion mainchain-follower/mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "main-chain-follower-mock"
version = "0.0.1-dev"
version = "1.1.0"
edition = "2021"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

in {
packages = {
inherit (smartContractsPkgs) sidechain-main-cli;
inherit (smartContractsPkgs) pc-contracts-cli;
inherit (cardanoPackages) cardano-node cardano-cli cardano-testnet;
inherit (dbSyncPackages) "cardano-db-sync:exe:cardano-db-sync";
kupo = cardanoExtraPkgs."kupo-${kupoVersion}";
Expand Down
8 changes: 4 additions & 4 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@
'';
}
{
name = "sidechain-main-cli";
name = "pc-contracts-cli";
help = "CLI to interact with Partner Chains Smart Contracts";
command = ''
${self'.packages.sidechain-main-cli}/bin/sidechain-main-cli $@
${self'.packages.pc-contracts-cli}/bin/pc-contracts-cli $@
'';
}
];
Expand All @@ -151,10 +151,10 @@
commands = commands ++ [
{
category = "Partner Chains";
name = "sidechain-main-cli";
name = "pc-contracts-cli";
help = "CLI to interact with Partner Chains Smart Contracts";
command = ''
${self'.packages.sidechain-main-cli}/bin/sidechain-main-cli $@
${self'.packages.pc-contracts-cli}/bin/pc-contracts-cli $@
'';
}
];
Expand Down
3 changes: 2 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "partner-chains-node"
version = "1.0.0"
version = "1.1.0"
description = "A reference implementation of a partner chain node"
authors = [ "IOG "]
homepage = "https://iohk.io/"
Expand Down Expand Up @@ -71,6 +71,7 @@ thiserror = { workspace = true }
time-source = { workspace = true }
derive-new = { workspace = true }
partner-chains-node-commands = { workspace = true }
envy = { workspace = true }

# These dependencies are used for the node template's RPCs
jsonrpsee = { workspace = true }
Expand Down
61 changes: 1 addition & 60 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
use sidechain_domain::{AssetName, MainchainAddress, PolicyId};
use sidechain_runtime::CrossChainPublic;
use sidechain_runtime::{opaque::SessionKeys, AccountId, Signature, WASM_BINARY};
use sidechain_runtime::{opaque::SessionKeys, AccountId, CrossChainPublic, Signature, WASM_BINARY};
use sp_core::{Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use sp_session_validator_management::MainChainScripts;
use std::str::FromStr;

// The URL for the telemetry server.
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

pub type ChainSpec = sc_service::GenericChainSpec;

pub enum EnvVarReadError {
Missing(String),
ParseError(String),
}

#[derive(Clone, Debug, PartialEq)]
pub struct AuthorityKeys {
pub session: SessionKeys,
Expand All @@ -41,53 +32,3 @@ where
pub fn runtime_wasm() -> &'static [u8] {
WASM_BINARY.expect("Runtime wasm not available")
}

pub fn from_var_or<T: FromStr>(var: &str, default: T) -> Result<T, EnvVarReadError> {
if let Ok(env_var_string) = std::env::var(var) {
env_var_string.parse::<T>().map_err(|_| {
EnvVarReadError::ParseError(format!(
"Can not interpret environment variable {}={} as {}",
var,
env_var_string,
std::any::type_name::<T>()
))
})
} else {
Ok(default)
}
}

pub fn from_var<T: FromStr>(var: &str) -> Result<T, EnvVarReadError> {
let env_var_string = std::env::var(var).map_err(|_| {
EnvVarReadError::Missing(format!("Environment variable {} cannot be empty.", var))
})?;

env_var_string.parse::<T>().map_err(|_| {
EnvVarReadError::ParseError(format!(
"Can not interpret environment variable {}={} as {}",
var,
env_var_string,
std::any::type_name::<T>(),
))
})
}

pub fn read_mainchain_scripts_from_env() -> Result<MainChainScripts, EnvVarReadError> {
let committee_candidate_address = from_var("COMMITTEE_CANDIDATE_ADDRESS")?;
let d_parameter_policy = from_var("D_PARAMETER_POLICY_ID")?;
let permissioned_candidates_policy = from_var::<PolicyId>("PERMISSIONED_CANDIDATES_POLICY_ID")?;
Ok(MainChainScripts {
committee_candidate_address,
d_parameter_policy,
permissioned_candidates_policy,
})
}

pub fn read_native_token_main_chain_scripts_from_env(
) -> Result<sp_native_token_management::MainChainScripts, EnvVarReadError> {
Ok(sp_native_token_management::MainChainScripts {
native_token_policy: from_var::<PolicyId>("NATIVE_TOKEN_POLICY_ID")?,
native_token_asset_name: from_var::<AssetName>("NATIVE_TOKEN_ASSET_NAME")?,
illiquid_supply_address: from_var::<MainchainAddress>("ILLIQUID_SUPPLY_VALIDATOR_ADDRESS")?,
})
}
18 changes: 10 additions & 8 deletions node/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::chain_spec::EnvVarReadError;
use crate::{
benchmarking::{inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder},
cli::{Cli, Subcommand},
Expand Down Expand Up @@ -42,22 +41,25 @@ impl SubstrateCli for Cli {
"staging" => staging::staging_config(),
"local" => testnet::local_testnet_config(),
"" => template_chain_spec::chain_spec(),
path => chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))
.map_err(|err| EnvVarReadError::ParseError(err.to_string())),
path => match chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path)) {
Ok(parsed) => Ok(parsed),
Err(err) => {
return Err(format!("Parsing chain spec file failed: {}", err.to_string()))
},
},
};

match maybe_chain_spec {
Ok(chain_spec) => Ok(Box::new(chain_spec)),
Err(EnvVarReadError::Missing(err)) => {
println!("{}", MISSING_ENV_VARIABLES_HELP);
Err(err)
Err(err) => {
println!("{}", INVALID_ENV_VARIABLES_HELP);
Err(format!("Reading configuration from environment failed: {}", err.to_string()))
},
Err(EnvVarReadError::ParseError(err)) => Err(err),
}
}
}

const MISSING_ENV_VARIABLES_HELP: &str = "Unable to start the node due to missing environment variables. This issue typically occurs when the node executable is launched directly. Instead, please use the `./partner-chains-cli start-node` command, which sets up all the necessary environment variables for you. This command also displays the complete node startup command, including the required environment variables, allowing you to use it directly if needed.";
const INVALID_ENV_VARIABLES_HELP: &str = "Unable to start the node due to missing or malformed environment variables. This issue typically occurs when the node executable is launched directly. Instead, please use the `./partner-chains-cli start-node` command, which sets up all the necessary environment variables for you. This command also displays the complete node startup command, including the required environment variables, allowing you to use it directly if needed.";

/// Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
Expand Down
Loading

0 comments on commit 8a8924f

Please sign in to comment.