-
Couldn't load subscription status.
- Fork 2.7k
Tipped Transaction Type. #2930
Tipped Transaction Type. #2930
Conversation
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'd ditch the generic Balance from Tip if possible, and also please triple check that it's part of the signing payload.
| /// The function that should be called. | ||
| pub function: Call, | ||
| /// The tip for this transaction | ||
| pub tip: Tip<Balance>, |
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 don't seem to modify fn check function and it's strictly required that tip is part of the payload we are signing. Otherwise you can change it arbitrarly and the signature would still be valid.
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.
right -- added to the todo list up top.
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.
cc @jacogr formats are changing
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.
As Jaco noticed we could bump version 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.
check is modified but I will keep the conversation open as a reminder that the extrinsic format has changed slightly.
|
@tomusdrw two questions, one important and one more of a nit:
|
I don't think it semantically fits the signature. Also note that to produce the
I think we should do that yes.
So with the current values of |
|
This can now be reviewed in more depth. There might still be some work on how the generic Once #2854 is stable and merged in with this I would like to add as many e2e tests as possible. For now, my only manual, cumbersome testing method I had is broken due to this issue #2943. I think it is an important one actually. |
core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs
Outdated
Show resolved
Hide resolved
core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs
Outdated
Show resolved
Hide resolved
srml/executive/src/lib.rs
Outdated
| // TODO: maximise (fee + tip) per weight unit here. | ||
| TransactionValidity::Valid { | ||
| priority: encoded_len as TransactionPriority, | ||
| priority: (encoded_len as TransactionPriority) + tip_value.saturated_into::<TransactionPriority>(), |
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 don't think this is correct. We seem to be adding a bytes length of the extrinsic and the value, but since MakePayment is generic, we don't really know how much each byte of encoded_len is worth, so it's hard to compare it directly with Balance.
I think MakePayment trait, should handle all this (maybe it requires a slight rename though):
fn make_payment(sender, encoded_len, tip) -> Result<Priority>;
So we make payment for both len and tip in one operation and we get the transaction priority back (or something that can be easily converted to priority).
|
@rphmeier the road map would be that this will be included in substrate and soonish we can try out replacing the |
core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs
Outdated
Show resolved
Hide resolved
core/sr-primitives/src/generic/unchecked_mortal_compact_tipped_extrinsic.rs
Outdated
Show resolved
Hide resolved
| Lookup, Checkable, Extrinsic, SaturatedConversion}; | ||
| use super::{CheckedExtrinsic, Era, Tip}; | ||
|
|
||
| const TRANSACTION_VERSION: u8 = 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.
Should we use different versioning than UncheckedMortalCompactExtrinsic? Say, start with 1000 or sth.
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.
Not sure we can go that high :)
So the first byte is the encoded value, it is - signed flag & version, where signed flag is 0 for unsigned, or 0b10000000 for signed. So the lowest 7 bits indicate the version.
Tl;DR 127 max :)
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.
64?
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.
Haha, right. I didn't notice it's only one byte :)
| signed: Address, | ||
| signature: Signature, | ||
| era: Era, | ||
| tip: Option<Tip<Balance>> |
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.
should be required, since it's signed.
| tip: Option<Tip<Balance>> | |
| tip: Tip<Balance>, |
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 my head it makes sense; a signed can say my tip is none (which is practically the same as saying my tip is Sender(0)) but it is still fine as long as it is provided in the byte stream and it can be decoded (afaik None is 0 or 0 0 when encoded?).
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.
ignore the above ^^ you're right.
srml/executive/src/lib.rs
Outdated
| Block: traits::Block<Header=System::Header, Hash=System::Hash>, | ||
| Context: Default, | ||
| Payment: MakePayment<System::AccountId>, | ||
| Balance: SimpleArithmetic + Copy, |
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 use BalanceOf<Payment, System::AccountId> instead of additional generic type Balance?
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 indeed we actually don't need this anymore; taking your previous comment balance is now an associated type of make_payment; hence not really needed up here.
|
is |
| /// Most often this is: | ||
| /// - `None` if the unchecked extrinsic does not have a tip OR it is unsigned. | ||
| /// - `Some` if the opposite. | ||
| pub tip: Option<Tip<Balance>>, |
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.
should just be an additional arg in signed
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 be moved there but you mean probably in unchecked_mortal_compact_tipped.rs (god, hate this name to type it)? I will also update here but this is not really important anymore.
| pub struct CheckedExtrinsic<AccountId, Index, Call, Balance> { | ||
| /// Who this purports to be from and the number of extrinsics have come before | ||
| /// from the same signer, if anyone (note this is not a signature). | ||
| pub signed: Option<(AccountId, Index)>, |
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.
| pub signed: Option<(AccountId, Index)>, | |
| pub signed: Option<(AccountId, Index, Tip<Balance>)>, |
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 could theoretically be an option, but as long as it's compact encoded, then there's no point since zero compact encoded is a big as None encoded.
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 make sure Tip<Balance> implements Default. For non-tipping chains, Tip<Balance> can be ().
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.
if it is part of the signature then it is only visible in signed txs which is the point of the current option. Hence, pub signed: Option<(AccountId, Index, Tip<Balance>)>, looks ok
|
|
||
| /// A placeholder tip type that is used to fulfill the generic requirements of `checked_extrinsic` | ||
| /// when the underlying `unchecked_extrinsic` actually does not have a tip. | ||
| pub type NoTipBalance = u32; |
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.
why 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.
Could not have it meet the type requirements of the generic type (has to be SimpleArithmetic-- probably doable but needs a more handy rust dev with more time -- will try)
| pub function: Call, | ||
| /// The tip for this transaction. This is always `Some` for a signed transaction and always | ||
| /// `None` for unsigned. | ||
| pub tip: Option<Tip<Balance>>, |
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.
doesn't belong here since it's meaningless unless this is a (signed) transaction.
| /// The signature, address, number of extrinsics have come before from | ||
| /// the same signer and an era describing the longevity of this transaction, | ||
| /// if this is a signed extrinsic. | ||
| pub signature: Option<(Address, Signature, Compact<Index>, Era)>, |
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.
| pub signature: Option<(Address, Signature, Compact<Index>, Era)>, | |
| pub signature: Option<(Address, Signature, Compact<Index>, Era, Tip<Balance>)>, |
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.
Types could do with reworking.
|
will be closed by #3102 |
Follow up on #2799 #2854.
Allows all three types of.UnchckedExtrinsicto have a generic atipenum fieldOptionally decoded to the tip upon receiving a tx. Default value if non-existent.runtime/executivevia aTippabletrait.TODO:
tipvalue invalidate_transactionto increase priority.WIP but pushed to get some initial feedback.