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

diff template #80

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ metadata.*

.vscode
docs

cli/executables
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<figure>
<img src="./scripts/demos/gif/demo-get.gif" alt="demo get" />
<figcaption>subwasm get</figcaption>
</figure>

### info command

<figure>
<img src="./scripts/demos/gif/demo-info.gif" alt="demo info" />
<figcaption>subwasm info</figcaption>
</figure>

### show command

<figure>
<img src="./scripts/demos/gif/demo-meta.gif" alt="demo meta" />
<figcaption>subwasm show</figcaption>
</figure>

### meta command

<figure>
<img src="./scripts/demos/gif/demo-meta.gif" alt="demo meta" />
<figcaption>subwasm meta</figcaption>
</figure>

### diff command

<figure>
<img src="./scripts/demos/gif/demo-diff.gif" alt="demo diff" />
<figcaption>subwasm diff</figcaption>
Expand Down
15 changes: 10 additions & 5 deletions doc/demos.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
24 changes: 1 addition & 23 deletions libs/substrate-runtime-proposal-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ pub fn get_result(prefix: Prefix, buffer: &[u8]) -> Result<SrhResult> {
})
}

/// 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<CalllHash> {
get_call_hash(PREFIX_SYSTEM_SETCODE, wasm_blob)
}

/// Calculate the proposal hash which is system.setCode
///
/// # Arguments
Expand Down Expand Up @@ -92,17 +81,6 @@ fn get_call_hash(prefix: Prefix, wasm_blob: &[u8]) -> Result<CalllHash> {
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!(
Expand Down Expand Up @@ -157,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]
Expand Down
73 changes: 73 additions & 0 deletions templates/diff/diff.md.tera
Original file line number Diff line number Diff line change
@@ -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 }}