Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Static Decoding of Signed Extensions: Simple Approach #1235
Static Decoding of Signed Extensions: Simple Approach #1235
Changes from 19 commits
c0226dc
ffec0b1
b0fb96a
c87f165
4ed554d
460bfaf
ea59e6c
3dad997
fe708e7
0eabab9
58fd654
1dd8f53
64b5c90
7d8447e
fe1db8c
8c93d5b
bba2c4b
2692882
0d52317
7ff7552
f200d0f
5afe150
42a0423
b7d9411
13e3f2d
39f1a30
cb65208
d50519d
1dc9976
3a79e70
0876c28
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think you added this
&'a self
lifetime back because metadata is no longer referenced, but you should be able to get rid of it (esp since youself.metadata.clone()
below still).If
Metadata
needs to be owned inExtrinsicSignedExtensions
(even though other bits are borrowed) then you could:let metadata = self.metadata.clone()
at the topself
in theiter::from_fn
below.But since everything else is borrowed, I'd borrow the Metadata in
ExtrinsicSignedExtensions
and then all of the data has the'a
lifetime and that lifetime flows into the iterated stuff too. (Basically, we should either fully commit to lifetimes or avoid them completely here I reckon, and fully committing seems like the good way to go unless we run into some case where they are a pain)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.
Could this take
&str
instead ofimpl AsRef<str>
?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.
Nit: Maybe this should be
Result<Option<..>
instead, actually? I'm never sure; just looking at some of the otherfind
methods we have around :)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 could probably modify the
find_by_name
function to take in a filter instead of the name, but yea we have a few extras anywayThere 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.
It looks like some things, like this and the lifetime stuff on
ExtrinsicSignedExtensions
were lost again compared to the base PR that these build off; would be good to merge the underlying branch or rebase :)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.
You are right, some stuff was lost in the merge, sorry. But this
decoded
function I kept on purpose. It is just private now, but used in the publicas_type()
andvalue()
functions.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.
In the other PR I'd updated to directly use
Value::decode_as_type(..)
which should be better thanDecodedValueThunk::decode_with_metadata(..)
, and also I'd remove thevalue()
function and just return aValue
from this one (I'd have a look at the other PR because that was good here :))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.
here and below I think I wouldn't make these
pub
and instead exposetip()
andasset_id()
getters wheretip
returnsu128
and theCompact
thing is hidden away (it's an implementation detail) :)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.
Personally I prefer the prev approach and not making the struct
Encode
(it feels like an implementation detail that's better to not expose). Same as belowThere 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.
As above I'd expose a
tip()
getter that returnsu128
to hide theCompact
implementation detail, and wouldn't have this beEncode
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.
it'd be really good I think to also test getting the mortality (just because that returns an enum and would be good to check that it decodes OK! I'm not sure off the top of my head whether the encoded impl is consistent with this or not))
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 added a check at the end of the test to verify Mortality decodes and is
Era::Immortal
.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, thank you! That's reassuring :)