Created
March 6, 2020 18:27
-
-
Save mvines/304f13d7c1c9f1da1142e4f6ba18cc2e to your computer and use it in GitHub Desktop.
Patch for FeeCalculator snapshot rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9f0b2ad5076ee0ee12a6244225bac680ea1a18f1 Mon Sep 17 00:00:00 2001 | |
From: Michael Vines <mvines@gmail.com> | |
Date: Thu, 5 Mar 2020 15:28:09 -0700 | |
Subject: [PATCH] FeeCalculator snapshot rewrite | |
--- | |
ledger/src/snapshot_utils.rs | 6 ++++++ | |
runtime/src/bank.rs | 5 +++-- | |
sdk/src/fee_calculator.rs | 32 +++++++++++++++++++++++--------- | |
3 files changed, 32 insertions(+), 11 deletions(-) | |
diff --git a/ledger/src/snapshot_utils.rs b/ledger/src/snapshot_utils.rs | |
index 6f4b19fb6..5aaff2349 100644 | |
--- a/ledger/src/snapshot_utils.rs | |
+++ b/ledger/src/snapshot_utils.rs | |
@@ -598,6 +598,12 @@ where | |
))); | |
} | |
}; | |
+ bank.fee_rate_governor.lamports_per_signature = 5000; | |
+ bank.fee_rate_governor.burn_percent = 100; | |
+ bank.fee_rate_governor.min_lamports_per_signature = 5000; | |
+ bank.fee_rate_governor.max_lamports_per_signature = 100000; | |
+ println!("fee_calculator: {:?}", bank.fee_calculator); | |
+ println!("fee_rate_governor: {:?}", bank.fee_rate_governor); | |
info!("Rebuilding accounts..."); | |
bank.set_bank_rc( | |
bank::BankRc::new(account_paths.to_vec(), 0, bank.slot()), | |
diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs | |
index 000f7467d..c214bfbb0 100644 | |
--- a/runtime/src/bank.rs | |
+++ b/runtime/src/bank.rs | |
@@ -299,10 +299,11 @@ pub struct Bank { | |
collector_fees: AtomicU64, | |
/// Latest transaction fees for transactions processed by this bank | |
- fee_calculator: FeeCalculator, | |
+ pub fee_calculator: FeeCalculator, | |
/// Track cluster signature throughput and adjust fee rate | |
- fee_rate_governor: FeeRateGovernor, | |
+ #[serde(skip_deserializing)] | |
+ pub fee_rate_governor: FeeRateGovernor, | |
/// Rent that have been collected | |
#[serde(serialize_with = "serialize_atomicu64")] | |
diff --git a/sdk/src/fee_calculator.rs b/sdk/src/fee_calculator.rs | |
index 03485117e..ac70126ff 100644 | |
--- a/sdk/src/fee_calculator.rs | |
+++ b/sdk/src/fee_calculator.rs | |
@@ -2,26 +2,39 @@ use crate::clock::{DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT}; | |
use crate::message::Message; | |
use log::*; | |
-#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] | |
+#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Debug)] | |
#[serde(rename_all = "camelCase")] | |
pub struct FeeCalculator { | |
// The current cost of a signature This amount may increase/decrease over time based on | |
// cluster processing load. | |
pub lamports_per_signature: u64, | |
-} | |
-impl Default for FeeCalculator { | |
- fn default() -> Self { | |
- Self { | |
- lamports_per_signature: 0, | |
- } | |
- } | |
+ // The target cost of a signature when the cluster is operating around target_signatures_per_slot | |
+ // signatures | |
+ #[serde(skip_serializing)] | |
+ pub target_lamports_per_signature: u64, | |
+ | |
+ // Used to estimate the desired processing capacity of the cluster. As the signatures for | |
+ // recent slots are fewer/greater than this value, lamports_per_signature will decrease/increase | |
+ // for the next slot. A value of 0 disables lamports_per_signature fee adjustments | |
+ #[serde(skip_serializing)] | |
+ pub target_signatures_per_slot: usize, | |
+ | |
+ #[serde(skip_serializing)] | |
+ pub min_lamports_per_signature: u64, | |
+ #[serde(skip_serializing)] | |
+ pub max_lamports_per_signature: u64, | |
+ | |
+ // What portion of collected fees are to be destroyed, as a fraction of std::u8::MAX | |
+ #[serde(skip_serializing)] | |
+ pub burn_percent: u8, | |
} | |
impl FeeCalculator { | |
pub fn new(lamports_per_signature: u64) -> Self { | |
Self { | |
lamports_per_signature, | |
+ ..Default::default() | |
} | |
} | |
@@ -36,7 +49,7 @@ pub struct FeeRateGovernor { | |
// The current cost of a signature This amount may increase/decrease over time based on | |
// cluster processing load. | |
#[serde(skip)] | |
- lamports_per_signature: u64, | |
+ pub lamports_per_signature: u64, | |
// The target cost of a signature when the cluster is operating around target_signatures_per_slot | |
// signatures | |
@@ -159,6 +172,7 @@ impl FeeRateGovernor { | |
pub fn create_fee_calculator(&self) -> FeeCalculator { | |
FeeCalculator { | |
lamports_per_signature: self.lamports_per_signature, | |
+ ..Default::default() | |
} | |
} | |
} | |
-- | |
2.21.1 (Apple Git-122.3) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/new-ledger | |
cp ~/old-ledger/genesis* ~/new-ledger | |
solana-ledger-tool --ledger ~/old-ledger create-snapshot 2486173 ~/new-ledger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment