-
Notifications
You must be signed in to change notification settings - Fork 378
Extrinsic v2 #1150
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
Extrinsic v2 #1150
Conversation
| const keyring = testingPairs({ type: 'ed25519' }, false); | ||
|
|
||
| describe('extrinsics', (): void => { | ||
| it('encodes extrinsic correctly (nobody)', (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I whacked this, technically a backwards incompatible change, however we have not had the nobody account in the system since poc-2 - so actually the test is bullsh*t. (inherents are now just unsigned, not with a nobody sig)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just remove it, then? Are we still supporting POC-2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is why the test was removed. (It relied on an unsupported all-0 sig)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, right, monday morning comment...
| Method.injectMethods(extrinsics); | ||
|
|
||
| // detect the extrinsic version in-use based on the last block | ||
| const lastBlock: SignedBlock = await this._rpcCore.chain.getBlock().toPromise(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now determine the extrinsic version from the chain - basically, based on the last block, we pull out the version from contained extrinsics and then use this in any future construction of this type.
| | [[SessionKeys]] | Wrapper for the session and authority ids | | ||
| | [[SetIndex]] | Set index, implemented as a [[U32]] | | ||
| | [[SignaturePayload]] | A signing payload for an [[Extrinsic]]. For the final encoding, it is variable length based on the contents included | | ||
| | [[SignaturePayloadRaw]] | A version of the [[SignaturePayload]] where it doesn't rely on [[Method]] with metadata, rather it treats the values as a raw byte stream | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The raw variant disappeared. The normal payload is now the same as the raw variant. We cannot continue to add special cases - this has a very limited impact, since it is just signers that actually use it. (extensions & internally to sumittable)
| * @description A type extends the Base class, when it holds a value | ||
| */ | ||
| export default class Base<T> { | ||
| export default abstract class Base<T extends Codec> implements Codec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make extension less noisy, the base defaults have been included into Base. Anything that extends it have been adjusted to remove duplication. (This happened since I really didn't want to add more boilerplate to the new classes, so rather cleaned up all)
| @@ -0,0 +1,67 @@ | |||
| // Copyright 2017-2019 @polkadot/types authors & contributors | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a move of the file.
| */ | ||
| public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, nonce: AnyNumber, era: Uint8Array | IExtrinsicEra): Extrinsic { | ||
| this.raw.addSignature(signer, signature, nonce, era); | ||
| public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: Uint8Array | string): Extrinsic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incompatible change. Signature now takes the actual encoded payload, this makes it much easier to support multiple versions all around
* Add SignerPayload and signPayload for Signer * Submittables use signPayload * Don't pass version on deprecated interface * Update after all e2e tx tests passes * Comment around payload generation * Adjust blocktime to default (nice round 50 block eras) * Fix calc * Re-add test comment
| }); | ||
| }); | ||
|
|
||
| describe('V2', (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new though - a copy of the V1 test adjusted for V2
amaury1093
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Lgtm overall
Co-Authored-By: Amaury Martiny <[email protected]>
Co-Authored-By: Amaury Martiny <[email protected]>
|
WIP until renames (suggested above) done. EDIT: And done, applied all the options work in 680a38b |
* Extrinsic v2
* Save after last move of files
* Signature V2
* Rework signature decoding
* Simplify V1 and V2 underlying impl.
* Detect chain extrinsic version
* SignaturePayload
* remove Raw payload variant link (Payload is now raw)
* Remove v2 comments referring to v1 data
* Pass isSigned to Extrinsic{V1, V2}
* Cleanup era injection
* It flows :)
* Add SignerPayload and signPayload for Signer (polkadot-js#1152)
* Add SignerPayload and signPayload for Signer
* Submittables use signPayload
* Don't pass version on deprecated interface
* Update after all e2e tx tests passes
* Comment around payload generation
* Adjust blocktime to default (nice round 50 block eras)
* Fix calc
* Re-add test comment
* Update packages/api/src/types.ts
Co-Authored-By: Amaury Martiny <[email protected]>
* Update packages/types/src/primitive/BalanceCompact.ts
Co-Authored-By: Amaury Martiny <[email protected]>
* Backwards compatibility for current in-store signers
* Apply options suggestions
* Add missing Compact params (linting)
* Extrinsic v2
* Save after last move of files
* Signature V2
* Rework signature decoding
* Simplify V1 and V2 underlying impl.
* Detect chain extrinsic version
* SignaturePayload
* remove Raw payload variant link (Payload is now raw)
* Remove v2 comments referring to v1 data
* Pass isSigned to Extrinsic{V1, V2}
* Cleanup era injection
* It flows :)
* Add SignerPayload and signPayload for Signer (polkadot-js#1152)
* Add SignerPayload and signPayload for Signer
* Submittables use signPayload
* Don't pass version on deprecated interface
* Update after all e2e tx tests passes
* Comment around payload generation
* Adjust blocktime to default (nice round 50 block eras)
* Fix calc
* Re-add test comment
* Update packages/api/src/types.ts
Co-Authored-By: Amaury Martiny <[email protected]>
* Update packages/types/src/primitive/BalanceCompact.ts
Co-Authored-By: Amaury Martiny <[email protected]>
* Backwards compatibility for current in-store signers
* Apply options suggestions
* Add missing Compact params (linting)
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Update: E2E test pass with #1152 (split, but to be merged into this branch)
What is does, note the
0x82identifier -calling author_submitAndWatchExtrinsic {"id":6,"jsonrpc":"2.0","method":"author_submitAndWatchExtrinsic","params":["0x290282ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22baea13d7c1f455e6cb9a40775704d5370dcc56968f183050c6e3d628c6e5130329018b16a742ce0e3aca7b6dc803f5f162fde040f3505ab4ed8c4bc5c8476a0e0000000500ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"]}Included -
received {"jsonrpc":"2.0","result":{"block":{"extrinsics":["0x2002020003665f345d","0x14020c00a538","0x290282ff90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22baea13d7c1f455e6cb9a40775704d5370dcc56968f183050c6e3d628c6e5130329018b16a742ce0e3aca7b6dc803f5f162fde040f3505ab4ed8c4bc5c8476a0e0000000500ffe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4ee5c0"],"header":{"digest":{"logs":["0x06617572612091ba880f00000000","0x05617572610101fb876aeb4427ab425491acb6d1464e4af2bf45ea7109ce93a3b06ad47fe633c746341c415e7f9b04e8b36bcef57bf87845c0f620c3df157d9fef951fd4e4af02"]},"extrinsicsRoot":"0x41ea404ed73b691335cae82803a5a437e60d8423d2ccfc88631ca0787c3a0ed0","number":"0xe2a","parentHash":"0x3d2d91b686ad497484d9be25c7da24d4b733c08732ff8ffb155f151c3ca19618","stateRoot":"0x23fdc1b79b358b246f894bebe3f4178267ecca8362b66e61aa95dc0832477c9d"}},"justification":null},"id":8}logging -