Skip to content

Commit 3b1a9e0

Browse files
committed
feat: expose ranking score.
1 parent b47f020 commit 3b1a9e0

File tree

4 files changed

+60
-18
lines changed

4 files changed

+60
-18
lines changed

aptos-move/framework/aptos-framework/doc/governed_gas_pool.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [Function `deposit_from`](#0x1_governed_gas_pool_deposit_from)
1919
- [Function `deposit_from_fungible_store`](#0x1_governed_gas_pool_deposit_from_fungible_store)
2020
- [Function `deposit_gas_fee`](#0x1_governed_gas_pool_deposit_gas_fee)
21+
- [Function `deposit_gas_fee_v2`](#0x1_governed_gas_pool_deposit_gas_fee_v2)
2122
- [Function `get_balance`](#0x1_governed_gas_pool_get_balance)
2223
- [Specification](#@Specification_1)
2324
- [Function `initialize`](#@Specification_1_initialize)
@@ -411,12 +412,39 @@ Deposits gas fees into the governed gas pool.
411412

412413

413414
<pre><code><b>public</b> <b>fun</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_gas_fee">deposit_gas_fee</a>(gas_payer: <b>address</b>, gas_fee: u64) <b>acquires</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool_GovernedGasPool">GovernedGasPool</a> {
414-
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_operations_default_to_fa_apt_store_enabled">features::operations_default_to_fa_apt_store_enabled</a>()) {
415+
// get the sender <b>to</b> preserve the signature but do nothing
416+
<a href="governed_gas_pool.md#0x1_governed_gas_pool_governed_gas_pool_address">governed_gas_pool_address</a>();
417+
}
418+
</code></pre>
419+
420+
421+
422+
</details>
423+
424+
<a id="0x1_governed_gas_pool_deposit_gas_fee_v2"></a>
425+
426+
## Function `deposit_gas_fee_v2`
427+
428+
Deposits gas fees into the governed gas pool.
429+
@param gas_payer The address of the account that paid the gas fees.
430+
@param gas_fee The amount of gas fees to be deposited.
431+
432+
433+
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_gas_fee_v2">deposit_gas_fee_v2</a>(gas_payer: <b>address</b>, gas_fee: u64)
434+
</code></pre>
435+
436+
437+
438+
<details>
439+
<summary>Implementation</summary>
440+
441+
442+
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_gas_fee_v2">deposit_gas_fee_v2</a>(gas_payer: <b>address</b>, gas_fee: u64) <b>acquires</b> <a href="governed_gas_pool.md#0x1_governed_gas_pool_GovernedGasPool">GovernedGasPool</a> {
443+
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_operations_default_to_fa_apt_store_enabled">features::operations_default_to_fa_apt_store_enabled</a>()) {
415444
<a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_from_fungible_store">deposit_from_fungible_store</a>(gas_payer, gas_fee);
416445
} <b>else</b> {
417446
<a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_from">deposit_from</a>&lt;AptosCoin&gt;(gas_payer, gas_fee);
418447
};
419-
420448
}
421449
</code></pre>
422450

aptos-move/framework/aptos-framework/doc/transaction_validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ Called by the Adapter
649649
<b>if</b> (amount_to_burn &gt; storage_fee_refunded) {
650650
<b>let</b> burn_amount = amount_to_burn - storage_fee_refunded;
651651
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_governed_gas_pool_enabled">features::governed_gas_pool_enabled</a>()) {
652-
<a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_gas_fee">governed_gas_pool::deposit_gas_fee</a>(gas_payer, burn_amount);
652+
<a href="governed_gas_pool.md#0x1_governed_gas_pool_deposit_gas_fee_v2">governed_gas_pool::deposit_gas_fee_v2</a>(gas_payer, burn_amount);
653653
} <b>else</b> {
654654
<a href="transaction_fee.md#0x1_transaction_fee_burn_fee">transaction_fee::burn_fee</a>(gas_payer, burn_amount);
655655
}

aptos-move/framework/move-stdlib/doc/features.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,10 +3341,12 @@ Deprecated to prevent validator set changes during DKG.
33413341

33423342
Genesis/tests should use <code><a href="features.md#0x1_features_change_feature_flags_internal">change_feature_flags_internal</a>()</code> for feature vec initialization.
33433343

3344+
This can be used on testnet prior to successful DKG.
3345+
33443346
Governance proposals should use <code><a href="features.md#0x1_features_change_feature_flags_for_next_epoch">change_feature_flags_for_next_epoch</a>()</code> to enable/disable features.
33453347

33463348

3347-
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(_framework: &<a href="signer.md#0x1_signer">signer</a>, _enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, _disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;)
3349+
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(framework: &<a href="signer.md#0x1_signer">signer</a>, enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;)
33483350
</code></pre>
33493351

33503352

@@ -3353,8 +3355,8 @@ Governance proposals should use <code><a href="features.md#0x1_features_change_f
33533355
<summary>Implementation</summary>
33543356

33553357

3356-
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(_framework: &<a href="signer.md#0x1_signer">signer</a>, _enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, _disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;) {
3357-
<b>abort</b> (<a href="error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="features.md#0x1_features_EAPI_DISABLED">EAPI_DISABLED</a>))
3358+
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(framework: &<a href="signer.md#0x1_signer">signer</a>, enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;) <b>acquires</b> <a href="features.md#0x1_features_Features">Features</a> {
3359+
<a href="features.md#0x1_features_change_feature_flags_internal">change_feature_flags_internal</a>(framework, enable, disable)
33583360
}
33593361
</code></pre>
33603362

mempool/src/core_mempool/mempool.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ impl Mempool {
119119
.reject_transaction(sender, sequence_number, hash);
120120
}
121121

122-
pub fn log_txn_latency(
123-
insertion_info: &InsertionInfo,
124-
bucket: &str,
125-
stage: &'static str,
126-
) {
122+
pub fn log_txn_latency(insertion_info: &InsertionInfo, bucket: &str, stage: &'static str) {
127123
if let Ok(time_delta) = SystemTime::now().duration_since(insertion_info.insertion_time) {
128124
counters::core_mempool_txn_commit_latency(
129125
stage,
@@ -304,13 +300,13 @@ impl Mempool {
304300
/// `exclude_transactions` - transactions that were sent to Consensus but were not committed yet
305301
/// mempool should filter out such transactions.
306302
#[allow(clippy::explicit_counter_loop)]
307-
pub fn get_batch(
303+
pub fn get_batch_with_ranking_score(
308304
&self,
309305
max_txns: u64,
310306
max_bytes: u64,
311307
return_non_full: bool,
312308
exclude_transactions: BTreeMap<TransactionSummary, TransactionInProgress>,
313-
) -> Vec<SignedTransaction> {
309+
) -> Vec<(SignedTransaction, u64)> {
314310
let start_time = Instant::now();
315311
let exclude_size = exclude_transactions.len();
316312
let mut inserted = HashSet::new();
@@ -381,7 +377,7 @@ impl Mempool {
381377
break;
382378
}
383379
total_bytes += txn_size;
384-
block.push(txn);
380+
block.push((txn, ranking_score));
385381
if total_bytes == max_bytes {
386382
full_bytes = true;
387383
}
@@ -441,6 +437,25 @@ impl Mempool {
441437
block
442438
}
443439

440+
pub fn get_batch(
441+
&self,
442+
max_txns: u64,
443+
max_bytes: u64,
444+
return_non_full: bool,
445+
exclude_transactions: BTreeMap<TransactionSummary, TransactionInProgress>,
446+
) -> Vec<SignedTransaction> {
447+
let batch_with_ranking_score = self.get_batch_with_ranking_score(
448+
max_txns,
449+
max_bytes,
450+
return_non_full,
451+
exclude_transactions,
452+
);
453+
batch_with_ranking_score
454+
.into_iter()
455+
.map(|(txn, _)| txn)
456+
.collect()
457+
}
458+
444459
/// Periodic core mempool garbage collection.
445460
/// Removes all expired transactions and clears expired entries in metrics
446461
/// cache and sequence number cache.
@@ -465,10 +480,7 @@ impl Mempool {
465480
}
466481

467482
/// Read transactions from timeline from `start_id` (exclusive) to `end_id` (inclusive).
468-
pub fn timeline_range(
469-
&self,
470-
start_end_pairs: &Vec<(u64, u64)>,
471-
) -> Vec<SignedTransaction> {
483+
pub fn timeline_range(&self, start_end_pairs: &Vec<(u64, u64)>) -> Vec<SignedTransaction> {
472484
self.transactions.timeline_range(start_end_pairs)
473485
}
474486

0 commit comments

Comments
 (0)