-
Notifications
You must be signed in to change notification settings - Fork 723
Feat/blocksimulate endpoint #6724
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
base: develop
Are you sure you want to change the base?
Feat/blocksimulate endpoint #6724
Conversation
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (63.16%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## develop #6724 +/- ##
============================================
- Coverage 78.18% 63.16% -15.02%
============================================
Files 580 582 +2
Lines 361096 361566 +470
============================================
- Hits 282312 228373 -53939
- Misses 78784 133193 +54409
... and 401 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
| debug!("Process transaction {} ({})", tx.txid(), tx.payload.name()); | ||
| let epoch = clarity_block.get_epoch(); | ||
|
|
||
| let no_fees = clarity_block.block.no_fees; |
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.
Correct me if I'm wrong, but the purpose of this endpoint is to faithfully re-execute a block. The block will almost certainly contain transactions for transferring assets between accounts (including STX). Disabling fee payment along with the commensurate nonce increment would likely invalidate or otherwise alter the execution of transactions, leading to an unfaithful block re-execution.
Can you help me understand what purpose is served by this feature?
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.
The block simulator allows you to execute "brand-new" transactions in a block (mainly as a quick-test mechanism). The (current) main usage is to run contract deploys and calls at specific heights (for example i am using it as the base for some integration tests for the python bindings). It happens sometime (especially when randomly generating keys) that having STXs is convoluted (in practice you are running your functions in the past). For this reason having the ability to run stuff "for free" is quite handy. Obviously if it does pose some risk it is definitely a feature that can be removed without harming the main goal of the patch.
Description
This patch introduces a new (protected) endpoint based on the block_replay, able to "simulate" a block (at a specific height) with a brand new set of transactions.
Transactions have to be passed as the HTTP body as a json array of hex strings (the serialized transaction).
The output is the same structure of the block replay endpoint. (so events and results are included)
This endpoint can be used for quick testing of contracts deploys/calls, or for reproducing specific scenarios in security checks/auditing.
The profiler feature of the block_replay is included too (only for linux x86-64)
Applicable issues
Additional info (benefits, drawbacks, caveats)
The patch refactors the block-replay endpoint too for allowing sharing of code between the two (replay and simulation).
A new option "disable_fees" has been added to the endpoint for allowing transactions to be executed without accounting for fees. This is is useful for those situation where the sender of a simulated transaction cannot get STXs assigned easily (for example when it is randomly generated)
Checklist
docs/rpc/openapi.yamlandrpc-endpoints.mdfor v2 endpoints,event-dispatcher.mdfor new events)clarity-benchmarkingrepo