eosnetworkfoundation/eos-evm-contract

Upgrade EOS EVM version

Closed this issue · 1 comments

Depends on #671

We need to modify the config singleton to capture the cached active protocol version and any pending changes to the version.

The config singleton needs some accessor function (std::pair<uint64_t, bool> get_version(block_timestamp current_time) const) that takes the current EOS block timestamp as an argument and returns what the current active protocol version is for this block as well as a boolean to indicate whether clean up is required. If there is no pending change to the version, it simply returns the cached active protocol version (and indicates cleanup is not required). Otherwise, it should use the EOS block timestamp stored with the pending version change to map that to the virtual EVM block height. It should also map the current EOS block timestamp to the corresponding virtual EVM block height. If that latter mapped block height is strictly greater than the prior mapped block height then it should return the version number stored as part of the pending change (and indicates that cleanup is required). Otherwise, it should return the cached active protocol version (and indicates that cleanup is not required).

The config singleton also needs two mutator function:

  • bool clean_up_version(block_timestamp current_time): This attempts to clean up the fields related to the current protocol version so that the cached active protocol version reflects the current active protocol version and any pending changes to the version have been removed. If there were no changes needed, it returns false; otherwise it returns true.
  • void set_version(uint64_t new_version, block_timestamp current_time): This first calls clean_up_version. Then it replaces the pending change to the version with a new one set to the new_version (and with the associated timestamp set to current_time).

We need a new action, setversion that require_auth(get_self()). This action needs to validate that the version is supported by the contract and is greater than the current active protocol version (as determined by the accessor function). The action should set the new version using the set_version mutator on the config singleton.

On any action that executes an EVM transaction (pushtx, call, admincall, exec) should call get_version from the config singleton to determine the active EOS EVM protocol version to use when executing the EVM transaction. Furthermore, on any action that executes an EVM transaction and emits an evmtx action (pushtx, call, admincall) it should check the boolean returned from get_version to determine if clean up is required. If cleanup is required it should call clean_up_version before the end of the action. Additionally the inline evmtx that is generated should include the version that was retrieved by get_version.

Closing since this task was subsumed by #671.