Skip to content

Commit 7fa319b

Browse files
LGLOAmbientTea
andauthored
feat: use Ogmios to get current D-parameter and Permissioned Candidates in setup-main-chain-state wizard (#794)
Co-authored-by: Nikolaos Dymitriadis <[email protected]>
1 parent d228760 commit 7fa319b

File tree

10 files changed

+348
-343
lines changed

10 files changed

+348
-343
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.
1717

1818
## Changed
1919

20+
2021
* `prepare-configuration` and `create-chain-spec` wizards are updated to setup `governedMap.MainChainScripts` in the chain-spec file.
22+
* `setup-main-chain-state` wizard uses Ogmios and `offchain` crate for getting the current D-parameter and Permissioned Candidates instead of invoking `<node-executable> ariadne-parameters` command.
2123
* `prepare-configuration` wizard suggests payment signing key hash as governance authority if there is no value in chain config stored so far.
2224
* Automatically create required index on `tx_out` table `address` column. Constructor signatures have changed - this change is not source compatible.
2325
* BREAKING: Wizards are not generating keys nor looking for them in `<base_path>/chains/partner_chains_template` but use `<base_path>` instead.

dev/local-environment/configurations/wizard/governance-authority/entrypoint.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,14 @@ echo "Setting up main chain state..."
145145
expect <<EOF
146146
spawn ./partner-chains-node wizards setup-main-chain-state
147147
set timeout 300
148-
expect "DB-Sync Postgres connection string (postgresql://postgres-user:postgres-password@localhost:5432/cexplorer)"
149-
send "postgresql://postgres:$POSTGRES_PASSWORD@postgres:$POSTGRES_PORT/cexplorer\r"
150-
expect "Do you want to set/update the permissioned candidates on the main chain with values from configuration file? (y/N)"
151-
send "y\r"
152148
expect "Ogmios protocol (http/https)"
153149
send "\r"
154150
expect "Ogmios hostname (ogmios)"
155151
send "\r"
156152
expect "Ogmios port (1337)"
157153
send "\r"
154+
expect "Do you want to set/update the permissioned candidates on the main chain with values from configuration file? (y/N)"
155+
send "y\r"
158156
expect "path to the payment signing key file (/keys/funded_address.skey)"
159157
send "\r"
160158
expect "Do you want to set/update the D-parameter on the main chain? (y/N)"

toolkit/partner-chains-cli/src/io.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ use crate::config::ServiceConfig;
22
use crate::ogmios::{OgmiosRequest, OgmiosResponse, ogmios_request};
33
use anyhow::{Context, anyhow};
44
use ogmios_client::jsonrpsee::{OgmiosClients, client_for_url};
5-
use partner_chains_cardano_offchain::d_param::UpsertDParam;
5+
use partner_chains_cardano_offchain::d_param::{GetDParam, UpsertDParam};
66
use partner_chains_cardano_offchain::init_governance::InitGovernance;
7-
use partner_chains_cardano_offchain::permissioned_candidates::UpsertPermissionedCandidates;
7+
use partner_chains_cardano_offchain::permissioned_candidates::{
8+
GetPermissionedCandidates, UpsertPermissionedCandidates,
9+
};
810
use partner_chains_cardano_offchain::register::{Deregister, Register};
911
use partner_chains_cardano_offchain::scripts_data::GetScriptsData;
1012
use sp_core::offchain::Timestamp;
@@ -20,9 +22,11 @@ pub trait IOContext {
2022
/// It should implement all the required traits for offchain operations
2123
type Offchain: GetScriptsData
2224
+ InitGovernance
25+
+ GetDParam
2326
+ UpsertDParam
2427
+ Deregister
2528
+ Register
29+
+ GetPermissionedCandidates
2630
+ UpsertPermissionedCandidates;
2731

2832
fn run_command(&self, cmd: &str) -> anyhow::Result<String>;

toolkit/partner-chains-cli/src/permissioned_candidates.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ impl Display for PermissionedCandidateKeys {
2424
}
2525
}
2626

27-
impl From<&ParsedPermissionedCandidatesKeys> for PermissionedCandidateKeys {
28-
fn from(value: &ParsedPermissionedCandidatesKeys) -> Self {
27+
impl From<&sidechain_domain::PermissionedCandidateData> for PermissionedCandidateKeys {
28+
fn from(value: &sidechain_domain::PermissionedCandidateData) -> Self {
2929
Self {
30-
sidechain_pub_key: sp_core::bytes::to_hex(&value.sidechain.0, false),
31-
aura_pub_key: sp_core::bytes::to_hex(&value.aura.0, false),
32-
grandpa_pub_key: sp_core::bytes::to_hex(&value.grandpa.0, false),
30+
sidechain_pub_key: sp_core::bytes::to_hex(&value.sidechain_public_key.0, false),
31+
aura_pub_key: sp_core::bytes::to_hex(&value.aura_public_key.0, false),
32+
grandpa_pub_key: sp_core::bytes::to_hex(&value.grandpa_public_key.0, false),
3333
}
3434
}
3535
}
@@ -72,6 +72,16 @@ impl TryFrom<&PermissionedCandidateKeys> for ParsedPermissionedCandidatesKeys {
7272
}
7373
}
7474

75+
impl From<&ParsedPermissionedCandidatesKeys> for sidechain_domain::PermissionedCandidateData {
76+
fn from(value: &ParsedPermissionedCandidatesKeys) -> Self {
77+
Self {
78+
sidechain_public_key: sidechain_domain::SidechainPublicKey(value.sidechain.0.to_vec()),
79+
aura_public_key: sidechain_domain::AuraPublicKey(value.aura.0.to_vec()),
80+
grandpa_public_key: sidechain_domain::GrandpaPublicKey(value.grandpa.0.to_vec()),
81+
}
82+
}
83+
}
84+
7585
fn parse_ecdsa(value: &str) -> Option<ecdsa::Public> {
7686
let bytes = sp_core::bytes::from_hex(value).ok()?;
7787
Some(ecdsa::Public::from(<[u8; 33]>::try_from(bytes).ok()?))

0 commit comments

Comments
 (0)