ref-fvm icon indicating copy to clipboard operation
ref-fvm copied to clipboard

EVM opcodes: TIMESTAMP, BLOCKHASH, CHAINID, GASLIMIT

Open maciejwitowski opened this issue 3 years ago • 0 comments

Implement opcodes which require FVM, ffi, and client work https://github.com/filecoin-project/ref-fvm/issues/689#issuecomment-1208032152

  • [ ] TIMESTAMP => the timestamp is an attribute in the block header; needs a syscall and snake through the ffi from the client.
  • [ ] BLOCKHASH => this is tricky. I don't think we can return just the hash of the first block in the parent tipset, as we probably lose some security in the face of a reorg that preserves the first block.
  • [ ] CHAINID => return value zero until #681?
  • [ ] GASLIMIT => returns the block's gas limit. We may need a syscall or a context parameter to return this value to avoid hardcoding the 15B gas assumption.

Consider:

  1. Putting these attributes behind a chain_data() syscall. These are really "environmental attributes" not scoped to the message (unlike InvocationContext).
  2. Adding them to the InvocationContext returned by vm::context(), but that would bloat the struct for cases that do not need to access all attributes (likely not a big deal, it'll be some ~64 bytes extra)

maciejwitowski avatar Sep 12 '22 13:09 maciejwitowski