-
Notifications
You must be signed in to change notification settings - Fork 295
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
[tracer][core] call tracer module when insert blocks #3799
Conversation
@peekpi can you add some experimental results on the improvements before and after this optimization? |
@peekpi generally looks good. please add some experimental results. thanks. |
@peekpi do you have some benchmarking results? |
added comparison of execution time. the times in the table do not include network transfer times, although network transfer times can be large. |
@@ -50,6 +51,110 @@ func (c *action) push(ac *action) { | |||
c.subCalls = append(c.subCalls, ac) | |||
} | |||
|
|||
func (c *action) fromStorage(blockStorage *TraceBlockStorage, acStorage *ActionStorage) { |
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.
Are these code from existing codebase or it's new code?
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.
new code
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package tracers |
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.
same here for this file. Is it just reuse of code from other repo?
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.
also new code
I tested this rpc, and it worked fine. |
here's another issue, when inserting a new block, it uses HMY tx hash, and the tracer store this hash to DB. but the output requires an ETH tx hash. changing tx hash in the block insertion function is a dangerous operation, I need to think about how to do it. |
I think it works fine now. but due to the DB has been written some wrong history trace data, the node can only return correct trace results while block >= 21212710. @sophoah |
@peekpi as discussed you mentioned |
Tested the latest build, and the http rpc call result returns the same output
|
Tested HTTP RPC API with Postman, interesting results for big blocks (900+ transactions) Note: 1) Internal node
2) Test node
Returned data content is equal |
According to my test results in July, the block execution time will increase by about 20%. This effect occurs only when trace is enabled. |
I think most of the time is spent on data transfer, the data generation should be less than 100ms. For faster access, consider enabling GZIP compression and access over the AWS internal network. |
Since this only happens on the archival nodes. It won't impact consensus. Will only make the archival node slower to process blocks (cause syncing slowness) |
ah right so only the slower sync |
There is another issue with go version trace_block, should merge #4064 first. |
@peekpi is it possible to have this feature enabled on demand (through harmony config and cli args) ? We know this only allow be used by explorer archival node, but considering the additional disk space it takes, having an option to to enable it or not would be useful. |
yes. use
and this feature does not require an archival node, but only archival nodes can trace historical block/tx. |
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.
LGTM
Issue
#3780 calculate trace result when first execute the block, and store it into leveldb.
2021-06-27:
The trace result has been stored in the Explorer DB and can be queried by RPC.
The remaining issue is that the trace data can be large and needs to be optimized.
The current implementation is to store the json data into the db, so need a more compact serialization method.
2021-07-01:
Storage for trace results is complete, but I need to write some unit tests.
The storage store the key values separately so that duplicate data only needs to be stored once.
2021-07-02:
Development and testing are complete. I test it with a mainnet node, and it works fine and stable.
When querying trace data via trace_block rpc, first try to read DB, if not found, then re-execute the block.
Tracing Enable
cmd flag
--tracing=true
config file
Test
Test with 11 blocks:
4.4M of data has been written to DB for 11 blocks (key+value). if use gizp to compress these data, the total size reduced to 225k. if use snappy (used by leveldb default) to compress these data, the total size reduced to 1.1M.
Unit Test Coverage
Before:
After:
Test/Run Logs
Operational Checklist
Does this PR introduce backward-incompatible changes to the on-disk data structure and/or the over-the-wire protocol?. (If no, skip to question 8.)
NO
Does this PR introduce backward-incompatible changes NOT related to on-disk data structure and/or over-the-wire protocol? (If no, continue to question 11.)
NO
Does this PR introduce significant changes to the operational requirements of the node software, such as >20% increase in CPU, memory, and/or disk usage?
** YES **
if an explorer node is enabled tracing flag: