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

Update to latest scale-codec & V13 type definitions + metadata #41

Merged
merged 13 commits into from
Oct 11, 2021

Conversation

insipx
Copy link
Contributor

@insipx insipx commented Aug 31, 2021

This should hopefully be one of the last updates before type-decoding lands in Substrate proper via scale-info. Once scale-info is fully functional in substrate proper it can be integrated into Desub and legacy types kept in JSON can be frozen for historical purposes.

Checklist of work left for this PR:

  • support "_fallback" type identifier in JSON
  • Add tests for metadata version V13 and V14
  • Fix failing extrinsic tests
  • run against newer KSM chain before merging into substrate-archive
  • Consider using obake for converting between different metadata versions

closes #40

NotFound(String),
#[error("Could not parse {0} into type")]
TypeError(String),
#[error("type is not possible in the context of rust")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be more specific

// if an enum is an array, it's a unit enum (stateless)
rust_enum.push(unit.as_str().expect("Will be string according to polkadot-js defs").to_string())
fn parse_enum(value: &Value) -> Result<RustTypeMarker, Error> {
if value.is_array() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Match

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting! Let me know when it's ready for a full review. :)



The goal of TxDecoder is to be a handy CLI tool for decoding extrinsics/storage that exist in an archive SQL database.
- Decode all extrinsics of a certain spec (one or multiple or every), and return all those that were not succesful
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"spec"? Spec version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, spec version. The idea being that we can debug by runtime-version instead of having a ridiculous amount of tests in integration_tests

bin/tx-decoder/src/main.rs Outdated Show resolved Hide resolved
@insipx insipx marked this pull request as draft September 3, 2021 16:10
@insipx insipx mentioned this pull request Sep 6, 2021
77 tasks
@insipx insipx changed the title Update to v14 Update to latest scale-codec & V13 type definitions + metadata Oct 4, 2021
@insipx insipx marked this pull request as ready for review October 11, 2021 11:45
@insipx
Copy link
Contributor Author

insipx commented Oct 11, 2021

#42 is a continuation of this PR, most of the bugfixes are in that PR

This PR is mostly fixing around metadata and stuff. #42 will merge into this one before being merged into master

The reason for the split is that this PR is gigantic and has alot of changes that don't make it in #42 (like the addition of a legacy core crate that is deleted in #42). This PR mostly just updated the dependencies, and fixed version bugs from the last time desub was updated.

* make tx-decoder actual cli app

* huge refactoring to consolidate cursor and data states

* formatting

* clippy

* progress, missing an increment somewhere causing signatures to fail decoding

* some parts of incrementing the cursor is made clearer by DecodeState

* make Extrinsic bytes into an iterator, fix more extrinsics in 1020

* fix bug in Vec decoding

* all of 1020 decodes

* fix all tests

* Decode up to 1050

* fix spec 1062

* 2008 decodes

* fix definition for ConsensusEngineId

* some upgrades to tx decoder

* rework tx-decoder to use previous spec version

when blocks transition from runtimes, the spec will be `next` but the block extrinsics
still use previous spec version

* mutex -> rwlock

* fix sanitization, v12 metadata conversion

- use index in metadata rather than enumerater() iterator
- fix type name sanitization to support <T as Trait<\w>> and <T as
  Config<\w>>

* Add tx_decoder to logs

* fix runtimes, number => version

* do_decode decides on decode_length independently

* remove do_decode in favor of decode

do_decode is no longer needed since we can inspect the decode length
independently.

* fix v12, add v13 metadata

* Add bitvec type to `SubstrateTypes`

* update v11 to scale-codec 2

* update v9 to scale-codec 2

* update v8 to scale-codec 2

* use one DecodeDifferent from frame-metadata

* remove dependency on legacy sp-core

* update codec to 2 for extras

* Add bitvec type

remove not-used version7 metadata

* Update core/src/decoder.rs

* Update core/src/decoder.rs

* some cleanup

* Update core/src/decoder.rs

* log::error -> println

* check for upgrade block 0

* check some

* fix santiziation of types with empty generic, <()>

* remove all extrinsic integration tests

* fix remaining integration tests

* fix tests/clippy lints

* remove solved todos

* add back unused

* add test for ChunkedExtrinsic

* remove println from test

* remove unused RustTypeMarker variant 'String'

* remove 'impossible' types

* remove more impossible types

* fix tests

* fix comment

* add westend, centrifuge and rococo to FromStr impl

* FromStr should allow for custom chains

* add docs about upgrade blocks

* docs

* Update README.md

fix release docs

* Update README.md

* Update bin/tx-decoder/src/queries.rs

Co-authored-by: Tarik Gul <[email protected]>

* Update bin/tx-decoder/src/queries.rs

Co-authored-by: Tarik Gul <[email protected]>

* Update bin/tx-decoder/src/queries.rs

Co-authored-by: Tarik Gul <[email protected]>

* rustfmt

* minus v14 for now

* add StorageKey definition

* add readme comment about StorageKey

* choose simplest representations for substrate_types

* rusfmt

Co-authored-by: Tarik Gul <[email protected]>
@insipx insipx merged commit 1c7b43f into master Oct 11, 2021
@insipx insipx deleted the insipx/update branch October 11, 2021 12:24
@insipx insipx restored the insipx/update branch October 11, 2021 12:24
@insipx insipx deleted the insipx/update branch October 20, 2021 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade parity-scale-codec dependency to version >=2
2 participants