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

libgoal: set FirstValid to LastRound to prevent early tnxs #5622

Merged

Conversation

algorandskiy
Copy link
Contributor

Summary

Pingpong testing on large network discovered an issue when a node sends transactions that are too early to its neighbors. This happens when a node is few milliseconds ahead and immediately sends transactions.
There are some logs from NPN running pingpong and its sibling relays. Note the EnsureBlock timestamp and transaction sending timestamp.

NPN:

{"Context":"Agreement","Hash":"M6PF4TJ3USEN2DT5VNORHIQX23DBF53QQS5YZNAVBRBQMNJMDNQA","ObjectPeriod":0,"ObjectRound":0,"ObjectStep":0,"Period":0,"Round":652,"S
ender":"PPFBOHV7JM3VKBJGXCLNFD6LIDQG3GRF6WCKS3TZ3L4D5CEP2AUNCC7SEU","Step":0,"Type":"RoundStart","Weight":0,"WeightTotal":0,"file":"actions.go","function":"gi
thub.com/algorand/go-algorand/agreement.ensureAction.do","level":"info","line":262,"msg":"finished round 652","time":"2023-07-28T19:03:58.592873Z"}

{"file":"node.go","function":"github.com/algorand/go-algorand/node.(*AlgorandFullNode).broadcastSignedTxGroup","level":"info","line":540,"msg":"sent txgroup","name":"","time":"2023-07-28T19:03:58.599011Z","txns":[{"s":"IXUESXV6OHGTRUHF24H3NTMDMTOHFQEX2ACB2QPB7F7BWTQPREMURNOVQM","id":"XHC26DCZHQGZYUPW4ZTV3INEPNHPQPHJ2JUXUTZ2ZRK27GHZM3VQ"}]}

Relays:

{"Context":"Agreement","Hash":"M6PF4TJ3USEN2DT5VNORHIQX23DBF53QQS5YZNAVBRBQMNJMDNQA","ObjectPeriod":0,"ObjectRound":0,"ObjectStep":0,"Period":0,"Round":652,"Sender":"PPFBOHV7JM3VKBJGXCLNFD6LIDQG3GRF6WCKS3TZ3L4D5CEP2AUNCC7SEU","Step":0,"Type":"RoundStart","Weight":0,"WeightTotal":0,"file":"actions.go","function":"github.com/algorand/go-algorand/agreement.ensureAction.do","level":"info","line":262,"msg":"finished round 652","time":"2023-07-28T19:03:58.602858Z"}

{"Context":"Agreement","Hash":"M6PF4TJ3USEN2DT5VNORHIQX23DBF53QQS5YZNAVBRBQMNJMDNQA","ObjectPeriod":0,"ObjectRound":0,"ObjectStep":0,"Period":0,"Round":652,"Sender":"PPFBOHV7JM3VKBJGXCLNFD6LIDQG3GRF6WCKS3TZ3L4D5CEP2AUNCC7SEU","Step":0,"Type":"RoundStart","Weight":0,"WeightTotal":0,"file":"actions.go","function":"github.com/algorand/go-algorand/agreement.ensureAction.do","level":"info","line":262,"msg":"finished round 652","time":"2023-07-28T19:03:58.608026Z"}

{"Context":"Agreement","Hash":"M6PF4TJ3USEN2DT5VNORHIQX23DBF53QQS5YZNAVBRBQMNJMDNQA","ObjectPeriod":0,"ObjectRound":0,"ObjectStep":0,"Period":0,"Round":652,"Sender":"PPFBOHV7JM3VKBJGXCLNFD6LIDQG3GRF6WCKS3TZ3L4D5CEP2AUNCC7SEU","Step":0,"Type":"RoundStart","Weight":0,"WeightTotal":0,"file":"actions.go","function":"github.com/algorand/go-algorand/agreement.ensureAction.do","level":"info","line":262,"msg":"finished round 652","time":"2023-07-28T19:03:58.624633Z"}

Test Plan

Adjusted existing test.

cce
cce previously approved these changes Aug 1, 2023
winder
winder previously approved these changes Aug 1, 2023
@algorandskiy algorandskiy dismissed stale reviews from winder and cce via 95b2755 August 1, 2023 18:37
@algorandskiy
Copy link
Contributor Author

I fixed some tests that had implicit assumptions on FirstValid values. Two of them are e2e_subs that had logic sig checking FirstValid vs TIMEOUT_ROUND, and another is lease test for V22 consensus where lease range was [FirstValid, LastValid] and not [current - MaxTxnFile, current] as in V23+.

@algorandskiy algorandskiy requested review from cce and winder August 1, 2023 18:40
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #5622 (95b2755) into master (1bf7a21) will increase coverage by 0.06%.
Report is 1 commits behind head on master.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #5622      +/-   ##
==========================================
+ Coverage   54.95%   55.01%   +0.06%     
==========================================
  Files         463      463              
  Lines       64525    64528       +3     
==========================================
+ Hits        35457    35502      +45     
+ Misses      26684    26652      -32     
+ Partials     2384     2374      -10     
Files Changed Coverage Δ
libgoal/libgoal.go 2.43% <50.00%> (+0.13%) ⬆️

... and 12 files with indirect coverage changes

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

@cce
Copy link
Contributor

cce commented Aug 2, 2023

For comparison the SDK suggests you use firstvalid = lastRound, not lastRound+1
https://github.com/algorand/go-algorand-sdk/blob/7590afc86aa7be7e381ae5e6c86dfacc3b44b290/client/v2/algod/transactionParams.go#L24-L25

@algorandskiy
Copy link
Contributor Author

then we are in sync now, thank you for checking

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.

None yet

3 participants