Example of usage
Is there any example of how to use this library?
A related question is what functionality does the library actually provide (or plans to provide)?
For example, I want to write a testerchain that would take a JSON RPC request, like a regular node or some provider like Infura, and return a JSON RPC response like a node would. What part of it would be handled by evm?
Naturally I would handle serialization/deserialization to some typed values before passing them to evm. Managing filters would probably be my job too. But I am unclear about the basic functionality:
- Contract calls - seems to be handled by https://docs.rs/evm/latest/evm/fn.transact.html with
TransactArgsCallCreate::Call - Contract deployment - one would think
transact()withTransactArgsCallCreate::Create, but I don't see any signature data there. Does that mean that checking transaction signatures is not done withinevm? - Transfers - https://docs.rs/evm/latest/evm/backend/trait.RuntimeBackend.html#method.transfer ?
- Contract transactions (that is, mutating calls) - ???
- Block mining - ???
- Transactions/blocks lookup by hash - ???
The jsontests crate is probably the best way to understand example usage of this crate: https://github.com/rust-ethereum/evm/blob/master/jsontests/src/run.rs#L348
evm handles all the way up to contract transactions, but without the signature -- you first verify the signature (probably via the ethereum crate) and then pass the verified sender argument to evm. It does not do block mining or transaction/block lookup.
- Contract calls: yes this is correct.
- Contract deployment: yes,
transact/TransactArgsCallCreate::Createhandles this. It does not do transaction signature verification. Verify it first, and then pass the verified arguments toevm. - Transfers: the same as contract calls, so
transact/TransactArgsCallCreate::Call. - Contract transactions: also simply contract calls, so
transact/TransactArgsCallCreate::Call. - Block mining:
evmdoes not do that. Just increase thecoinbasebalance and you're done. Note thatevmhandles transaction fee payment as part of the contract transaction. - Transactions/blocks lookup by hash:
evmdoes not do that. This mapping needs to be stored externally.
Thank you for the explanation. Are there any plans within the org to add a crate that would handle these higher level tasks, block generation in particular?
The jsontests crate is probably the best way to understand example usage of this crate
That's what I've been using so far. While it may be the best way available, it's certainly not the best possible - there's a lot of indirection happening, and even finding a relevant test among the hundreds of obscure JSON files with no comments is problematic.
Are there any plans within the org to add a crate that would handle these higher level tasks, block generation in particular?
Yeah it'll be done by the ethereum crate. Note that ethereum crate is not yet ready for v1.0 and the interface will likely vastly change.
This separation of functionality is because many custom chains may not be using Ethereum signatures.
While it may be the best way available, it's certainly not the best possible - there's a lot of indirection happening, and even finding a relevant test among the hundreds of obscure JSON files with no comments is problematic.
I agree. The crate desperately lacks documentations and I'm working on this. :)