Skip to content

Conversation

@jacogr
Copy link
Member

@jacogr jacogr commented Jul 20, 2019

Update: E2E test pass with #1152 (split, but to be merged into this branch)

What is does, note the 0x82 identifier -

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 -

Transaction status: Finalized

Completed at block hash 
  0xcf96dddee6835dcd40f474a1de91aad216d4fdb627431c6edfcd7e759210585c

Events:
    	 {"ApplyExtrinsic":2} : balances.Transfer ["5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y","5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw",12345,1000000000000]
    	 {"ApplyExtrinsic":2} : system.ExtrinsicSuccess []

@jacogr jacogr added the WIP Work in Progress label Jul 20, 2019
const keyring = testingPairs({ type: 'ed25519' }, false);

describe('extrinsics', (): void => {
it('encodes extrinsic correctly (nobody)', (): void => {
Copy link
Member Author

@jacogr jacogr Jul 20, 2019

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)

Copy link
Contributor

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?

Copy link
Member Author

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)

Copy link
Contributor

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();
Copy link
Member Author

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 |
Copy link
Member Author

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 {
Copy link
Member Author

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
Copy link
Member Author

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 {
Copy link
Member Author

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 => {
Copy link
Member Author

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

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Nice! Lgtm overall

@jacogr jacogr added the WIP Work in Progress label Jul 22, 2019
@jacogr
Copy link
Member Author

jacogr commented Jul 22, 2019

WIP until renames (suggested above) done.

EDIT: And done, applied all the options work in 680a38b

@jacogr jacogr removed the WIP Work in Progress label Jul 22, 2019
@jacogr jacogr merged commit 50a2314 into master Jul 22, 2019
@jacogr jacogr deleted the kg-extrinsic-v2 branch July 22, 2019 15:08
ianhe8x pushed a commit to plugblockchain/api.js that referenced this pull request Jul 30, 2019
* 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)
ianhe8x pushed a commit to plugblockchain/api.js that referenced this pull request Jul 31, 2019
* 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)
@polkadot-js-bot
Copy link

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support v2 Extrinsic format Support optional extrinsic “tip” enum

5 participants