-
Notifications
You must be signed in to change notification settings - Fork 151
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
feat: add era
to blocks/{blockId}
response for extrinsics
#685
Changes from 8 commits
8b9cba6
122f376
90c0903
ac049f1
294b250
c01bb8f
602852b
91400cc
dd32594
1cbba06
2bab240
39f08f3
9f85f45
29425d8
c335892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1736,6 +1736,8 @@ components: | |
format: hex | ||
info: | ||
$ref: '#/components/schemas/RuntimeDispatchInfo' | ||
era: | ||
$ref: '#/components/schemas/GenericExtrinsicEra' | ||
events: | ||
type: array | ||
description: An array of `SanitizedEvent`s that occurred during extrinsic | ||
|
@@ -1793,6 +1795,23 @@ components: | |
trieIndex: | ||
type: string | ||
format: unsignedInteger | ||
GenericExtrinsicEra: | ||
type: object | ||
description: | | ||
The return value for eraInfo can either be `mortalEra`, or `immortalEra` and is represented as an enum in substrate. `immortalEra` meaning | ||
the transaction is valid forever. `mortalEra` consists of a tuple containing a period and phase. | ||
ex: `"{"mortalEra": ["64", "11"]}"`. The Period is the period of validity from the block hash found in the signing material. | ||
The Phase is the period that this transaction's lifetime begins (and, importantly, | ||
implies which block hash is included in the signature material). | ||
properties: | ||
mortalEra: | ||
type: string | ||
nullable: true | ||
immortalEra: | ||
type: string | ||
nullable: true | ||
default: ['0x00'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand this correctly, this is the only possible value for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes totally, correct. I agree it should just be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One way to represent the return types I guess could be:
or
(with a typescript type like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's ok for this PR. Perhaps add an issue to investigate James' suggestion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet, so I added a concise description for I do think for now it might be wise to keep the response as close to substrate as possible. The idea being if anything were to change in substrate (low likely hood), the little logic there is for getting |
||
example: "{\"immmortalEra\": ['0x00']}" | ||
TarikGul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NodeNetwork: | ||
type: object | ||
properties: | ||
|
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.
Hmm, this is a bit dense to parse. Is this correct? The first parameter,
64
in the example, is thePeriod
and indicates the number of blocks for which the extrinsic is valid, starting from the block the extrinsic was signed? But what is thePhase
? The wording "The Phase is the period" is confusing to me!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 always confuses me in the documentation too. I assumed a mortal era was just a block number, and a number of blocks it'd be valid from after that (and the signature material contains the block hash so we can verify that the block numbered is what you'd expect), but I don't think I'm quite right (I'm not sure what a "phase" is)?!
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 build on this; iirc we don't pass a block hash at all in the transaction; we just sign it against a block hash, so you need to know the block number you'll be getting the hash of to verify the signature I think?)
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.
Yes, the runtime keeps a mapping of
BlockNumber => BlockHash
for the lastBlockHashCount
blocks: https://github.com/paritytech/polkadot/blob/v0.9.10/runtime/common/src/lib.rs#L81The mortality is a number of blocks, but it's encoded in one byte, so it's
2 ** mortality
. Front ends abstract this by letting you "choose" a validity period, but if you choose e.g. 50 blocks it would actually be mortal for 64.