Refactor pass feature status to deserialized packet via packet meta#31549
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31549 +/- ##
=======================================
Coverage 81.3% 81.3%
=======================================
Files 733 733
Lines 204786 204801 +15
=======================================
+ Hits 166517 166530 +13
- Misses 38269 38271 +2 |
There was a problem hiding this comment.
Passing bank_forks to PacketReceiver then to PacketDeserializer, so packets can be flagged with working_bank's feature set.
There was a problem hiding this comment.
the particular feature flag is then read from packet's meta data, avoiding passing it through call stacks
There was a problem hiding this comment.
flag packet with root_bank feature set
There was a problem hiding this comment.
I'm not familiar with this specific feature round_compute_unit_price_enabled, but should we be getting it from the root bank? It seems like we should be checking the feature gates of the bank we're currently building, or our parent?
If it's a feature gate whole cluster won't cross epoch on their root bank at the same time which would lead to different timing for this feature to be activated across the cluster.
There was a problem hiding this comment.
Excellent point! So this PR is prerequisite for #31469, where the feature gate and its functions are implemented.
The context is: the feature gate is required (for #31469) between banking stage receives packet from sigverify, and before inserting it to priority-sorted queue (Transaction storage), because the prioritization (eg compute-unit-price) defined in compute-budget IX will be rounded down to nearest lamports when the feature is activated.
This PR is getting banking stage part of code ready for that.
Was thinking about picking one between root_bank over working_bank, sounds like working_bank is the better option for the purpose.
There was a problem hiding this comment.
94fefbbbf6345931d61a8923ffcbd685b4ca4030
There was a problem hiding this comment.
Okay makes sense. Since it only affects block packing seems like it wouldn't actually affect consensus? Basically it's okay if some members of the cluster are rounding down and some are not - so does it require a feature gate?
There was a problem hiding this comment.
This PR only affects leader code; to be more precious, would only affect at what numerical value of priority the packets are sorted in queue. For example, if a transaction sets compute-unit-price to 1_000_900; Before feature is enabled, the transaction will be prioritized as 1_000_900, after feature activation, it would be prioritized as 1_000_000. But all this change are in leader's thread queue only.
Just to clarify, the PR does not change code behavior, it only does the plumbing work. (it hardcoded the flag as false as feature is not activated, which is current behavior. )
It is a prerequisite of #31469 , where feature is actually added, and its status will affect how transactions are charged with priority fee, hence could affect consensus.
|
Checking the perf impact by read This branch: Head of Master: |
2. add packet meta flag; 3. prioritization_fee_cache read flag from its working bank directly; 4. immutable_deserialized_packet read flag from packet.meta;
2. packet_deserializer uses current root_bank from bank_fork to get feature status, use it to flag packet meta.
94fefbb to
4ccf3a5
Compare
apfitzge
left a comment
There was a problem hiding this comment.
I realize this was already merged, but I'm following-up to push back on it a bit. I think we should always be hesistant to add feature usage to things that do not affect consensus - I think it adds complexity that is not necessary, edge cases etc.
Leader's are already free to do whatever they want in terms of buffer prioritization - it's not enforcable by consensus. As an alternative, why not just start rounding down always for buffer prioritization, and we calculate actual fee based using the bank the tx is committed to.
To the best of my knowledge, there's no plans to backport this. So we have to wait for v1.16+ to activate anyway?
Additionally, the current method is already going to lead to some oddities around the feature activation:
gantt
title Receiving Window Race
dateFormat HH:mm
axisFormat %H:%M
section Banks
Bank 1 (Not Leader): b1, 00:00, 40m
Epoch Boundary: milestone, after b1
Bank 2 (Leader): after b1, 40m
section Receiving
Receiving 1: 00:05, 5m
Receiving 2: 00:35, 3m
Receiving 3: 00:42, 3m
Packets from receive windows 1/2 will be unrounded, while packets from receive 3 will be rounded.
|
Valid point, we chatted offline, agreed that if leader started to round down before feature gate (effectively passing hardcoded I think it is better to round down at both leader and fee calculation by same feature gate to be consistent in behavior, and focus the communication on this change is about incentivizing accurate compute-unit-limit economically. |
Problem
Passing current root_bank's feature status from packet_receiver to ImmutableDeserializedPacket is cumbersome. The plumbing go through many level call stacks (poc #31543).
Another possibility is to add an additional flag to
Packet, which is set by root bank feature status at the moment of packet deserialization. So the feature status goes with packet instead of passing multiple layers of calls. It'd also make removing feature code easier when it's fully activated.Summary of Changes
round-compute-unit-priceflag toPacketPacketDeserializerusesbank_forkto get root_bank's feature set statusFixes #