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

BatchVerifier: Rename and unexport local functions in verify/txn #4578

Merged
merged 13 commits into from
Sep 30, 2022

Conversation

algonautshant
Copy link
Contributor

@algonautshant algonautshant commented Sep 23, 2022

Rename and make local functions which are internal to the package.
The purpose is to enhance the code readability.
Also removing a function which is not used.

@algonautshant algonautshant added tech debt Things that need re-work for simplification / sanitization to reduce implementation overhead Team Carbon-11 labels Sep 23, 2022
brianolson
brianolson previously approved these changes Sep 23, 2022
Copy link
Contributor

@brianolson brianolson left a comment

Choose a reason for hiding this comment

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

Good cleanup. I like it. This should make future changes much more clear about the scope of things in this package.

@algonautshant algonautshant changed the title Rename and unexport local functions in verify/txn BatchVerifier: Rename and unexport local functions in verify/txn Sep 23, 2022
algorandskiy
algorandskiy previously approved these changes Sep 23, 2022
data/transactions/verify/txn.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #4578 (9ff7853) into master (8cb8ec6) will increase coverage by 0.03%.
The diff coverage is 62.50%.

@@            Coverage Diff             @@
##           master    #4578      +/-   ##
==========================================
+ Coverage   54.12%   54.16%   +0.03%     
==========================================
  Files         401      401              
  Lines       51642    51615      -27     
==========================================
+ Hits        27951    27955       +4     
+ Misses      21341    21312      -29     
+ Partials     2350     2348       -2     
Impacted Files Coverage Δ
data/transactions/verify/txn.go 46.19% <47.05%> (+2.44%) ⬆️
crypto/multisig.go 44.65% <75.00%> (-0.70%) ⬇️
crypto/batchverifier.go 100.00% <100.00%> (ø)
network/wsNetwork.go 64.63% <0.00%> (ø)
ledger/acctupdates.go 70.19% <0.00%> (+0.59%) ⬆️
network/wsPeer.go 68.73% <0.00%> (+0.80%) ⬆️
ledger/tracker.go 74.89% <0.00%> (+0.85%) ⬆️
ledger/roundlru.go 96.22% <0.00%> (+5.66%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

algorandskiy
algorandskiy previously approved these changes Sep 23, 2022
Copy link
Contributor

@cce cce left a comment

Choose a reason for hiding this comment

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

I need access to TxnBatchVerify for external optimization (verifying more than one TxnGroup at a time)

data/transactions/verify/txn.go Outdated Show resolved Hide resolved
@cce
Copy link
Contributor

cce commented Sep 23, 2022

another function that needs renaming (e.g. from logicSigBatchVerify to logicSigVerify):

// logicSigBatchVerify checks that the signature is valid, executing the program.
// it is the caller responsibility to call batchVerifier.verify()
func logicSigBatchVerify(txn *transactions.SignedTxn, groupIndex int, groupCtx *GroupContext) error {

this is a copy-paste typo — logicSigBatchVerify does not take a batchVerifier argument, and the caller does not have the responsibility to call it after calling this function, since one is not provided

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

I like these name changes, I was pretty scared callers would think the old things performed verification rather than just set it up.

cce
cce previously approved these changes Sep 27, 2022
Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

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

Not going to approve so others get eyes on, but reading through think it is correct.

brianolson
brianolson previously approved these changes Sep 27, 2022
Copy link
Contributor

@brianolson brianolson left a comment

Choose a reason for hiding this comment

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

LGTM

cce
cce previously approved these changes Sep 27, 2022
@algonautshant algonautshant dismissed stale reviews from cce and brianolson via 754f0fb September 28, 2022 01:40
crypto/multisig.go Outdated Show resolved Hide resolved
@@ -113,7 +112,7 @@ func (b *BatchVerifier) GetNumberOfEnqueuedSignatures() int {
// if the batch is zero an appropriate error is return.
func (b *BatchVerifier) Verify() error {
if b.GetNumberOfEnqueuedSignatures() == 0 {
return ErrZeroTransactionInBatch
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

this change means that TxnGroup will now add things to the cache where before it would just exit out early with the ctx and nil error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is the intention, so that the logicsig transactions which were not added to BatchVerifier at the level of TxnGroup and do not contribute to this GetNumberOfEnqueuedSignatures, but were verified at local batches, also get cached.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering about that too, I looked up the version just before the BV refactor merged in #2578 and it looks like any verified txngroup (even those with 0 sigs) would get cached in the old version
https://github.com/algorand/go-algorand/blame/16bada1e2b185348a41e1590eefd9eebd4315064/data/transactions/verify/txn.go#L115

Copy link
Contributor

Choose a reason for hiding this comment

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

so are we OK this this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we discussed it and it is the intention to make this change and then have logicsigs be cached like they used to.

crypto/multisig.go Outdated Show resolved Hide resolved
crypto/multisig.go Outdated Show resolved Hide resolved
data/transactions/verify/txn_test.go Outdated Show resolved Hide resolved
crypto/multisig.go Outdated Show resolved Hide resolved
@algorandskiy algorandskiy merged commit d389196 into algorand:master Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Team Carbon-11 tech debt Things that need re-work for simplification / sanitization to reduce implementation overhead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants