-
Notifications
You must be signed in to change notification settings - Fork 1k
Separate fee-calculation from SDK #2120
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
Changes from all commits
697fc46
c6a03be
9cb6521
050d294
17c1547
e65eae5
4c1a3c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [package] | ||
| name = "solana-fee" | ||
| description = "Solana fee calculation" | ||
| documentation = "https://docs.rs/solana-fee" | ||
| version = { workspace = true } | ||
| authors = { workspace = true } | ||
| repository = { workspace = true } | ||
| homepage = { workspace = true } | ||
| license = { workspace = true } | ||
| edition = { workspace = true } | ||
|
|
||
| [dependencies] | ||
| solana-sdk = { workspace = true } | ||
| solana-svm-transaction = { workspace = true } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| use {solana_sdk::fee::FeeDetails, solana_svm_transaction::svm_message::SVMMessage}; | ||
|
|
||
| /// Calculate fee for `SanitizedMessage` | ||
| pub fn calculate_fee( | ||
| message: &impl SVMMessage, | ||
| zero_fees_for_test: bool, | ||
| lamports_per_signature: u64, | ||
| prioritization_fee: u64, | ||
| remove_rounding_in_fee_calculation: bool, | ||
| ) -> u64 { | ||
| calculate_fee_details( | ||
| message, | ||
| zero_fees_for_test, | ||
| lamports_per_signature, | ||
| prioritization_fee, | ||
| remove_rounding_in_fee_calculation, | ||
| ) | ||
| .total_fee() | ||
| } | ||
|
|
||
| pub fn calculate_fee_details( | ||
|
tao-stones marked this conversation as resolved.
|
||
| message: &impl SVMMessage, | ||
|
tao-stones marked this conversation as resolved.
|
||
| zero_fees_for_test: bool, | ||
| lamports_per_signature: u64, | ||
|
tao-stones marked this conversation as resolved.
|
||
| prioritization_fee: u64, | ||
| remove_rounding_in_fee_calculation: bool, | ||
| ) -> FeeDetails { | ||
| if zero_fees_for_test { | ||
| return FeeDetails::default(); | ||
| } | ||
| let signature_fee = message | ||
| .num_total_signatures() | ||
| .saturating_mul(lamports_per_signature); | ||
|
|
||
| FeeDetails::new( | ||
| signature_fee, | ||
| prioritization_fee, | ||
| remove_rounding_in_fee_calculation, | ||
| ) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,8 @@ net2 = "0.2.37" | |
| num-derive = "0.4.2" | ||
| num-traits = "0.2" | ||
| rand = "0.8" | ||
| serde = "1.0.112" # must match the serde_derive version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251 | ||
| serde_derive = "1.0.112" # must match the serde version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251 | ||
| serde = "1.0.112" # must match the serde_derive version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251 | ||
| serde_derive = "1.0.112" # must match the serde version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251 | ||
|
Comment on lines
+25
to
+26
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI yelled at me. I think because I edited file and we must have added formatting requirement since last edit 🤷♂️ |
||
| serde_json = "1.0.56" | ||
| solana-account-decoder = { path = "../../account-decoder", version = "=2.1.0" } | ||
| solana-accounts-db = { path = "../../accounts-db", version = "=2.1.0" } | ||
|
|
@@ -33,6 +33,7 @@ solana-cli-output = { path = "../../cli-output", version = "=2.1.0" } | |
| solana-compute-budget = { path = "../../compute-budget", version = "=2.1.0" } | ||
| solana-curve25519 = { path = "../../curves/curve25519", version = "=2.1.0" } | ||
| solana-decode-error = { path = "../../sdk/decode-error", version = "=2.1.0" } | ||
| solana-fee = { path = "../../fee", version = "=2.1.0" } | ||
| solana-ledger = { path = "../../ledger", version = "=2.1.0" } | ||
| solana-log-collector = { path = "../../log-collector", version = "=2.1.0" } | ||
| solana-logger = { path = "../../logger", version = "=2.1.0" } | ||
|
|
@@ -99,6 +100,7 @@ solana-accounts-db = { workspace = true } | |
| solana-bpf-loader-program = { workspace = true } | ||
| solana-cli-output = { workspace = true } | ||
| solana-compute-budget = { workspace = true } | ||
| solana-fee = { workspace = true } | ||
| solana-ledger = { workspace = true } | ||
| solana-log-collector = { workspace = true } | ||
| solana-logger = { workspace = true } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.