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

feat: ETH TRACE API: Trace installed bytecode in the Ethereum JSON-RPC trace_block output #11984

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aarshkshah1992
Copy link
Contributor

Related Issues

Closes #11635.

Proposed Changes

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@aarshkshah1992
Copy link
Contributor Author

@Stebalien Does this look correct ?

if deployedCode != nil {
var getBytecodeReturn evm12.GetBytecodeReturn
if err := getBytecodeReturn.UnmarshalCBOR(bytes.NewReader(et.MsgRct.Return)); err == nil && getBytecodeReturn.Cid != nil {
deployedCode[abi.ActorID(id)] = getBytecodeReturn.Cid
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Stebalien This is not correct. How do I get the byte code of the contract here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to make a call to the GetBytecode method of the contract Actor ?
Looks like none of the trace types we here have the byte code in them.

@jennijuju
Copy link
Member

cc @eshon this PR should fix the issue you brought up in our 1:1!

Copy link

All checks have completed

❌ Failed Check / Check (lint-all) (pull_request)

Comment on lines +893 to +896
var deployed map[abi.ActorID]*cid.Cid
if ir.MsgRct.ExitCode.IsSuccess() {
deployed = deployedCode
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do this per sub-trace. The top-level message can succeed while sub-messages cain fail.

Basically, move this into buildTraces and, if the receipt of the currently processed message has a non-zero exit code, set this to nil for the sub-call.

Comment on lines +929 to +930
for _, trace := range allTraces {
switch r := trace.Result.(type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct, we want to update the last one only. The idea was to record a pointer to r.Code in deployedCode, so we could set it without even having to look at the traces. That is:

deployedCode := make(map[abi.ActorID]*EthBytes)

Then, inside the buildTraces logic, we'd record deployedCode[receiverID] = &r.Code.

Finally, we'd iterate over deployedCode and set *deployedCode[receiverID] = loadByteCode(receiverID), as long as the receiver is still live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eth API: Trace installed bytecode in the Ethereum JSON-RPC trace_block output
3 participants