-
Notifications
You must be signed in to change notification settings - Fork 814
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
Add Solana priority fees #23214
base: master
Are you sure you want to change the base?
Add Solana priority fees #23214
Conversation
1fcb940
to
ceaeaf4
Compare
d9d87c2
to
a9c030f
Compare
A Storybook has been deployed to preview UI for the latest push |
a9c030f
to
55a0dcc
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
2ea81ad
to
0e37933
Compare
A Storybook has been deployed to preview UI for the latest push |
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.
desktop frontend ++
0e37933
to
621277c
Compare
A Storybook has been deployed to preview UI for the latest push |
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.
iOS ++
@@ -2382,6 +2392,8 @@ struct SolanaTxData { | |||
// signAllTransactions provider APIs, which includes serialized message and | |||
// signatures from partial_sign. | |||
SolanaSignTransactionParam? sign_transaction_param; | |||
|
|||
SolanaGasEstimation? gas_estimation; |
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.
nit: let's use fee estimation instead.
@@ -20,6 +20,9 @@ class PrefService; | |||
|
|||
namespace brave_wallet { | |||
|
|||
// https://docs.rs/solana-program/1.18.10/src/solana_program/clock.rs.html#129-131 | |||
extern const int kValidBlockHeightThreshold; |
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.
Let's move the constant to a shared file rather than use extern here, and rename to kSolanaValidBlockHeightThreshold if needed.
@@ -155,6 +161,9 @@ class SolanaTransaction { | |||
// Currently might be specified by solana.signAndSendTransaction provider | |||
// API as the options to be passed to sendTransaction RPC call. | |||
std::optional<SendOptions> send_options_; | |||
|
|||
// Gas estimation result | |||
mojom::SolanaGasEstimationPtr gas_estimation_; |
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.
add a check in SolanaTransaction::operator==
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 was addressed after you wrote your comment but before it was posted to the pull request.
GetSolanaGasEstimation(string chain_id, string tx_meta_id) | ||
=> (SolanaGasEstimation estimation, SolanaProviderError error, string error_message); |
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.
Why do we need two instead of just changing fee to the new struct in GetEstimatedTxFee?
// Rearrange the static account keys and generate a new SolanaMessageHeader | ||
uint16_t num_required_signatures = 0; | ||
uint16_t num_readonly_signed_accounts = 0; | ||
uint16_t num_readonly_unsigned_accounts = 0; | ||
std::vector<SolanaAccountMeta> unique_account_metas; | ||
GetUniqueAccountMetas(fee_payer_, instructions_, &unique_account_metas); | ||
std::vector<SolanaAddress> static_accounts; | ||
for (const auto& meta : unique_account_metas) { | ||
auto addr = SolanaAddress::FromBase58(meta.pubkey); | ||
if (!addr) { | ||
return false; | ||
} | ||
|
||
if (meta.is_signer) { | ||
num_required_signatures++; | ||
} | ||
if (meta.is_signer && !meta.is_writable) { | ||
num_readonly_signed_accounts++; | ||
} | ||
if (!meta.is_signer && !meta.is_writable) { | ||
num_readonly_unsigned_accounts++; | ||
} | ||
|
||
if (num_required_signatures > UINT8_MAX || | ||
num_readonly_signed_accounts > UINT8_MAX || | ||
num_readonly_unsigned_accounts > UINT8_MAX || | ||
static_accounts.size() == UINT8_MAX) { | ||
return false; | ||
} | ||
static_accounts.emplace_back(*addr); | ||
} | ||
static_account_keys_ = static_accounts; | ||
|
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.
We should extract and share code in CreateLegacyMessage rather than copy the logic.
621277c
to
7552175
Compare
10a6041
to
1a0851d
Compare
A Storybook has been deployed to preview UI for the latest push |
1a0851d
to
3b68864
Compare
A Storybook has been deployed to preview UI for the latest push |
* Fix to support AddPriorityFEe for v0 transactions * Test case for AddPriorityFee for v0 transactions * Test case for UsesPriorityFee
* If fetching the base fee fails, don't set a gas estimate or modify the priority fee instructions, but still add the transaction. The client will need to fetch the estimate again on it's own as it currently does. * If only setting the priority fee fails (e.g. simulation), we set the gas estimate, but don't modify the instructions. We do this because the frontend can still use base fee from the estimate, but we don't have enough info to set the priority fee instruction.
3b68864
to
97fb9e7
Compare
[puLL-Merge] - brave/brave-core@23214 Here is a review of the pull request: DescriptionThis PR makes several changes to improve Solana transaction handling in Brave Wallet:
The motivation seems to be to provide more accurate and complete fee estimations for Solana transactions and enable users to add priority fees. ChangesChangesChanges are organized by area: Core:
Tests:
UI:
Security HotspotsNo major security issues identified. The changes primarily impact already-existing Solana transaction handling rather than opening up new attack surface. One note is that user-provided compute unit limits in transactions are now respected. However, this seems to be the intended behavior, and there are still limits in place (max transaction size, etc). Let me know if you have any other questions! |
A Storybook has been deployed to preview UI for the latest push |
Resolves brave/brave-browser#35866
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: