Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace default authorize_upgrade call index to 0x02 #62

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# POLKADOT_HTTP=http://localhost:9933
# POLKADOT_WS=ws://localhost:9944
# PARACHAIN_PALLET_ID=0x01
# AUTHORIZE_UPGRADE_PREFIX=0x03
# AUTHORIZE_UPGRADE_PREFIX=0x02
2 changes: 1 addition & 1 deletion README_src.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ include::doc/usage_get.adoc[]
include::doc/usage_info.adoc[]
----

NOTE: By default, the ID for the Parachain pallet is expected to be `0x01` and the call ID for `authorize_upgrade` is expected to be `0x03`.
NOTE: By default, the ID for the Parachain pallet is expected to be `0x01` and the call ID for `authorize_upgrade` is expected to be `0x02`.
This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to the ID of your parachain pallet and the `AUTHORIZE_UPGRADE_PREFIX` to the ID of your choice.

=== Command: version
Expand Down
10 changes: 8 additions & 2 deletions libs/substrate-runtime-proposal-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ type Prefix = (u8, u8);
/// The PREFIX is prepended to the data before hashing
pub const PREFIX_SYSTEM_SETCODE: Prefix = (0x00, 0x03);
const PARACHAIN_PALLET_ID_ENV: &str = "PARACHAIN_PALLET_ID";
const DEFAULT_PARACHAIN_PALLET_ID: &str = "0x01";
const AUTHORIZE_UPGRADE_PREFIX_ENV: &str = "AUTHORIZE_UPGRADE_PREFIX";
const DEFAULT_AUTHORIZE_UPGRADE_PREFIX: &str = "0x02";

/// This struct is a container for whatever we calculated.
#[derive(Debug)]
Expand Down Expand Up @@ -62,8 +64,12 @@ pub fn get_system_setcode(wasm_blob: &[u8]) -> CalllHash {
}

pub fn get_parachainsystem_authorize_upgrade(wasm_blob: &[u8]) -> CalllHash {
let s1 = env::var(PARACHAIN_PALLET_ID_ENV).unwrap_or_else(|_| String::from("0x01")).replace("0x", "");
let s2 = env::var(AUTHORIZE_UPGRADE_PREFIX_ENV).unwrap_or_else(|_| String::from("0x03")).replace("0x", "");
let s1 = env::var(PARACHAIN_PALLET_ID_ENV)
.unwrap_or_else(|_| String::from(DEFAULT_PARACHAIN_PALLET_ID))
.replace("0x", "");
let s2 = env::var(AUTHORIZE_UPGRADE_PREFIX_ENV)
.unwrap_or_else(|_| String::from(DEFAULT_AUTHORIZE_UPGRADE_PREFIX))
.replace("0x", "");
let decoded1 = <[u8; 1]>::from_hex(s1).expect("Decoding failed");
let decoded2 = <[u8; 1]>::from_hex(s2).expect("Decoding failed");

Expand Down