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

Executor trait #79

Open
DemiMarie opened this issue Jan 30, 2019 · 1 comment
Open

Executor trait #79

DemiMarie opened this issue Jan 30, 2019 · 1 comment

Comments

@DemiMarie
Copy link

We need an Executor trait for executing calls from Rust to the EVM.

@afck
Copy link
Collaborator

afck commented Feb 4, 2019

Let's first try to get an overview of which types and implementations already exist, to avoid 927.

SystemCall is an alias for FnMut(Address, Vec<u8>) -> Result<Vec<u8>, String> + 'a. It takes a contract address and encoded parameters and returns the result. It's meant for system calls, i.e. calls by the system address outside of transactions.

SystemOrCodeCall is similar, but it allows you alternatively to pass in the code to be executed, instead of the address of the code.

engines::default_system_or_code_call takes an EthereumMachine and an ExecutedBlock and returns a SystemOrCodeCall that will call:

EthereumMachine::execute_as_system resp. EthereumMachine::execute_code_as_system executes code at an address resp. passed in code on a specified block with the sender equal to SYSTEM_ADDRESS, modifying the block state, but not storing a transaction or logs on the block, or counting towards the gas limit.

OpenBlock::push_transaction, on the other hand, takes a transaction, stores it on the block, executes it and stores the receipt and traces as well. (It can do that because OpenBlock wraps not only a block but also an engine.)

Client::call_contract runs a constant call on a specified block number and returns the result. (Internally, it creates a transaction, but it doesn't actually queue it or push it onto any block.) It takes the block number, address and encoded input data, and returns the encoded output data. Internally it uses the somewhat lower-level:

Executive, which wraps a state and a machine, and can use them to execute a transaction. (Note that transact_virtual seems to do the same thing but with unlimited gas; it's not really virtual…)

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

No branches or pull requests

2 participants