Skip to content
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

[ZCash] Fetch consensus branch id from the backend #27089

Merged
merged 2 commits into from
Dec 24, 2024
Merged

[ZCash] Fetch consensus branch id from the backend #27089

merged 2 commits into from
Dec 24, 2024

Conversation

cypt4
Copy link
Collaborator

@cypt4 cypt4 commented Dec 23, 2024

Resolves brave/brave-browser#42951

Testplan :
Test transparent transactions to be working

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Comment on lines +57 to 60
zcash_wallet_service_->zcash_rpc().GetLightdInfo(
chain_id,
base::BindOnce(&ZCashTransactionCompleteManager::OnGetLatestBlockHeight,
base::BindOnce(&ZCashTransactionCompleteManager::OnGetLightdInfo,
weak_ptr_factory_.GetWeakPtr(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How frequently branch id changes? Does it make sense to cache it per browser instance, or persist it per network?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several times a year i guess, we have to check whether it has been changed anyway

@@ -334,7 +334,6 @@ void ZCashWalletService::CompleteTransactionDone(
result.error());
return;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need this change?

Comment on lines 96 to 109
std::array<uint8_t, kBlake2bPersonalizationSize> result;
uint32_t consensusBranchId = tx.consensus_brach_id();
base::span(result)
.subspan(0, sizeof(kTxHashPersonalizerPrefix) - 1)
.copy_from(base::byte_span_from_cstring(kTxHashPersonalizerPrefix));
base::span(result)
.subspan(sizeof(kTxHashPersonalizerPrefix) - 1, sizeof(consensusBranchId))
.copy_from(base::byte_span_from_ref(base::numerics::U32FromLittleEndian(
base::byte_span_from_ref(consensusBranchId))));
return result;
}

} // namespace

Copy link
Collaborator

@supermassive supermassive Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be done with SpanWriter
something like

auto span_writer = base::SpanWriter(base::span(result));
span_writer.Write(base::byte_span_from_cstring(kTxHashPersonalizerPrefix));
span_writer.WriteU32LittleEndian(tx.consensus_brach_id())
DCHECK_EQ(span_writer.remaining(), 0u);

@@ -10,6 +10,7 @@
#include <utility>

#include "base/containers/span.h"
#include "base/containers/to_vector.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "base/containers/to_vector.h"

Copy link
Collaborator

@supermassive supermassive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet core lgtm

@cypt4 cypt4 merged commit 1c9725d into master Dec 24, 2024
20 checks passed
@cypt4 cypt4 deleted the brave_42951 branch December 24, 2024 13:09
@github-actions github-actions bot added this to the 1.75.x - Nightly milestone Dec 24, 2024
@brave-builds
Copy link
Collaborator

Released in v1.75.122

cypt4 added a commit that referenced this pull request Dec 24, 2024
* [ZCash] Fetch consensus branch id from the backend
Resolves brave/brave-browser#42951
@cypt4 cypt4 mentioned this pull request Dec 25, 2024
24 tasks
cypt4 added a commit that referenced this pull request Dec 25, 2024
* [ZCash] Fetch consensus branch id from the backend
Resolves brave/brave-browser#42951
@cypt4 cypt4 mentioned this pull request Dec 25, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to send from transparent to shielded account
3 participants