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

EVM-C: Classification of external data for EVM #110

Closed
chfast opened this issue Dec 27, 2016 · 7 comments
Closed

EVM-C: Classification of external data for EVM #110

chfast opened this issue Dec 27, 2016 · 7 comments
Assignees

Comments

@chfast
Copy link
Member

chfast commented Dec 27, 2016

This document tries to organize external data needed to perform any execution in EVM. The hypothesis is:

  • Message data should be always provided to the EVM (as function argument),
  • Transaction and block data should be provided to the EVM on demand. Good EVMs should request it at most once per transaction.
  • Information about accounts should be requested every time needed. Smart EVMs might try to avoid redundant queries, but this is hard and probably will duplicate efforts in high level languages.

Message

Immutable data:

  • GAS
  • ADDRESS
  • CALLER (aka sender)
  • VALUE
  • CALLDATA (aka input data)
  • CALL DEPTH

Functions:

  • log(data, topics)

The message contains immutable data valid for the current call. ~112 bytes in total, but might be bigger if extended by code and code hash.
The log() function attaches logs to the current message. All logs attached should be discarded if the message execution fails.

Transaction & Block

Immutable data:

  • ORIGIN
  • GAS PRICE
  • COINBASE
  • GAS LIMIT
  • NUMBER
  • TIMESTAMP
  • DIFFICULTY

Functions:

  • blockhash(number)

Information about the current transaction and block is mostly immutable data that are valid for the whole transactions (all calls in it). ~136 bytes in total.
The blockhash() function provides hashes of 256 recent blocks (8192 bytes of information in total).

State (accounts)

Query functions:

  • balance(address)
  • get_storage(address, key)
  • exists(address)
  • code(address)
  • code_size(address)

Update functions:

  • set_storage(address, key, value)
  • selfdestruct(address, beneficiary)
  • create(creator, code)

This provides information about accounts in the state, so address is always a required argument.

@chfast
Copy link
Member Author

chfast commented Dec 27, 2016

Python implementation might be closest to this, C++ on the other hand has additional abstraction layer that flattens account access (no address argument required). Go is somewhere in the middle, probably closer to Python anyway.

@gcolvin
Copy link

gcolvin commented Dec 27, 2016

So in C++ you have an Address class with balance() and kin as member functions?

@chfast
Copy link
Member Author

chfast commented Dec 27, 2016

@chriseth
Copy link
Contributor

What is the overhead of just providing all the immutable data at the point of the call in a flat byte array?

@chfast
Copy link
Member Author

chfast commented Jan 11, 2017

In case of transaction & block data it is the cost of the accesing and coping the data -- ~136 bytes (no matter if the application has the data in already in the single array or not). I'm gessing it is the same order of cost as the call itself. Because it is immutable per transaction the EVM will not need to ask for it in the same call/transaction again.

I can do some microbenchmarks if needed.

@chfast chfast mentioned this issue Jan 11, 2017
@chriseth
Copy link
Contributor

Ok, looks good to me!

@chfast chfast mentioned this issue Jan 18, 2017
@chfast chfast self-assigned this Apr 26, 2017
@axic
Copy link
Member

axic commented Aug 18, 2017

I think this is closed now?

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

4 participants