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

Rework codecs & extrinsics for poc-3 compatibility #161

Closed
jacogr opened this issue Sep 19, 2018 · 11 comments
Closed

Rework codecs & extrinsics for poc-3 compatibility #161

jacogr opened this issue Sep 19, 2018 · 11 comments
Assignees

Comments

@jacogr
Copy link
Member

jacogr commented Sep 19, 2018

I cannot put it more succinctly :)

  • Remote extrinsics & storage (the latter will still contain some, e.g. :code, basically all these Extract well known keys into a single place paritytech/substrate#764)
  • Pull storage, extrinsics and events (this is new) from state_getMeta
  • Fixup encoders and do it properly - currently they are all-over, some in primitives, some in params
  • Make everything work....
  • ... I missed some stuff

cc @amaurymartiny :)

@jacogr jacogr added this to To Do in @polkadot{.js} via automation Sep 19, 2018
@amaury1093 amaury1093 self-assigned this Sep 19, 2018
@amaury1093
Copy link
Contributor

Yeah, I'll work on this.

@jacogr
Copy link
Member Author

jacogr commented Sep 19, 2018

This could be useful - #149

No need to use anything in there, but it is probably worth a look - it makes some attempt for saner Json/u8a encoding/decoding.

Either way, the work here will replace the above, so it will never be merged as-is, nor make much progress form where it is. Feel free to adapt, copy or completely ignore as a science experiment.

@jacogr
Copy link
Member Author

jacogr commented Sep 19, 2018

New extrinsics format for poc-3 - https://github.com/paritytech/wiki/blob/master/Extrinsic.md

The basics are the same, version header added, order somewhat changed. More importantly, it is now documented.

@jacogr
Copy link
Member Author

jacogr commented Sep 21, 2018

From Gav -

"
i'm changing codec to include a compact integer encoding
since trie nodes are currently way too inefficient with the u32 len encoding
here's the spec:

// compact encoding:
// 0b00 00 00 00 / 00 00 00 00 / 00 00 00 00 / 00 00 00 00

// (0 ... 2**6 - 1)		(u8)
//   00 xx xx xx		

// (2**6 ... 2**14 - 1)	(u8, u16)													
//   01 yy yy yy / yy yy yy yy					

// (2**14 ... 2**30 - 1)	(u16, u32)							
//   10 zz zz zz / zz zz zz zz / zz zz zz zz / zz zz zz zz			

// (2**30 ... 2**536 - 1)	(u32, u64, u128, U256, U512, U520)		
//   11 nn nn nn [ / zz zz zz zz ]{4 + n}									

"

@jacogr
Copy link
Member Author

jacogr commented Sep 30, 2018

UInt encoding paritytech/substrate#847

@amaury1093
Copy link
Contributor

amaury1093 commented Oct 8, 2018

Putting here to have a written record of what's been discussed on Riot. It must be done in the following order.

  • 1. Add a static decode method on all types, which takes any input of any type, and decodes it correctly to the type's base type (i.e. for Text, decode() returns a string).
  • 2. Remove fromJSON and fromU8a from all types, create them only with constructor.
    • The constructor will just be: super(MyType.decode(value));
  • 3. Remove Base class, let all types extend directly JS types (e.g. Moment extends Date, Text extends String...)
  • 4. Replace Base with a Codec interface, which all types need to implement, which basically is
interface Codec {
  static decode(input: any): any;
  encodedLength: number;
  toHex(): string;
  toJSON(): any;
  toString(): string;
  toU8a(): Uint8Array;
}

@jacogr
Copy link
Member Author

jacogr commented Oct 8, 2018

Add toString() - this is quite useful in display (UI only uses this - although I suppose it doesn't need to be on the interface since it is part of base "Object")

@jacogr jacogr mentioned this issue Oct 9, 2018
@ltfschoen
Copy link
Contributor

@amaurymartiny what branch will you be using to work on it?

@amaury1093
Copy link
Contributor

@ltfschoen It's not a one branch effort, Jaco and I have been creating small PRs all the way to slowly refactor all stuff, see all the linked PRs above.

All PRs that are related to this refactoring have a "Related #161" message.

@jacogr
Copy link
Member Author

jacogr commented Nov 14, 2018

Closing. Feature-complete.

@jacogr jacogr closed this as completed Nov 14, 2018
@polkadot{.js} automation moved this from To Do to Done Nov 14, 2018
@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

No branches or pull requests

4 participants