-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve nops broadcasting. #150
Conversation
Not sure why it sometimes fail. After sprinkling some printf all over the code, I found out when the test fails, it's because of this: https://github.com/perlin-network/wavelet/blob/master/ledger.go#L292-L297 Somehow, sometimes EDIT: this happened because the test does not wait for the faucet tx to be applied. This commit fixed it: 38e2e08 |
ledger.go
Outdated
return broadcastNops | ||
} | ||
|
||
// WaitForConsensus blocks until the ledger reaches consensus. |
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.
@iwasaki-kenta Need your thought on this. WaitForConsensus
is basically added purely for testing purposes. What it does is it waits for a round to be finalized, or timeout if it takes too long. I'm not sure if it will impact the ledger in production, as it involves using a mutex. And it doesn't feel right to me at the moment.
Is there a better way to do this? Basically I just need a way to listen for a finalized round when testing. Otherwise either I'll just use time.Sleep
(which makes the test run longer), or somehow poll the HTTP API to see if the round has increased.
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.
Nvm, I just polled ledger.Round().Latest().Index
to see if the round increased, and it works quite well.
Here's a result of running
Out of 96 runs, the test failed 3 times. 2 times it failed due to |
After latest adjustments to
|
Tested it thoroughly; transactions are being finalized much more nicely now. LGTM. |
This PR modifies the behavior of nop broadcasting such that the ledger will continue broadcasting nops until all of the sender's transactions has been applied (i.e. graph root depth >= highest transaction depth added).
TODO: