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(anvil): support better debugging flows when using anvil programmatically via EthApi #3558

Open
4 tasks
Tracked by #8269
reem opened this issue Oct 26, 2022 · 7 comments
Open
4 tasks
Tracked by #8269
Labels
A-extensions Area: extensions C-anvil Command: anvil T-feature Type: feature

Comments

@reem
Copy link
Contributor

reem commented Oct 26, 2022

Component

Anvil

Describe the feature you would like

There are several features which would be useful to support out of the box with anvil when using it via EthApi that already have some level of support within forge:

  • Ability to query for transaction exit reason/revert message given transaction hash
  • Ability to get some form of stack trace from a reverted transaction given transaction hash
  • Ability to programmatically access transaction traces as offered with logging and within forge
  • Ability to get console.log outputs (as returned data, not logged) from a transaction given the transaction hash

Probably there are even more features available in forge that would be useful to expose here that I am not thinking of!

Additional context

Some of this data is available internally already e.g. here

let info = TransactionInfo {
transaction_hash: *transaction.hash(),
transaction_index,
from: *transaction.pending_transaction.sender(),
to: transaction.pending_transaction.transaction.to().copied(),
contract_address,
logs,
logs_bloom: *receipt.logs_bloom(),
traces: CallTraceArena { arena: traces },
exit,
out: match out {
TransactOut::Call(b) => Some(b.into()),
TransactOut::Create(b, _) => Some(b.into()),
_ => None,
},
};
but it is not forwarded to be easily accessible via EthApi

@reem reem added the T-feature Type: feature label Oct 26, 2022
@gakonst gakonst added this to Foundry Oct 26, 2022
@gakonst gakonst moved this to Todo in Foundry Oct 26, 2022
@mattsse
Copy link
Member

mattsse commented Oct 26, 2022

thanks for this.

supportive of this, since we already have (all|most?) of the data, we need to figure out how to make it available.

Perhaps with some additional helper functions/types that are Tx + DebugInfo or something?

@reem
Copy link
Contributor Author

reem commented Oct 26, 2022

Additional functions that also return debug info would work, it would be doubly nice to make this info accessible when using anvil over rpc but I also think it would still be valuable if exposed first as just methods on EthApi

@mattsse
Copy link
Member

mattsse commented Oct 26, 2022

makes sense, perhaps the easiest way to integrate this is to adapt this

fn mined_transaction_by_hash(&self, hash: H256) -> Option<Transaction> {
let (info, block) = {
let storage = self.blockchain.storage.read_recursive();
let MinedTransaction { info, block_hash, .. } =
storage.transactions.get(&hash)?.clone();
let block = storage.blocks.get(&block_hash).cloned()?;
(info, block)
};
let tx = block.transactions.get(info.transaction_index as usize)?.clone();
Some(transaction_build(tx, Some(&block), Some(info), true, block.header.base_fee_per_gas))
}

so it returns a TransactionInfo which is TX+additional stuff extracted from storage

@rkrasiuk rkrasiuk added the C-anvil Command: anvil label Oct 28, 2022
@Alexintosh
Copy link

I would love to see this happen, it's a bit of a missing piece right now.

@mattsse
Copy link
Member

mattsse commented Dec 1, 2022

@Alexintosh are you referring to this being available programmatically or via RPC?

@rickbeeloo
Copy link

Is it already possible to debug anvil transactions?

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@zerosnacks zerosnacks added the A-extensions Area: extensions label Aug 7, 2024
@zerosnacks zerosnacks removed this from the v1.0.0 milestone Aug 7, 2024
@zerosnacks zerosnacks changed the title Support better debugging flows when using anvil programmatically via EthApi feat(anvil): support better debugging flows when using anvil programmatically via EthApi Aug 7, 2024
@zerosnacks
Copy link
Member

@reem is this still relevant to your use case? If so, I think the best next step is to break this ticket up into its own actionable tickets so they can be picked up. I'm supportive of improving programmatic access to Anvil though it may be more of a design goal for Anvil-on-Reth post-1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-extensions Area: extensions C-anvil Command: anvil T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

6 participants