feat: adds costs test for completing withdrawals #314
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a unit tests that measures the amount of cost used when "maxing out" the number of individual withdrawals completed in a single transaction.
At the moment, the unit test completes 500 withdrawals in one tx. To view the costs of a transaction, run
pnpm test:report
, then opencontracts/costs-report.json
. Search for"test_name": "tests/sbtc-withdrawal.test.ts__optimization tests
to see that transaction's costs. The result with 500 withdrawals is:As you can see, the
read_count
is pretty close to the full block budget, so we can assume that ~600 is the upper limit without optimization. In general,read_count
is the metric that most blocks max out, so the fact that it's also our highest relative metric is important.On the other hand, I'm not so sure that making a batch call to
.sbtc-registry
would help that much, because (I think) eachcontract-call?
is only 1 extraread_count
. Additionally,sbtc-registry
will need to validate the contract caller each time, so that's another single read per call. So, we'd reduce the read count by 1000, but that's not that much of an optimization (compared to what I thought it could be).