-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Refactor pass feature status to deserialized packet via packet meta #31549
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 |
@@ -390,7 +390,8 @@ impl BankingStage { | |||
), | |||
}; | |||
|
|||
let mut packet_receiver = PacketReceiver::new(id, packet_receiver); | |||
let mut packet_receiver = | |||
PacketReceiver::new(id, packet_receiver, bank_forks.clone()); |
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.
Passing bank_forks
to PacketReceiver
then to PacketDeserializer
, so packets can be flagged with working_bank's feature set.
@@ -55,7 +55,7 @@ impl ImmutableDeserializedPacket { | |||
|
|||
// drop transaction if prioritization fails. | |||
let mut priority_details = sanitized_transaction | |||
.get_transaction_priority_details() | |||
.get_transaction_priority_details(packet.meta().round_compute_unit_price()) |
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.
the particular feature flag is then read from packet's meta data, avoiding passing it through call stacks
let mut packet_clone = packet_batch[*packet_index].clone(); | ||
packet_clone | ||
.meta_mut() | ||
.set_round_compute_unit_price(round_compute_unit_price_enabled); |
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.
flag packet with root_bank feature set
core/src/packet_deserializer.rs
Outdated
@@ -42,9 +52,15 @@ impl PacketDeserializer { | |||
capacity: usize, | |||
) -> Result<ReceivePacketResults, RecvTimeoutError> { | |||
let (packet_count, packet_batches) = self.receive_until(recv_timeout, capacity)?; | |||
|
|||
// get current root bank to get feature gate status | |||
let _root_bank = self.bank_forks.read().unwrap().root_bank(); |
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'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
lgtm
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 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-price
flag toPacket
PacketDeserializer
usesbank_fork
to get root_bank's feature set statusFixes #