From 846ce8debd7dec9ab63fa0f6eb32ae5b17ca51df Mon Sep 17 00:00:00 2001 From: Chevdor Date: Fri, 23 Jun 2023 09:05:08 +0200 Subject: [PATCH 1/6] Fix location of the version --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index a459215..d5e8ff9 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ -VERSION := `toml get cli/Cargo.toml package.version | jq -r` -export TAG:=`toml get cli/Cargo.toml "package.version" | jq -r .` +VERSION := `toml get Cargo.toml workspace.package.version | jq -r` +export TAG:=`toml get Cargo.toml "workspace.package.version" | jq -r .` # List available commands _default: From 2c055775cb84cdb56fe6bde8ce82da1c65c26d8a Mon Sep 17 00:00:00 2001 From: Chevdor Date: Fri, 23 Jun 2023 16:51:09 +0200 Subject: [PATCH 2/6] Fix readme --- README.md | 10 ++++++++++ doc/demos.adoc | 15 ++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0770db5..33c2088 100644 --- a/README.md +++ b/README.md @@ -47,26 +47,36 @@ This is a great way to have a peek at what the runtime can do. You may however w ## Demos +### Get a runtime +
demo get
subwasm get
+### info command +
demo info
subwasm info
+### show command +
demo meta
subwasm show
+### meta command +
demo meta
subwasm meta
+### diff command +
demo diff
subwasm diff
diff --git a/doc/demos.adoc b/doc/demos.adoc index ec20ef0..955d98e 100644 --- a/doc/demos.adoc +++ b/doc/demos.adoc @@ -2,17 +2,22 @@ :imagesdir: ./scripts/demos/gif -.Get a runtime +=== Get a runtime + image::demo-get.gif[title="subwasm get"] -.info command +=== info command + image::demo-info.gif[title="subwasm info"] -.show command +=== show command + image::demo-meta.gif[title="subwasm show"] -.meta command +=== meta command + image::demo-meta.gif[title="subwasm meta"] -.diff command +=== diff command + image::demo-diff.gif[title="subwasm diff"] From a8aaa6919b5d92533f857fc40a6c028d2c580310 Mon Sep 17 00:00:00 2001 From: Chevdor Date: Mon, 26 Jun 2023 10:04:25 +0200 Subject: [PATCH 3/6] Remove deprecated function --- libs/substrate-runtime-proposal-hash/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libs/substrate-runtime-proposal-hash/src/lib.rs b/libs/substrate-runtime-proposal-hash/src/lib.rs index cef7225..8b2dea2 100644 --- a/libs/substrate-runtime-proposal-hash/src/lib.rs +++ b/libs/substrate-runtime-proposal-hash/src/lib.rs @@ -52,17 +52,6 @@ pub fn get_result(prefix: Prefix, buffer: &[u8]) -> Result { }) } -/// Calculate the proposal hash -/// -/// # Arguments -/// * `wasm_blob` - The WASM blob -/// # Returns -/// * `CalllHash` - The hash of the proposal as calculated on chain -/// @deprecated -pub fn get_proposal_hash(wasm_blob: &[u8]) -> Result { - get_call_hash(PREFIX_SYSTEM_SETCODE, wasm_blob) -} - /// Calculate the proposal hash which is system.setCode /// /// # Arguments From 389f1932a43bca1763ec4627a7e19511dd06175a Mon Sep 17 00:00:00 2001 From: Chevdor Date: Tue, 27 Jun 2023 19:06:24 +0200 Subject: [PATCH 4/6] Ignore executables --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5eecd01..747cadc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ metadata.* .vscode docs + +cli/executables From 243b27e5d76af72e7d2dbb2957a8d772a5993f0e Mon Sep 17 00:00:00 2001 From: Chevdor Date: Wed, 28 Jun 2023 15:09:40 +0200 Subject: [PATCH 5/6] WIP on a template for the diffs --- templates/diff/diff.md.tera | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 templates/diff/diff.md.tera diff --git a/templates/diff/diff.md.tera b/templates/diff/diff.md.tera new file mode 100644 index 0000000..15ebb0c --- /dev/null +++ b/templates/diff/diff.md.tera @@ -0,0 +1,73 @@ +# Subwasm Differ Report + + +{% for c in changes.changes %} + +{% set palletsAdded = c.Pallets | filter(attribute="Added") %} +{% set palletsChanged = c.Pallets | filter(attribute="Changed") %} +{% set palletsRemoved = c.Pallets | filter(attribute="Removed") %} + +{# {{ c | json_encode }} +{{ p.Changed | json_encode }} +#} +## Pallets Removed +{% if palletsRemoved | length %} +{% for p in palletsRemoved %} + +{% set pallet_id = p.Removed[0] %} +{% set pallet_a = changes.runtime_a.pallets[pallet_id] %} +{% set content = p.Removed[1] %} +### {{pallet_a.name}} +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + + +## Pallets Added +{% if palletsAdded | length %} +{% for p in palletsAdded %} + +{% set pallet_id = p.Added[0] %} +{% set pallet_b = changes.runtime_b.pallets[pallet_id] %} +{% set content = p.Added[1] %} + +### {{pallet_b.name}} + +``` +{{ pallet_b | json_encode(pretty=true) }} +``` +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + + +## Pallets Changed + +{% if palletsChanged | length %} +{% for p in palletsChanged %} + +{% set pallet_id = p.Changed[0] %} +{% set pallet_a = changes.runtime_a.pallets[pallet_id] %} +{% set pallet_b = changes.runtime_b.pallets[pallet_id] %} +{% set content = p.Changed[1] %} + +### {{pallet_a.name}} +{% endfor %} +{% else %} +No pallet removed +{% endif %} +{# +#} + +{% endfor %} + +## Analysis + +- tx bump: {{ require_transaction_version_bump }} +- compat : {{ compatible }} From ac20195ae3c9e571c9d83afeb6b412b44f785bab Mon Sep 17 00:00:00 2001 From: Chevdor Date: Wed, 28 Jun 2023 15:12:11 +0200 Subject: [PATCH 6/6] Fix tests --- libs/substrate-runtime-proposal-hash/src/lib.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libs/substrate-runtime-proposal-hash/src/lib.rs b/libs/substrate-runtime-proposal-hash/src/lib.rs index 8b2dea2..c821ec7 100644 --- a/libs/substrate-runtime-proposal-hash/src/lib.rs +++ b/libs/substrate-runtime-proposal-hash/src/lib.rs @@ -81,17 +81,6 @@ fn get_call_hash(prefix: Prefix, wasm_blob: &[u8]) -> Result { mod prop_hash_tests { use super::*; - #[test] - fn test_proposal_hash() { - assert_eq!( - get_proposal_hash(&[1, 2, 42]).expect("Failed getting a hash"), - [ - 174, 123, 79, 240, 254, 106, 147, 26, 65, 61, 41, 84, 181, 102, 24, 182, 128, 135, 188, 31, 135, 187, - 99, 34, 143, 35, 120, 100, 246, 90, 186, 106 - ] - ); - } - #[test] fn test_call_hash() { assert_eq!( @@ -146,7 +135,7 @@ mod prop_hash_tests { #[test] fn test_hash_length() { - assert_eq!(32, get_proposal_hash(&[0]).expect("Failed getting a hash").len()); + assert_eq!(32, get_call_hash((0, 0), &[0]).expect("Failed getting a hash").len()); } #[test]