trailofbits/manticore

Feature request: Improve API to retrieve transactions

Open

#1,594 创建于 2020年1月23日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Python (3,469 star) (481 fork)batch import
ethereumhelp wantedidea

描述

A common mistake in our scripts has this pattern:

contract = create[....]
contract.f1(..)
contract.f1(..) // we want to return value here
contract.f1(..)
contract.f1(..)
for state in m.ready_states:

    second_f1_call_transaction = state.platform.transactions[1]

Here state.platform.transactions[1] will not be the second call to f1, but the first. Because the first transactions of the platform will be the contract's deployement.

For complex scripts, that are split through multiple files, it's also more complex to determine what index should be given to state.platform.transactions.

An alternative would be to return an object after the functions calls, like

first_tx = contract.f1(..)

And be able to access the state's related transaction later, either through something like

transaction = state.platform.get_transaction(first_tx)

or

transaction = first_tx.get_transaction(state | state_id)

I see one caveat though, for contract's creation, m.solidity_create_contract already returns an object. I see two solutions:

  • Return a tuple, but that might just overcomplexity the API
  • Not return the tx-object, but have it accessible through the contract (like contract.tx_creation).

Note that here tx is maybe not a good name, as the object will, in fact, refers to the set of transactions for all the states

Any thoughts?

贡献者指南

Feature request: Improve API to retrieve transactions · trailofbits/manticore#1594 | Good First Issue