Library MonadVM.Host
File generated by rocq-of-ocaml
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import RocqOfOCaml.Settings.
Require Import MonadVM.Support.UintN.
Require MonadVM.Byte_string.
Require MonadVM.Chain.Ethereum.
Require MonadVM.Chain.Monad.
Require MonadVM.Crypto.
Require MonadVM.Delegation.
Require MonadVM.Evmc.
Require MonadVM.Gas.
Require MonadVM.Int64.
Require MonadVM.Map.
Require MonadVM.Monad.
Require MonadVM.Numeric.
Require MonadVM.Precompiles.
Require MonadVM.Reserve_balance.
Require MonadVM.State.
Require MonadVM.String.
Require MonadVM.Traits.
Require MonadVM.Uint64.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import MonadVM.Support.TransactionStateNotation.
Local Open Scope transaction_state_scope.
Module TS := MonadVM.State.TransactionState.
Module WS := MonadVM.State.WorldState.
Module Account := MonadVM.Chain.Ethereum.Account.
Module Address := MonadVM.Chain.Ethereum.Address.
Module Header := MonadVM.Chain.Ethereum.Block.Header.
Module Block := MonadVM.Chain.Ethereum.Block.
Module U256 := MonadVM.Numeric.U256.
Module Uint := MonadVM.Support.UintN.
Module Revision := MonadVM.Chain.Monad.Revision.
Module SM := MonadVM.Monad.State.State_result.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
Require Import RocqOfOCaml.Settings.
Require Import MonadVM.Support.UintN.
Require MonadVM.Byte_string.
Require MonadVM.Chain.Ethereum.
Require MonadVM.Chain.Monad.
Require MonadVM.Crypto.
Require MonadVM.Delegation.
Require MonadVM.Evmc.
Require MonadVM.Gas.
Require MonadVM.Int64.
Require MonadVM.Map.
Require MonadVM.Monad.
Require MonadVM.Numeric.
Require MonadVM.Precompiles.
Require MonadVM.Reserve_balance.
Require MonadVM.State.
Require MonadVM.String.
Require MonadVM.Traits.
Require MonadVM.Uint64.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import MonadVM.Support.TransactionStateNotation.
Local Open Scope transaction_state_scope.
Module TS := MonadVM.State.TransactionState.
Module WS := MonadVM.State.WorldState.
Module Account := MonadVM.Chain.Ethereum.Account.
Module Address := MonadVM.Chain.Ethereum.Address.
Module Header := MonadVM.Chain.Ethereum.Block.Header.
Module Block := MonadVM.Chain.Ethereum.Block.
Module U256 := MonadVM.Numeric.U256.
Module Uint := MonadVM.Support.UintN.
Module Revision := MonadVM.Chain.Monad.Revision.
Module SM := MonadVM.Monad.State.State_result.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
The division of responsibilities introduced by the EVMC API makes it so that Host and VM modules depend
on each other, as a host needs access to a VM to implement the {!Evmc.HOST.call} method and a VM needs
access to a host to interact with the blockchain. This mutual recursion is handled here by the
{!Instantiate} functor below.
In addition to the functions required by the {!Evmc.HOST} interface, this module also exposes
call_from_eoa which executes a call or create caused by a user-sent transaction (as opposed to
a CALL or CREATE opcode in a smart contract).
Module Make.
Class FArgs := {
ChainParams : MonadVM.Chain.Monad.PARAMS;
Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
}.
Module StorageKey := MonadVM.State.TransactionState.StorageKey.
Definition t `{_fargs : FArgs} := MonadVM.State.TransactionState.t.
Module TLens := MonadVM.State.TransactionState.TLens.
Definition initial_world_state `{_fargs : FArgs} : Lens.t TS.t WS.t :=
MonadVM.State.TransactionState.initial_world_state.
Definition world_state `{_fargs : FArgs} : Lens.t TS.t WS.t :=
MonadVM.State.TransactionState.world_state.
Definition current_block `{_fargs : FArgs} : Lens.t TS.t Block.t :=
MonadVM.State.TransactionState.current_block.
Definition accounts_created_in_current_transaction `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accounts_created_in_current_transaction.
Definition tx_origin `{_fargs : FArgs} : Lens.t TS.t Address.t :=
MonadVM.State.TransactionState.tx_origin.
Definition tx_gas_price `{_fargs : FArgs} : Lens.t TS.t MonadVM.Gas.t :=
MonadVM.State.TransactionState.tx_gas_price.
Definition tx_gas_limit `{_fargs : FArgs} : Lens.t TS.t MonadVM.Gas.t :=
MonadVM.State.TransactionState.tx_gas_limit.
Definition self_destruct `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.self_destruct.
Definition logs `{_fargs : FArgs} :
Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t) :=
MonadVM.State.TransactionState.logs.
Definition refund `{_fargs : FArgs} : Lens.t TS.t U256.t :=
MonadVM.State.TransactionState.refund.
Definition accessed_addresses `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accessed_addresses.
Definition accessed_keys `{_fargs : FArgs} :
Lens.t TS.t StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accessed_keys.
Definition empty `{_fargs : FArgs} : TS.t :=
MonadVM.State.TransactionState.empty.
Definition make `{_fargs : FArgs} :
MonadVM.State.BlockState.t → Address.t →
MonadVM.Chain.Ethereum.Transaction.t → TS.t :=
MonadVM.State.TransactionState.make.
Definition account `{_fargs : FArgs} :
option bool → Address.Map.key → Lens.t TS.t Account.t :=
MonadVM.State.TransactionState.account.
Definition initialize_access_sets `{_fargs : FArgs} :
MonadVM.Chain.Ethereum.Transaction.t → TS.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → TS.t :=
MonadVM.State.TransactionState.initialize_access_sets.
Definition M `{_fargs : FArgs} := MonadVM.State.TransactionState.M.
Definition Precompiles_fargs `{_fargs : FArgs} :=
MonadVM.Precompiles.Make.Build_FArgs ltac:(refine (_ :
MonadVM.Precompiles.Make_Revision_signature); constructor; [refine (ChainParams.(MonadVM.Chain.Monad.PARAMS.revision))]; shelve).
Definition Precompiles `{_fargs : FArgs} :
MonadVM.Precompiles.Make.Make_result (_fargs := Precompiles_fargs) :=
(MonadVM.Precompiles.Make.functor (_fargs := (Precompiles_fargs ))).
Definition transfer_ether `{_fargs : FArgs}
(sender : Address.Map.key) (recipient : Address.Map.key)
(amount : U256.Impl.(MonadVM.Numeric.Make.Impl.Impl_signature.t))
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* sender_balance :=
read
(Lens.Infix.op_pipeminusminus (account None sender)
Account.TLens.balance) in
if U256.op_gteq sender_balance amount then
let* '_ :=
(M.(SM.op_coloneq) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None sender)
Account.TLens.balance) (U256.op_minus sender_balance amount) in
let* '_ :=
(M.(SM.update_field) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None recipient)
Account.TLens.balance)
(fun (eth : U256.t) ⇒ U256.op_plus eth amount) in
return true
else
return false.
Class FArgs := {
ChainParams : MonadVM.Chain.Monad.PARAMS;
Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
}.
Module StorageKey := MonadVM.State.TransactionState.StorageKey.
Definition t `{_fargs : FArgs} := MonadVM.State.TransactionState.t.
Module TLens := MonadVM.State.TransactionState.TLens.
Definition initial_world_state `{_fargs : FArgs} : Lens.t TS.t WS.t :=
MonadVM.State.TransactionState.initial_world_state.
Definition world_state `{_fargs : FArgs} : Lens.t TS.t WS.t :=
MonadVM.State.TransactionState.world_state.
Definition current_block `{_fargs : FArgs} : Lens.t TS.t Block.t :=
MonadVM.State.TransactionState.current_block.
Definition accounts_created_in_current_transaction `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accounts_created_in_current_transaction.
Definition tx_origin `{_fargs : FArgs} : Lens.t TS.t Address.t :=
MonadVM.State.TransactionState.tx_origin.
Definition tx_gas_price `{_fargs : FArgs} : Lens.t TS.t MonadVM.Gas.t :=
MonadVM.State.TransactionState.tx_gas_price.
Definition tx_gas_limit `{_fargs : FArgs} : Lens.t TS.t MonadVM.Gas.t :=
MonadVM.State.TransactionState.tx_gas_limit.
Definition self_destruct `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.self_destruct.
Definition logs `{_fargs : FArgs} :
Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t) :=
MonadVM.State.TransactionState.logs.
Definition refund `{_fargs : FArgs} : Lens.t TS.t U256.t :=
MonadVM.State.TransactionState.refund.
Definition accessed_addresses `{_fargs : FArgs} :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accessed_addresses.
Definition accessed_keys `{_fargs : FArgs} :
Lens.t TS.t StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t) :=
MonadVM.State.TransactionState.accessed_keys.
Definition empty `{_fargs : FArgs} : TS.t :=
MonadVM.State.TransactionState.empty.
Definition make `{_fargs : FArgs} :
MonadVM.State.BlockState.t → Address.t →
MonadVM.Chain.Ethereum.Transaction.t → TS.t :=
MonadVM.State.TransactionState.make.
Definition account `{_fargs : FArgs} :
option bool → Address.Map.key → Lens.t TS.t Account.t :=
MonadVM.State.TransactionState.account.
Definition initialize_access_sets `{_fargs : FArgs} :
MonadVM.Chain.Ethereum.Transaction.t → TS.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → TS.t :=
MonadVM.State.TransactionState.initialize_access_sets.
Definition M `{_fargs : FArgs} := MonadVM.State.TransactionState.M.
Definition Precompiles_fargs `{_fargs : FArgs} :=
MonadVM.Precompiles.Make.Build_FArgs ltac:(refine (_ :
MonadVM.Precompiles.Make_Revision_signature); constructor; [refine (ChainParams.(MonadVM.Chain.Monad.PARAMS.revision))]; shelve).
Definition Precompiles `{_fargs : FArgs} :
MonadVM.Precompiles.Make.Make_result (_fargs := Precompiles_fargs) :=
(MonadVM.Precompiles.Make.functor (_fargs := (Precompiles_fargs ))).
Definition transfer_ether `{_fargs : FArgs}
(sender : Address.Map.key) (recipient : Address.Map.key)
(amount : U256.Impl.(MonadVM.Numeric.Make.Impl.Impl_signature.t))
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* sender_balance :=
read
(Lens.Infix.op_pipeminusminus (account None sender)
Account.TLens.balance) in
if U256.op_gteq sender_balance amount then
let* '_ :=
(M.(SM.op_coloneq) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None sender)
Account.TLens.balance) (U256.op_minus sender_balance amount) in
let* '_ :=
(M.(SM.update_field) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None recipient)
Account.TLens.balance)
(fun (eth : U256.t) ⇒ U256.op_plus eth amount) in
return true
else
return false.
{!Evmc.HOST.account_exists}
Definition account_exists `{_fargs : FArgs} (addr : Address.Map.key)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
(M.(SM.op_ltdollargt) (B := bool) (A := option Account.t))
M.(SM.Option_is_some)
(read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus world_state WS.accounts)
(Address.Map._at addr))).
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
(M.(SM.op_ltdollargt) (B := bool) (A := option Account.t))
M.(SM.Option_is_some)
(read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus world_state WS.accounts)
(Address.Map._at addr))).
{!Evmc.HOST.get_storage}
Definition get_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) : M.(SM.t) string :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account None addr) Account.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))).
(addr : Address.Map.key) (key : string) : M.(SM.t) string :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account None addr) Account.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))).
{!Evmc.HOST.set_storage}
Definition set_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) (v_value : string)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.StorageStatus.t × TS.t) :=
let* o_value :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus initial_world_state
(WS.account None addr)) Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)))
in
let* c_value :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account None addr)
Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)))
in
let* '_ :=
(M.(SM.op_coloneq) (x := option string))
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account (Some true) addr)
Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(if
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
v_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
then
None
else
Some v_value) in
let zero (u_value : string) : bool :=
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
in
let x_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value o_value) in
let y_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value o_value)
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value c_value)) in
let z_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value o_value)
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value c_value)
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value v_value))) in
return
match
(tt,
(let '_ := tt in
andb (zero o_value) (andb (zero c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (x_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (x_value c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (zero c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (y_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (zero c_value) (x_value v_value))),
(let '_ := tt in
andb (zero o_value) (andb (y_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (y_value c_value) (x_value v_value))))
with
| (_, true, _, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Added
| (_, _, true, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Deleted
| (_, _, _, true, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Modified
| (_, _, _, _, true, _, _, _, _) ⇒
MonadVM.Evmc.StorageStatus.DeletedAdded
| (_, _, _, _, _, true, _, _, _) ⇒
MonadVM.Evmc.StorageStatus.ModifiedDeleted
| (_, _, _, _, _, _, true, _, _) ⇒
MonadVM.Evmc.StorageStatus.DeletedRestored
| (_, _, _, _, _, _, _, true, _) ⇒
MonadVM.Evmc.StorageStatus.AddedDeleted
| (_, _, _, _, _, _, _, _, true) ⇒
MonadVM.Evmc.StorageStatus.ModifiedRestored
| (_, _, _, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Assigned
end.
(addr : Address.Map.key) (key : string) (v_value : string)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.StorageStatus.t × TS.t) :=
let* o_value :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus initial_world_state
(WS.account None addr)) Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)))
in
let* c_value :=
read
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account None addr)
Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)))
in
let* '_ :=
(M.(SM.op_coloneq) (x := option string))
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus (account (Some true) addr)
Account.TLens.storage)
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(if
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
v_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
then
None
else
Some v_value) in
let zero (u_value : string) : bool :=
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
in
let x_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value o_value) in
let y_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value o_value)
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value c_value)) in
let z_value (u_value : string) : bool :=
andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros))
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value o_value)
(andb
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_ltgt)
u_value c_value)
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.op_eq)
u_value v_value))) in
return
match
(tt,
(let '_ := tt in
andb (zero o_value) (andb (zero c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (x_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (x_value c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (zero c_value) (z_value v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (y_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (zero c_value) (x_value v_value))),
(let '_ := tt in
andb (zero o_value) (andb (y_value c_value) (zero v_value))),
(let '_ := tt in
andb (x_value o_value) (andb (y_value c_value) (x_value v_value))))
with
| (_, true, _, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Added
| (_, _, true, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Deleted
| (_, _, _, true, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Modified
| (_, _, _, _, true, _, _, _, _) ⇒
MonadVM.Evmc.StorageStatus.DeletedAdded
| (_, _, _, _, _, true, _, _, _) ⇒
MonadVM.Evmc.StorageStatus.ModifiedDeleted
| (_, _, _, _, _, _, true, _, _) ⇒
MonadVM.Evmc.StorageStatus.DeletedRestored
| (_, _, _, _, _, _, _, true, _) ⇒
MonadVM.Evmc.StorageStatus.AddedDeleted
| (_, _, _, _, _, _, _, _, true) ⇒
MonadVM.Evmc.StorageStatus.ModifiedRestored
| (_, _, _, _, _, _, _, _, _) ⇒ MonadVM.Evmc.StorageStatus.Assigned
end.
{!Evmc.HOST.get_balance}
Definition get_balance `{_fargs : FArgs} (addr : Address.Map.key)
: M.(SM.t) U256.t :=
read
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.balance).
: M.(SM.t) U256.t :=
read
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.balance).
{!Evmc.HOST.get_code_size}
Definition get_code_size `{_fargs : FArgs} (addr : Address.Map.key)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (int64 × TS.t) :=
let* code :=
read (Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.code)
in
return (MonadVM.Uint64.of_int (MonadVM.Byte_string.Bytes.length code)).
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (int64 × TS.t) :=
let* code :=
read (Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.code)
in
return (MonadVM.Uint64.of_int (MonadVM.Byte_string.Bytes.length code)).
{!Evmc.HOST.get_code_hash}
Definition get_code_hash `{_fargs : FArgs} (addr : Address.Map.key)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t) :=
let* account := read (account None addr) in
return
(if Account.is_empty account then
None
else
Some (MonadVM.Crypto.keccak_256 account.(Account.t.code))).
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t) :=
let* account := read (account None addr) in
return
(if Account.is_empty account then
None
else
Some (MonadVM.Crypto.keccak_256 account.(Account.t.code))).
{!Evmc.HOST.copy_code}
Definition _rocq_fallback_copy_code_0 `{_fargs : FArgs} :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((string)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition copy_code `{_fargs : FArgs}
(addr : Address.Map.key) (offset : int) (size : int)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (string × TS.t) :=
let* code :=
read (Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.code)
in
if Z.geb offset (MonadVM.Byte_string.Bytes.length code) then
return MonadVM.Byte_string.Bytes.empty
else
let size :=
Z.min size
(RocqOfOCaml.OCamlInt.sub (MonadVM.Byte_string.Bytes.length code)
offset) in
return
((MonadVM.Byte_string.Bytes.sub (_rocq_fallback_copy_code_0)) code
offset size).
ltac:(let typ := constr:(ltac:(first [unshelve refine ((string)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition copy_code `{_fargs : FArgs}
(addr : Address.Map.key) (offset : int) (size : int)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (string × TS.t) :=
let* code :=
read (Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.code)
in
if Z.geb offset (MonadVM.Byte_string.Bytes.length code) then
return MonadVM.Byte_string.Bytes.empty
else
let size :=
Z.min size
(RocqOfOCaml.OCamlInt.sub (MonadVM.Byte_string.Bytes.length code)
offset) in
return
((MonadVM.Byte_string.Bytes.sub (_rocq_fallback_copy_code_0)) code
offset size).
{!Evmc.HOST.selfdestruct}
Definition _rocq_fallback_selfdestruct_0 `{_fargs : FArgs} :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((unit)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition selfdestruct `{_fargs : FArgs}
(address : Address.Map.key) (beneficiary : Address.Map.key)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* account_balance :=
read
(Lens.Infix.op_pipeminusminus (account None address)
Account.TLens.balance) in
let* transfer_ok := transfer_ether address beneficiary account_balance in
let '_ := if transfer_ok then tt else _rocq_fallback_selfdestruct_0 in
let* created_in_current_tx :=
(M.(SM.op_ltdollargt) (B := bool)
(A := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
(Address._Set.(RocqOfOCaml.OCamlSet.S.mem) address)
(read accounts_created_in_current_transaction) in
if created_in_current_tx then
let* alive_before_selfdestruct := account_exists address in
let* '_ :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
self_destruct (Address._Set.(RocqOfOCaml.OCamlSet.S.add) address) in
let* '_ :=
(M.(SM.op_coloneq) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None address)
Account.TLens.balance) U256.zero in
return alive_before_selfdestruct
else
return false.
Definition should_transfer `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: bool :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.CallCode |
MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒
negb msg.(MonadVM.Evmc.Message.t.static)
| MonadVM.Evmc.Message.CallKind.DelegateCall ⇒ false
end.
Definition touch_account `{_fargs : FArgs} (addr : string) : M.(SM.t) unit :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
accessed_addresses (Address._Set.(RocqOfOCaml.OCamlSet.S.add) addr).
Definition touch_storage `{_fargs : FArgs} (addr : string) (key : string)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (unit × TS.t) :=
let* '_ := touch_account addr in
(M.(SM.update_field) (x := StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t)))
accessed_keys (StorageKey._Set.(RocqOfOCaml.OCamlSet.S.add) (addr, key)).
Definition process_call `{_fargs : FArgs}
(from_tx : option MonadVM.Chain.Ethereum.Transaction.t)
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let '_ :=
if
negb
(MonadVM.Evmc.Message.CallKind.is_create
msg.(MonadVM.Evmc.Message.t.kind)) then tt else
_rocq_fallback_selfdestruct_0 in
let* transfer_ok :=
if should_transfer msg then
transfer_ether msg.(MonadVM.Evmc.Message.t.sender)
msg.(MonadVM.Evmc.Message.t.recipient)
msg.(MonadVM.Evmc.Message.t.value)
else
return true in
if transfer_ok then
let* '(code_address, code) :=
let* account_code :=
read
(Lens.Infix.op_pipeminusminus
(account None msg.(MonadVM.Evmc.Message.t.code_address))
Account.TLens.code) in
match (from_tx, (MonadVM.Delegation.get_delegated_address account_code))
with
| (Some _, Some delegated_addr) ⇒
let* delegated_code :=
read
(Lens.Infix.op_pipeminusminus (account None delegated_addr)
Account.TLens.code) in
return (delegated_addr, delegated_code)
| _ ⇒ return (msg.(MonadVM.Evmc.Message.t.code_address), account_code)
end in
match
(Precompiles (_fargs := _fargs)).(MonadVM.Precompiles.Make.Make_result.try_precompile)
msg code_address with
| Some action ⇒ action
| None ⇒ Vm.(MonadVM.Evmc.Vm.SIG.execute) msg code
end
else
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Insufficient_balance).
Definition process_syscall `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: M.(SM.t) MonadVM.Evmc.Result.t :=
let '_ :=
if
MonadVM.Evmc.Message.CallKind.op_eq msg.(MonadVM.Evmc.Message.t.kind)
MonadVM.Evmc.Message.CallKind.Call then tt else
_rocq_fallback_selfdestruct_0 in
match
Address.Map.find_opt msg.(MonadVM.Evmc.Message.t.recipient)
(Precompiles (_fargs := _fargs)).(MonadVM.Precompiles.Make.Make_result.syscall_endpoints)
with
| Some precompile ⇒ precompile msg
| None ⇒
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Internal_error)
end.
Definition contract_creation_address `{_fargs : FArgs}
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (Address.t × TS.t) :=
let* sender_nonce :=
read
(Lens.Infix.op_pipeminusminus
(account None msg.(MonadVM.Evmc.Message.t.sender)) Account.TLens.nonce)
in
let create2 :=
if
MonadVM.Evmc.Message.CallKind.op_eq msg.(MonadVM.Evmc.Message.t.kind)
MonadVM.Evmc.Message.CallKind.Create2
then
Some
{|
Address.create2_params.salt :=
msg.(MonadVM.Evmc.Message.t.create2_salt);
Address.create2_params.initcode :=
msg.(MonadVM.Evmc.Message.t.input_data); |}
else
None in
return
(Address.of_contract_creation msg.(MonadVM.Evmc.Message.t.sender)
sender_nonce create2).
Definition _rocq_fallback_process_create_0 `{_fargs : FArgs} : ltac:(let typ := constr:(ltac:(first [unshelve refine ((RocqOfOCaml.OCamlChar.t)%type )]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition process_create `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* create_address := contract_creation_address msg in
let* pre_existent_account := read (account None create_address) in
if
orb
(MonadVM.Numeric.U64.op_ltgt pre_existent_account.(Account.t.nonce)
MonadVM.Numeric.U64.zero)
(MonadVM.Byte_string.Bytes.op_ltgt
pre_existent_account.(Account.t.code)
MonadVM.Byte_string.Bytes.empty)
then
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Contract_validation_failure)
else
let* '_ :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
accounts_created_in_current_transaction
(fun (addresses : Address._Set.(RocqOfOCaml.OCamlSet.S.t)) ⇒
Address._Set.(RocqOfOCaml.OCamlSet.S.add) create_address addresses)
in
let* '_ :=
(M.(SM.op_coloneq)
(x := MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t) string))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.storage)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.empty)
in
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Numeric.U64.t))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.nonce) MonadVM.Numeric.U64.one in
let* transfer_ok :=
transfer_ether msg.(MonadVM.Evmc.Message.t.sender) create_address
msg.(MonadVM.Evmc.Message.t.value) in
let* result_value :=
if transfer_ok then
let creation_msg :=
MonadVM.Evmc.Message.t.with_code_address create_address
(MonadVM.Evmc.Message.t.with_create2_salt
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
(MonadVM.Evmc.Message.t.with_input_data
MonadVM.Byte_string.Bytes.empty
(MonadVM.Evmc.Message.t.with_recipient create_address
(MonadVM.Evmc.Message.t.with_kind
MonadVM.Evmc.Message.CallKind.Call msg)))) in
Vm.(MonadVM.Evmc.Vm.SIG.execute) creation_msg
msg.(MonadVM.Evmc.Message.t.input_data)
else
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Insufficient_balance) in
match result_value.(MonadVM.Evmc.Result.t.status_code) with
| MonadVM.Evmc.Result.StatusCode.Success ⇒
let contract_code := result_value.(MonadVM.Evmc.Result.t.output_data) in
let contract_length := MonadVM.Byte_string.Bytes.length contract_code in
let contract_code_gas :=
MonadVM.Gas.op_star (MonadVM.Gas.of_int contract_length)
MonadVM.Gas.code_deposit_per_byte in
let failure :=
if
andb (Z.gtb contract_length 0)
(RocqOfOCaml.OCamlChar.equal
((MonadVM.String.get
(_rocq_fallback_process_create_0))
contract_code 0) "239" % char)
then
Some MonadVM.Evmc.Result.StatusCode.Contract_validation_failure
else
if
Z.gtb contract_length MonadVM.Chain.Monad.Constants.max_code_size
then
Some MonadVM.Evmc.Result.StatusCode.Contract_validation_failure
else
if
MonadVM.Gas.op_lt
(MonadVM.Gas.of_uint64
result_value.(MonadVM.Evmc.Result.t.gas_left))
contract_code_gas
then
Some MonadVM.Evmc.Result.StatusCode.Out_of_gas
else
None in
match failure with
| Some _error ⇒ return (MonadVM.Evmc.Result.failure _error)
| None ⇒
let gas_left :=
MonadVM.Gas.to_uint64
(MonadVM.Gas.op_minus
(MonadVM.Gas.of_uint64
result_value.(MonadVM.Evmc.Result.t.gas_left))
contract_code_gas) in
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Byte_string.Bytes.t))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.code) contract_code in
return
(MonadVM.Evmc.Result.t.with_create_address create_address
(MonadVM.Evmc.Result.t.with_gas_left gas_left result_value))
end
| _ ⇒ return result_value
end.
Inductive call_kind `{_fargs : FArgs} : Set :=
| System_tx : call_kind
| Eoa_tx : MonadVM.Chain.Ethereum.Transaction.t → call_kind
| Evm_call : call_kind.
Definition call_impl `{_fargs : FArgs}
(kind : call_kind) (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* '_ :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒
let* create_address := contract_creation_address msg in
touch_account create_address
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.CallCode |
MonadVM.Evmc.Message.CallKind.DelegateCall) ⇒ return tt
end in
let* initial_state := M.(SM.get) in
let* result_value :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.DelegateCall |
MonadVM.Evmc.Message.CallKind.CallCode) ⇒
match kind with
| MonadVM.Host.Make.System_tx ⇒ process_syscall msg
| MonadVM.Host.Make.Eoa_tx tx ⇒ process_call (Some tx) msg
| MonadVM.Host.Make.Evm_call ⇒ process_call None msg
end
|
(MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒ process_create msg
end in
let* result_value :=
match
(kind,
match kind with
| MonadVM.Host.Make.Eoa_tx _t ⇒
MonadVM.Evmc.Result.StatusCode.is_success
result_value.(MonadVM.Evmc.Result.t.status_code)
| _ ⇒ false
end) with
| (MonadVM.Host.Make.Eoa_tx _t, true) ⇒
let* reserve_dipped :=
MonadVM.Reserve_balance.dipped_into_reserve
ChainParams.(MonadVM.Chain.Monad.PARAMS.revision) in
return
(if reserve_dipped then
MonadVM.Evmc.Result.t.with_gas_refund 0
(MonadVM.Evmc.Result.t.with_status_code
MonadVM.Evmc.Result.StatusCode.Revert result_value)
else
result_value)
|
((MonadVM.Host.Make.Eoa_tx _ | MonadVM.Host.Make.System_tx |
MonadVM.Host.Make.Evm_call), _) ⇒ return result_value
end in
let* '_ :=
M.(SM.when_)
(negb
(MonadVM.Evmc.Result.StatusCode.is_success
result_value.(MonadVM.Evmc.Result.t.status_code)))
(M.(SM.put) initial_state) in
return result_value.
Definition try_increment_nonce `{_fargs : FArgs} (addr : Address.t)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* current_nonce :=
read
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.nonce)
in
if MonadVM.Numeric.U64.op_eq current_nonce MonadVM.Numeric.U64.max_t then
return false
else
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Numeric.U64.t))
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.nonce)
(MonadVM.Numeric.U64.op_plus current_nonce MonadVM.Numeric.U64.one) in
return true.
ltac:(let typ := constr:(ltac:(first [unshelve refine ((unit)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition selfdestruct `{_fargs : FArgs}
(address : Address.Map.key) (beneficiary : Address.Map.key)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* account_balance :=
read
(Lens.Infix.op_pipeminusminus (account None address)
Account.TLens.balance) in
let* transfer_ok := transfer_ether address beneficiary account_balance in
let '_ := if transfer_ok then tt else _rocq_fallback_selfdestruct_0 in
let* created_in_current_tx :=
(M.(SM.op_ltdollargt) (B := bool)
(A := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
(Address._Set.(RocqOfOCaml.OCamlSet.S.mem) address)
(read accounts_created_in_current_transaction) in
if created_in_current_tx then
let* alive_before_selfdestruct := account_exists address in
let* '_ :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
self_destruct (Address._Set.(RocqOfOCaml.OCamlSet.S.add) address) in
let* '_ :=
(M.(SM.op_coloneq) (x := U256.t))
(Lens.Infix.op_pipeminusminus (account None address)
Account.TLens.balance) U256.zero in
return alive_before_selfdestruct
else
return false.
Definition should_transfer `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: bool :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.CallCode |
MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒
negb msg.(MonadVM.Evmc.Message.t.static)
| MonadVM.Evmc.Message.CallKind.DelegateCall ⇒ false
end.
Definition touch_account `{_fargs : FArgs} (addr : string) : M.(SM.t) unit :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
accessed_addresses (Address._Set.(RocqOfOCaml.OCamlSet.S.add) addr).
Definition touch_storage `{_fargs : FArgs} (addr : string) (key : string)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (unit × TS.t) :=
let* '_ := touch_account addr in
(M.(SM.update_field) (x := StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t)))
accessed_keys (StorageKey._Set.(RocqOfOCaml.OCamlSet.S.add) (addr, key)).
Definition process_call `{_fargs : FArgs}
(from_tx : option MonadVM.Chain.Ethereum.Transaction.t)
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let '_ :=
if
negb
(MonadVM.Evmc.Message.CallKind.is_create
msg.(MonadVM.Evmc.Message.t.kind)) then tt else
_rocq_fallback_selfdestruct_0 in
let* transfer_ok :=
if should_transfer msg then
transfer_ether msg.(MonadVM.Evmc.Message.t.sender)
msg.(MonadVM.Evmc.Message.t.recipient)
msg.(MonadVM.Evmc.Message.t.value)
else
return true in
if transfer_ok then
let* '(code_address, code) :=
let* account_code :=
read
(Lens.Infix.op_pipeminusminus
(account None msg.(MonadVM.Evmc.Message.t.code_address))
Account.TLens.code) in
match (from_tx, (MonadVM.Delegation.get_delegated_address account_code))
with
| (Some _, Some delegated_addr) ⇒
let* delegated_code :=
read
(Lens.Infix.op_pipeminusminus (account None delegated_addr)
Account.TLens.code) in
return (delegated_addr, delegated_code)
| _ ⇒ return (msg.(MonadVM.Evmc.Message.t.code_address), account_code)
end in
match
(Precompiles (_fargs := _fargs)).(MonadVM.Precompiles.Make.Make_result.try_precompile)
msg code_address with
| Some action ⇒ action
| None ⇒ Vm.(MonadVM.Evmc.Vm.SIG.execute) msg code
end
else
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Insufficient_balance).
Definition process_syscall `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: M.(SM.t) MonadVM.Evmc.Result.t :=
let '_ :=
if
MonadVM.Evmc.Message.CallKind.op_eq msg.(MonadVM.Evmc.Message.t.kind)
MonadVM.Evmc.Message.CallKind.Call then tt else
_rocq_fallback_selfdestruct_0 in
match
Address.Map.find_opt msg.(MonadVM.Evmc.Message.t.recipient)
(Precompiles (_fargs := _fargs)).(MonadVM.Precompiles.Make.Make_result.syscall_endpoints)
with
| Some precompile ⇒ precompile msg
| None ⇒
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Internal_error)
end.
Definition contract_creation_address `{_fargs : FArgs}
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (Address.t × TS.t) :=
let* sender_nonce :=
read
(Lens.Infix.op_pipeminusminus
(account None msg.(MonadVM.Evmc.Message.t.sender)) Account.TLens.nonce)
in
let create2 :=
if
MonadVM.Evmc.Message.CallKind.op_eq msg.(MonadVM.Evmc.Message.t.kind)
MonadVM.Evmc.Message.CallKind.Create2
then
Some
{|
Address.create2_params.salt :=
msg.(MonadVM.Evmc.Message.t.create2_salt);
Address.create2_params.initcode :=
msg.(MonadVM.Evmc.Message.t.input_data); |}
else
None in
return
(Address.of_contract_creation msg.(MonadVM.Evmc.Message.t.sender)
sender_nonce create2).
Definition _rocq_fallback_process_create_0 `{_fargs : FArgs} : ltac:(let typ := constr:(ltac:(first [unshelve refine ((RocqOfOCaml.OCamlChar.t)%type )]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ).
Proof. unshelve (RocqOfOCaml.Opaque.opaque_inhabit 64%nat). all: RocqOfOCaml.Opaque.opaque_inhabit 64%nat. Qed.
Definition process_create `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* create_address := contract_creation_address msg in
let* pre_existent_account := read (account None create_address) in
if
orb
(MonadVM.Numeric.U64.op_ltgt pre_existent_account.(Account.t.nonce)
MonadVM.Numeric.U64.zero)
(MonadVM.Byte_string.Bytes.op_ltgt
pre_existent_account.(Account.t.code)
MonadVM.Byte_string.Bytes.empty)
then
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Contract_validation_failure)
else
let* '_ :=
(M.(SM.update_field) (x := Address._Set.(RocqOfOCaml.OCamlSet.S.t)))
accounts_created_in_current_transaction
(fun (addresses : Address._Set.(RocqOfOCaml.OCamlSet.S.t)) ⇒
Address._Set.(RocqOfOCaml.OCamlSet.S.add) create_address addresses)
in
let* '_ :=
(M.(SM.op_coloneq)
(x := MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t) string))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.storage)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.empty)
in
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Numeric.U64.t))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.nonce) MonadVM.Numeric.U64.one in
let* transfer_ok :=
transfer_ether msg.(MonadVM.Evmc.Message.t.sender) create_address
msg.(MonadVM.Evmc.Message.t.value) in
let* result_value :=
if transfer_ok then
let creation_msg :=
MonadVM.Evmc.Message.t.with_code_address create_address
(MonadVM.Evmc.Message.t.with_create2_salt
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)
(MonadVM.Evmc.Message.t.with_input_data
MonadVM.Byte_string.Bytes.empty
(MonadVM.Evmc.Message.t.with_recipient create_address
(MonadVM.Evmc.Message.t.with_kind
MonadVM.Evmc.Message.CallKind.Call msg)))) in
Vm.(MonadVM.Evmc.Vm.SIG.execute) creation_msg
msg.(MonadVM.Evmc.Message.t.input_data)
else
return
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Insufficient_balance) in
match result_value.(MonadVM.Evmc.Result.t.status_code) with
| MonadVM.Evmc.Result.StatusCode.Success ⇒
let contract_code := result_value.(MonadVM.Evmc.Result.t.output_data) in
let contract_length := MonadVM.Byte_string.Bytes.length contract_code in
let contract_code_gas :=
MonadVM.Gas.op_star (MonadVM.Gas.of_int contract_length)
MonadVM.Gas.code_deposit_per_byte in
let failure :=
if
andb (Z.gtb contract_length 0)
(RocqOfOCaml.OCamlChar.equal
((MonadVM.String.get
(_rocq_fallback_process_create_0))
contract_code 0) "239" % char)
then
Some MonadVM.Evmc.Result.StatusCode.Contract_validation_failure
else
if
Z.gtb contract_length MonadVM.Chain.Monad.Constants.max_code_size
then
Some MonadVM.Evmc.Result.StatusCode.Contract_validation_failure
else
if
MonadVM.Gas.op_lt
(MonadVM.Gas.of_uint64
result_value.(MonadVM.Evmc.Result.t.gas_left))
contract_code_gas
then
Some MonadVM.Evmc.Result.StatusCode.Out_of_gas
else
None in
match failure with
| Some _error ⇒ return (MonadVM.Evmc.Result.failure _error)
| None ⇒
let gas_left :=
MonadVM.Gas.to_uint64
(MonadVM.Gas.op_minus
(MonadVM.Gas.of_uint64
result_value.(MonadVM.Evmc.Result.t.gas_left))
contract_code_gas) in
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Byte_string.Bytes.t))
(Lens.Infix.op_pipeminusminus (account None create_address)
Account.TLens.code) contract_code in
return
(MonadVM.Evmc.Result.t.with_create_address create_address
(MonadVM.Evmc.Result.t.with_gas_left gas_left result_value))
end
| _ ⇒ return result_value
end.
Inductive call_kind `{_fargs : FArgs} : Set :=
| System_tx : call_kind
| Eoa_tx : MonadVM.Chain.Ethereum.Transaction.t → call_kind
| Evm_call : call_kind.
Definition call_impl `{_fargs : FArgs}
(kind : call_kind) (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* '_ :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒
let* create_address := contract_creation_address msg in
touch_account create_address
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.CallCode |
MonadVM.Evmc.Message.CallKind.DelegateCall) ⇒ return tt
end in
let* initial_state := M.(SM.get) in
let* result_value :=
match msg.(MonadVM.Evmc.Message.t.kind) with
|
(MonadVM.Evmc.Message.CallKind.Call |
MonadVM.Evmc.Message.CallKind.DelegateCall |
MonadVM.Evmc.Message.CallKind.CallCode) ⇒
match kind with
| MonadVM.Host.Make.System_tx ⇒ process_syscall msg
| MonadVM.Host.Make.Eoa_tx tx ⇒ process_call (Some tx) msg
| MonadVM.Host.Make.Evm_call ⇒ process_call None msg
end
|
(MonadVM.Evmc.Message.CallKind.Create |
MonadVM.Evmc.Message.CallKind.Create2) ⇒ process_create msg
end in
let* result_value :=
match
(kind,
match kind with
| MonadVM.Host.Make.Eoa_tx _t ⇒
MonadVM.Evmc.Result.StatusCode.is_success
result_value.(MonadVM.Evmc.Result.t.status_code)
| _ ⇒ false
end) with
| (MonadVM.Host.Make.Eoa_tx _t, true) ⇒
let* reserve_dipped :=
MonadVM.Reserve_balance.dipped_into_reserve
ChainParams.(MonadVM.Chain.Monad.PARAMS.revision) in
return
(if reserve_dipped then
MonadVM.Evmc.Result.t.with_gas_refund 0
(MonadVM.Evmc.Result.t.with_status_code
MonadVM.Evmc.Result.StatusCode.Revert result_value)
else
result_value)
|
((MonadVM.Host.Make.Eoa_tx _ | MonadVM.Host.Make.System_tx |
MonadVM.Host.Make.Evm_call), _) ⇒ return result_value
end in
let* '_ :=
M.(SM.when_)
(negb
(MonadVM.Evmc.Result.StatusCode.is_success
result_value.(MonadVM.Evmc.Result.t.status_code)))
(M.(SM.put) initial_state) in
return result_value.
Definition try_increment_nonce `{_fargs : FArgs} (addr : Address.t)
: TS.t → MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t) :=
let* current_nonce :=
read
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.nonce)
in
if MonadVM.Numeric.U64.op_eq current_nonce MonadVM.Numeric.U64.max_t then
return false
else
let* '_ :=
(M.(SM.op_coloneq) (x := MonadVM.Numeric.U64.t))
(Lens.Infix.op_pipeminusminus (account None addr) Account.TLens.nonce)
(MonadVM.Numeric.U64.op_plus current_nonce MonadVM.Numeric.U64.one) in
return true.
{!Evmc.HOST.call}
Definition call `{_fargs : FArgs} (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* no_nonce_overflow :=
if
MonadVM.Evmc.Message.CallKind.is_create
msg.(MonadVM.Evmc.Message.t.kind)
then
try_increment_nonce msg.(MonadVM.Evmc.Message.t.sender)
else
return true in
if no_nonce_overflow then
call_impl MonadVM.Host.Make.Evm_call msg
else
return
(MonadVM.Evmc.Result.t.with_gas_left msg.(MonadVM.Evmc.Message.t.gas)
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Argument_out_of_range)).
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
let* no_nonce_overflow :=
if
MonadVM.Evmc.Message.CallKind.is_create
msg.(MonadVM.Evmc.Message.t.kind)
then
try_increment_nonce msg.(MonadVM.Evmc.Message.t.sender)
else
return true in
if no_nonce_overflow then
call_impl MonadVM.Host.Make.Evm_call msg
else
return
(MonadVM.Evmc.Result.t.with_gas_left msg.(MonadVM.Evmc.Message.t.gas)
(MonadVM.Evmc.Result.failure
MonadVM.Evmc.Result.StatusCode.Argument_out_of_range)).
call_from_eoa tx msg processes a message (contract creation or call) created from a transaction sent
by an EOA, as opposed to a system transaction or a CALL opcode which are handled by {!call} directly.
Definition call_from_eoa `{_fargs : FArgs}
(tx : MonadVM.Chain.Ethereum.Transaction.t) (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
call_impl (MonadVM.Host.Make.Eoa_tx tx) msg.
Definition call_from_monad_system_transaction `{_fargs : FArgs}
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
call_impl MonadVM.Host.Make.System_tx msg.
(tx : MonadVM.Chain.Ethereum.Transaction.t) (msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
call_impl (MonadVM.Host.Make.Eoa_tx tx) msg.
Definition call_from_monad_system_transaction `{_fargs : FArgs}
(msg : MonadVM.Evmc.Message.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t) :=
call_impl MonadVM.Host.Make.System_tx msg.
{!Evmc.HOST.get_tx_context}
Definition get_tx_context `{_fargs : FArgs}
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.TxContext.t × TS.t) :=
let* state := M.(SM.get) in
return
{|
MonadVM.Evmc.TxContext.t.tx_gas_price :=
U256.of_uint_exn state.(TS.t.tx_gas_price);
MonadVM.Evmc.TxContext.t.tx_origin := state.(TS.t.tx_origin);
MonadVM.Evmc.TxContext.t.block_coinbase :=
state.(TS.t.current_block).(Block.t.header).(Header.t.beneficiary);
MonadVM.Evmc.TxContext.t.block_number :=
MonadVM.Support.UintN.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.number);
MonadVM.Evmc.TxContext.t.block_timestamp :=
U256.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.timestamp);
MonadVM.Evmc.TxContext.t.block_gas_limit :=
MonadVM.Gas.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.gas_limit);
MonadVM.Evmc.TxContext.t.block_prev_randao :=
U256.of_repr
state.(TS.t.current_block).(Block.t.header).(Header.t.prev_randao);
MonadVM.Evmc.TxContext.t.chain_id :=
U256.of_uint_exn ChainParams.(MonadVM.Chain.Monad.PARAMS.chain_id);
MonadVM.Evmc.TxContext.t.block_base_fee :=
U256.of_uint_exn
state.(TS.t.current_block).(Block.t.header).(Header.t.base_fee_per_gas);
MonadVM.Evmc.TxContext.t.blob_base_fee := U256.one;
MonadVM.Evmc.TxContext.t.blob_hashes := nil;
MonadVM.Evmc.TxContext.t.initcodes := nil; |}.
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.TxContext.t × TS.t) :=
let* state := M.(SM.get) in
return
{|
MonadVM.Evmc.TxContext.t.tx_gas_price :=
U256.of_uint_exn state.(TS.t.tx_gas_price);
MonadVM.Evmc.TxContext.t.tx_origin := state.(TS.t.tx_origin);
MonadVM.Evmc.TxContext.t.block_coinbase :=
state.(TS.t.current_block).(Block.t.header).(Header.t.beneficiary);
MonadVM.Evmc.TxContext.t.block_number :=
MonadVM.Support.UintN.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.number);
MonadVM.Evmc.TxContext.t.block_timestamp :=
U256.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.timestamp);
MonadVM.Evmc.TxContext.t.block_gas_limit :=
MonadVM.Gas.to_uint64
state.(TS.t.current_block).(Block.t.header).(Header.t.gas_limit);
MonadVM.Evmc.TxContext.t.block_prev_randao :=
U256.of_repr
state.(TS.t.current_block).(Block.t.header).(Header.t.prev_randao);
MonadVM.Evmc.TxContext.t.chain_id :=
U256.of_uint_exn ChainParams.(MonadVM.Chain.Monad.PARAMS.chain_id);
MonadVM.Evmc.TxContext.t.block_base_fee :=
U256.of_uint_exn
state.(TS.t.current_block).(Block.t.header).(Header.t.base_fee_per_gas);
MonadVM.Evmc.TxContext.t.blob_base_fee := U256.one;
MonadVM.Evmc.TxContext.t.blob_hashes := nil;
MonadVM.Evmc.TxContext.t.initcodes := nil; |}.
{!Evmc.HOST.get_block_hash}
Definition get_block_hash `{_fargs : FArgs} (i_value : MonadVM.Uint64.t)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t) :=
let* state := M.(SM.get) in
return
(M.(SM.Option_map) Block.hash
(M.(SM.List_find_opt)
(fun (block : Block.t) ⇒
MonadVM.Support.UintN.op_eq block.(Block.t.header).(Header.t.number)
(MonadVM.Support.UintN.of_uint64 i_value))
state.(TS.t.world_state).(WS.t.history))).
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t) :=
let* state := M.(SM.get) in
return
(M.(SM.Option_map) Block.hash
(M.(SM.List_find_opt)
(fun (block : Block.t) ⇒
MonadVM.Support.UintN.op_eq block.(Block.t.header).(Header.t.number)
(MonadVM.Support.UintN.of_uint64 i_value))
state.(TS.t.world_state).(WS.t.history))).
{!Evmc.HOST.emit_log}
Definition emit_log `{_fargs : FArgs}
(address : Address.t) (data : MonadVM.Byte_string.Bytes.t)
(topics : list string) : M.(SM.t) unit :=
let log :=
{| MonadVM.Chain.Ethereum.Log.t.address := address;
MonadVM.Chain.Ethereum.Log.t.topics := topics;
MonadVM.Chain.Ethereum.Log.t.data := data; |} in
(M.(SM.update_field) (x := list MonadVM.Chain.Ethereum.Log.t)) logs
(fun (logs : list MonadVM.Chain.Ethereum.Log.t) ⇒ Datatypes.cons log logs).
(address : Address.t) (data : MonadVM.Byte_string.Bytes.t)
(topics : list string) : M.(SM.t) unit :=
let log :=
{| MonadVM.Chain.Ethereum.Log.t.address := address;
MonadVM.Chain.Ethereum.Log.t.topics := topics;
MonadVM.Chain.Ethereum.Log.t.data := data; |} in
(M.(SM.update_field) (x := list MonadVM.Chain.Ethereum.Log.t)) logs
(fun (logs : list MonadVM.Chain.Ethereum.Log.t) ⇒ Datatypes.cons log logs).
{!Evmc.HOST.access_account}
Definition access_account `{_fargs : FArgs} (addr : string)
: M.(SM.t) MonadVM.Support.Variants.AccessStatus.t :=
let* accessed := read accessed_addresses in
if
M.(SM.Option_is_some)
(Address._Set.(RocqOfOCaml.OCamlSet.S.find_opt) addr accessed)
then
return MonadVM.Support.Variants.AccessStatus.Warm
else
let* '_ := touch_account addr in
return MonadVM.Support.Variants.AccessStatus.Cold.
: M.(SM.t) MonadVM.Support.Variants.AccessStatus.t :=
let* accessed := read accessed_addresses in
if
M.(SM.Option_is_some)
(Address._Set.(RocqOfOCaml.OCamlSet.S.find_opt) addr accessed)
then
return MonadVM.Support.Variants.AccessStatus.Warm
else
let* '_ := touch_account addr in
return MonadVM.Support.Variants.AccessStatus.Cold.
{!Evmc.HOST.access_storage}
Definition access_storage `{_fargs : FArgs} (addr : Address.t) (key : string)
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Support.Variants.AccessStatus.t × TS.t) :=
let* accessed := read accessed_keys in
if
M.(SM.Option_is_some)
(StorageKey._Set.(RocqOfOCaml.OCamlSet.S.find_opt) (addr, key)
accessed)
then
return MonadVM.Support.Variants.AccessStatus.Warm
else
let* '_ := touch_storage addr key in
return MonadVM.Support.Variants.AccessStatus.Cold.
Definition transient_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) : Lens.t TS.t string :=
Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus TS.transient_storage
(Address.Map._at addr))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.empty)))
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)).
: TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Support.Variants.AccessStatus.t × TS.t) :=
let* accessed := read accessed_keys in
if
M.(SM.Option_is_some)
(StorageKey._Set.(RocqOfOCaml.OCamlSet.S.find_opt) (addr, key)
accessed)
then
return MonadVM.Support.Variants.AccessStatus.Warm
else
let* '_ := touch_storage addr key in
return MonadVM.Support.Variants.AccessStatus.Cold.
Definition transient_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) : Lens.t TS.t string :=
Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus
(Lens.Infix.op_pipeminusminus TS.transient_storage
(Address.Map._at addr))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.empty)))
((MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature._at)
(v := string)) key))
(M.(SM.Option_get_or_default)
MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.zeros)).
{!Evmc.HOST.get_transient_storage}
Definition get_transient_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) : M.(SM.t) string :=
read (transient_storage addr key).
(addr : Address.Map.key) (key : string) : M.(SM.t) string :=
read (transient_storage addr key).
{!Evmc.HOST.set_transient_storage}
Definition set_transient_storage `{_fargs : FArgs}
(addr : Address.Map.key) (key : string) (value : string) : M.(SM.t) unit :=
(M.(SM.op_coloneq) (x := string)) (transient_storage addr key) value.
Module Make_result.
Record signature `{_fargs : FArgs} {StorageKey_Set_t : Set}
{call_kind : Set} : Type := {
StorageKey_Impl : MonadVM.Map.OrderedType (t := Address.t × string);
StorageKey_t := Address.t × string;
StorageKey_compare : Address.t × string → Address.t × string → int;
StorageKey_Set :
RocqOfOCaml.OCamlSet.S (elt := Address.t × string)
(t := StorageKey_Set_t);
t := TS.t;
t__rocq_record_make :
WS.t → WS.t → Block.t →
Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string) → Address._Set.(RocqOfOCaml.OCamlSet.S.t) → Address.t →
MonadVM.Gas.t → MonadVM.Gas.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) →
list MonadVM.Chain.Ethereum.Log.t → U256.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → StorageKey_Set_t → t;
t__rocq_record_get_initial_world_state : t → WS.t;
t__rocq_record_get_world_state : t → WS.t;
t__rocq_record_get_current_block : t → Block.t;
t__rocq_record_get_transient_storage :
t →
Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string);
t__rocq_record_get_accounts_created_in_current_transaction :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_tx_origin : t → Address.t;
t__rocq_record_get_tx_gas_price : t → MonadVM.Gas.t;
t__rocq_record_get_tx_gas_limit : t → MonadVM.Gas.t;
t__rocq_record_get_self_destruct :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_logs : t → list MonadVM.Chain.Ethereum.Log.t;
t__rocq_record_get_refund : t → U256.t;
t__rocq_record_get_accessed_addresses :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_accessed_keys : t → StorageKey_Set_t;
TLens_initial_world_state : Lens.t TS.t WS.t;
TLens_world_state : Lens.t TS.t WS.t;
TLens_current_block : Lens.t TS.t Block.t;
TLens_transient_storage :
Lens.t TS.t
(Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string));
TLens_accounts_created_in_current_transaction :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_tx_origin : Lens.t TS.t Address.t;
TLens_tx_gas_price : Lens.t TS.t MonadVM.Gas.t;
TLens_tx_gas_limit : Lens.t TS.t MonadVM.Gas.t;
TLens_self_destruct : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_logs : Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t);
TLens_refund : Lens.t TS.t U256.t;
TLens_accessed_addresses :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_accessed_keys :
Lens.t TS.t TS.StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t);
initial_world_state : Lens.t TS.t WS.t;
world_state : Lens.t TS.t WS.t;
current_block : Lens.t TS.t Block.t;
accounts_created_in_current_transaction :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
tx_origin : Lens.t TS.t Address.t;
tx_gas_price : Lens.t TS.t MonadVM.Gas.t;
tx_gas_limit : Lens.t TS.t MonadVM.Gas.t;
self_destruct : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
logs : Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t);
refund : Lens.t TS.t U256.t;
accessed_addresses : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
accessed_keys : Lens.t TS.t StorageKey_Set_t;
empty : TS.t;
make :
MonadVM.State.BlockState.t → Address.t →
MonadVM.Chain.Ethereum.Transaction.t → TS.t;
account : option bool → Address.Map.key → Lens.t TS.t Account.t;
initialize_access_sets :
MonadVM.Chain.Ethereum.Transaction.t → TS.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → TS.t;
M : MonadVM.Monad.State.State_result (_fargs := TS.M_fargs);
Precompiles :
MonadVM.Precompiles.Make.Make_result (_fargs := Precompiles_fargs);
transfer_ether :
Address.Map.key → Address.Map.key →
U256.Impl.(MonadVM.Numeric.Make.Impl.Impl_signature.t) → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
account_exists :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
get_storage : Address.Map.key → string → M.(SM.t) string;
set_storage :
Address.Map.key → string → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.StorageStatus.t × TS.t);
get_balance : Address.Map.key → M.(SM.t) U256.t;
get_code_size :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (int64 × TS.t);
get_code_hash :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t);
copy_code :
Address.Map.key → int → int → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (string × TS.t);
selfdestruct :
Address.Map.key → Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
should_transfer : MonadVM.Evmc.Message.t → bool;
touch_account : string → M.(SM.t) unit;
touch_storage :
string → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (unit × TS.t);
process_call :
option MonadVM.Chain.Ethereum.Transaction.t → MonadVM.Evmc.Message.t →
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
process_syscall :
MonadVM.Evmc.Message.t → M.(SM.t) MonadVM.Evmc.Result.t;
contract_creation_address :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (Address.t × TS.t);
process_create :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_kind := call_kind;
call_impl :
call_kind → MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
try_increment_nonce :
Address.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
call :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_from_eoa :
MonadVM.Chain.Ethereum.Transaction.t → MonadVM.Evmc.Message.t →
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_from_monad_system_transaction :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
get_tx_context :
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.TxContext.t × TS.t);
get_block_hash :
MonadVM.Uint64.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t);
emit_log :
Address.t → MonadVM.Byte_string.Bytes.t → list string → M.(SM.t) unit;
access_account :
string → M.(SM.t) MonadVM.Support.Variants.AccessStatus.t;
access_storage :
Address.t → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Support.Variants.AccessStatus.t × TS.t);
transient_storage : Address.Map.key → string → Lens.t TS.t string;
get_transient_storage : Address.Map.key → string → M.(SM.t) string;
set_transient_storage :
Address.Map.key → string → string → M.(SM.t) unit;
StorageKey_Set_t := StorageKey_Set_t;
}.
End Make_result.
Definition Make_result `{_fargs : FArgs} := @Make_result.signature _.
Arguments Make_result {_ _ _}.
Definition functor `{_fargs : FArgs}
:Make_result (StorageKey_Set_t := _) (call_kind := _) :=
{|
Make_result.StorageKey_Impl := TS.StorageKey.Impl;
Make_result.StorageKey_compare := TS.StorageKey.compare;
Make_result.StorageKey_Set := TS.StorageKey._Set;
Make_result.t__rocq_record_make :=
fun _rocq_record_field_initial_world_state
_rocq_record_field_world_state _rocq_record_field_current_block
_rocq_record_field_transient_storage
_rocq_record_field_accounts_created_in_current_transaction
_rocq_record_field_tx_origin _rocq_record_field_tx_gas_price
_rocq_record_field_tx_gas_limit _rocq_record_field_self_destruct
_rocq_record_field_logs _rocq_record_field_refund
_rocq_record_field_accessed_addresses _rocq_record_field_accessed_keys
⇒
{| TS.t.initial_world_state := _rocq_record_field_initial_world_state;
TS.t.world_state := _rocq_record_field_world_state;
TS.t.current_block := _rocq_record_field_current_block;
TS.t.transient_storage := _rocq_record_field_transient_storage;
TS.t.accounts_created_in_current_transaction :=
_rocq_record_field_accounts_created_in_current_transaction;
TS.t.tx_origin := _rocq_record_field_tx_origin;
TS.t.tx_gas_price := _rocq_record_field_tx_gas_price;
TS.t.tx_gas_limit := _rocq_record_field_tx_gas_limit;
TS.t.self_destruct := _rocq_record_field_self_destruct;
TS.t.logs := _rocq_record_field_logs;
TS.t.refund := _rocq_record_field_refund;
TS.t.accessed_addresses := _rocq_record_field_accessed_addresses;
TS.t.accessed_keys := _rocq_record_field_accessed_keys; |};
Make_result.t__rocq_record_get_initial_world_state :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.initial_world_state);
Make_result.t__rocq_record_get_world_state :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.world_state);
Make_result.t__rocq_record_get_current_block :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.current_block);
Make_result.t__rocq_record_get_transient_storage :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.transient_storage);
Make_result.t__rocq_record_get_accounts_created_in_current_transaction :=
fun _rocq_record_value ⇒
_rocq_record_value.(TS.t.accounts_created_in_current_transaction);
Make_result.t__rocq_record_get_tx_origin :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_origin);
Make_result.t__rocq_record_get_tx_gas_price :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_gas_price);
Make_result.t__rocq_record_get_tx_gas_limit :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_gas_limit);
Make_result.t__rocq_record_get_self_destruct :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.self_destruct);
Make_result.t__rocq_record_get_logs :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.logs);
Make_result.t__rocq_record_get_refund :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.refund);
Make_result.t__rocq_record_get_accessed_addresses :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.accessed_addresses);
Make_result.t__rocq_record_get_accessed_keys :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.accessed_keys);
Make_result.TLens_initial_world_state := TS.TLens.initial_world_state;
Make_result.TLens_world_state := TS.TLens.world_state;
Make_result.TLens_current_block := TS.TLens.current_block;
Make_result.TLens_transient_storage := TS.TLens.transient_storage;
Make_result.TLens_accounts_created_in_current_transaction :=
TS.TLens.accounts_created_in_current_transaction;
Make_result.TLens_tx_origin := TS.TLens.tx_origin;
Make_result.TLens_tx_gas_price := TS.TLens.tx_gas_price;
Make_result.TLens_tx_gas_limit := TS.TLens.tx_gas_limit;
Make_result.TLens_self_destruct := TS.TLens.self_destruct;
Make_result.TLens_logs := TS.TLens.logs;
Make_result.TLens_refund := TS.TLens.refund;
Make_result.TLens_accessed_addresses := TS.TLens.accessed_addresses;
Make_result.TLens_accessed_keys := TS.TLens.accessed_keys;
Make_result.initial_world_state := initial_world_state;
Make_result.world_state := world_state;
Make_result.current_block := current_block;
Make_result.accounts_created_in_current_transaction :=
accounts_created_in_current_transaction;
Make_result.tx_origin := tx_origin;
Make_result.tx_gas_price := tx_gas_price;
Make_result.tx_gas_limit := tx_gas_limit;
Make_result.self_destruct := self_destruct;
Make_result.logs := logs;
Make_result.refund := refund;
Make_result.accessed_addresses := accessed_addresses;
Make_result.accessed_keys := accessed_keys;
Make_result.empty := empty;
Make_result.make := make;
Make_result.account := account;
Make_result.initialize_access_sets := initialize_access_sets;
Make_result.M := M;
Make_result.Precompiles := Precompiles;
Make_result.transfer_ether := transfer_ether;
Make_result.account_exists := account_exists;
Make_result.get_storage := get_storage;
Make_result.set_storage := set_storage;
Make_result.get_balance := get_balance;
Make_result.get_code_size := get_code_size;
Make_result.get_code_hash := get_code_hash;
Make_result.copy_code := copy_code;
Make_result.selfdestruct := selfdestruct;
Make_result.should_transfer := should_transfer;
Make_result.touch_account := touch_account;
Make_result.touch_storage := touch_storage;
Make_result.process_call := process_call;
Make_result.process_syscall := process_syscall;
Make_result.contract_creation_address := contract_creation_address;
Make_result.process_create := process_create;
Make_result.call_impl := call_impl;
Make_result.try_increment_nonce := try_increment_nonce;
Make_result.call := call;
Make_result.call_from_eoa := call_from_eoa;
Make_result.call_from_monad_system_transaction :=
call_from_monad_system_transaction;
Make_result.get_tx_context := get_tx_context;
Make_result.get_block_hash := get_block_hash;
Make_result.emit_log := emit_log;
Make_result.access_account := access_account;
Make_result.access_storage := access_storage;
Make_result.transient_storage := transient_storage;
Make_result.get_transient_storage := get_transient_storage;
Make_result.set_transient_storage := set_transient_storage
|}.
End Make.
Definition Make
(ChainParams : MonadVM.Chain.Monad.PARAMS)
(Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) :=
@Make.functor (Make.Build_FArgs ChainParams Vm).
Module Instantiate.
Class FArgs := {
ChainParams : MonadVM.Chain.Monad.PARAMS;
Vm_parameter :
∀ (Host : MonadVM.Evmc.HOST (t := TS.t)),
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
}.
Definition MonadVM_Evmc_Instantiate_include `{_fargs : FArgs} :=
MonadVM.Evmc.Instantiate
((ltac:(constructor) : MonadVM.Evmc.Vm_H_signature (t := TS.t)) :
MonadVM.Evmc.Vm_H_signature (t := TS.t))
(fun
(Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) ⇒
let module_coercion := Make ChainParams Vm in
{|
MonadVM.Evmc.HOST.account_exists :=
module_coercion.(Make.Make_result.account_exists);
MonadVM.Evmc.HOST.get_storage :=
module_coercion.(Make.Make_result.get_storage);
MonadVM.Evmc.HOST.set_storage :=
module_coercion.(Make.Make_result.set_storage);
MonadVM.Evmc.HOST.get_balance :=
module_coercion.(Make.Make_result.get_balance);
MonadVM.Evmc.HOST.get_code_size :=
module_coercion.(Make.Make_result.get_code_size);
MonadVM.Evmc.HOST.get_code_hash :=
module_coercion.(Make.Make_result.get_code_hash);
MonadVM.Evmc.HOST.copy_code :=
module_coercion.(Make.Make_result.copy_code);
MonadVM.Evmc.HOST.selfdestruct :=
module_coercion.(Make.Make_result.selfdestruct);
MonadVM.Evmc.HOST.call := module_coercion.(Make.Make_result.call);
MonadVM.Evmc.HOST.get_tx_context :=
module_coercion.(Make.Make_result.get_tx_context);
MonadVM.Evmc.HOST.get_block_hash :=
module_coercion.(Make.Make_result.get_block_hash);
MonadVM.Evmc.HOST.emit_log :=
module_coercion.(Make.Make_result.emit_log);
MonadVM.Evmc.HOST.access_account :=
module_coercion.(Make.Make_result.access_account);
MonadVM.Evmc.HOST.access_storage :=
module_coercion.(Make.Make_result.access_storage);
MonadVM.Evmc.HOST.get_transient_storage :=
module_coercion.(Make.Make_result.get_transient_storage);
MonadVM.Evmc.HOST.set_transient_storage :=
module_coercion.(Make.Make_result.set_transient_storage)
|}) Vm_parameter.
(addr : Address.Map.key) (key : string) (value : string) : M.(SM.t) unit :=
(M.(SM.op_coloneq) (x := string)) (transient_storage addr key) value.
Module Make_result.
Record signature `{_fargs : FArgs} {StorageKey_Set_t : Set}
{call_kind : Set} : Type := {
StorageKey_Impl : MonadVM.Map.OrderedType (t := Address.t × string);
StorageKey_t := Address.t × string;
StorageKey_compare : Address.t × string → Address.t × string → int;
StorageKey_Set :
RocqOfOCaml.OCamlSet.S (elt := Address.t × string)
(t := StorageKey_Set_t);
t := TS.t;
t__rocq_record_make :
WS.t → WS.t → Block.t →
Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string) → Address._Set.(RocqOfOCaml.OCamlSet.S.t) → Address.t →
MonadVM.Gas.t → MonadVM.Gas.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) →
list MonadVM.Chain.Ethereum.Log.t → U256.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → StorageKey_Set_t → t;
t__rocq_record_get_initial_world_state : t → WS.t;
t__rocq_record_get_world_state : t → WS.t;
t__rocq_record_get_current_block : t → Block.t;
t__rocq_record_get_transient_storage :
t →
Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string);
t__rocq_record_get_accounts_created_in_current_transaction :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_tx_origin : t → Address.t;
t__rocq_record_get_tx_gas_price : t → MonadVM.Gas.t;
t__rocq_record_get_tx_gas_limit : t → MonadVM.Gas.t;
t__rocq_record_get_self_destruct :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_logs : t → list MonadVM.Chain.Ethereum.Log.t;
t__rocq_record_get_refund : t → U256.t;
t__rocq_record_get_accessed_addresses :
t → Address._Set.(RocqOfOCaml.OCamlSet.S.t);
t__rocq_record_get_accessed_keys : t → StorageKey_Set_t;
TLens_initial_world_state : Lens.t TS.t WS.t;
TLens_world_state : Lens.t TS.t WS.t;
TLens_current_block : Lens.t TS.t Block.t;
TLens_transient_storage :
Lens.t TS.t
(Address.Map.t
(MonadVM.Byte_string.B32.(MonadVM.Byte_string.Fixed.Fixed_result.Map).(MonadVM.Byte_string.Fixed.Map.Map_signature.t)
string));
TLens_accounts_created_in_current_transaction :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_tx_origin : Lens.t TS.t Address.t;
TLens_tx_gas_price : Lens.t TS.t MonadVM.Gas.t;
TLens_tx_gas_limit : Lens.t TS.t MonadVM.Gas.t;
TLens_self_destruct : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_logs : Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t);
TLens_refund : Lens.t TS.t U256.t;
TLens_accessed_addresses :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
TLens_accessed_keys :
Lens.t TS.t TS.StorageKey._Set.(RocqOfOCaml.OCamlSet.S.t);
initial_world_state : Lens.t TS.t WS.t;
world_state : Lens.t TS.t WS.t;
current_block : Lens.t TS.t Block.t;
accounts_created_in_current_transaction :
Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
tx_origin : Lens.t TS.t Address.t;
tx_gas_price : Lens.t TS.t MonadVM.Gas.t;
tx_gas_limit : Lens.t TS.t MonadVM.Gas.t;
self_destruct : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
logs : Lens.t TS.t (list MonadVM.Chain.Ethereum.Log.t);
refund : Lens.t TS.t U256.t;
accessed_addresses : Lens.t TS.t Address._Set.(RocqOfOCaml.OCamlSet.S.t);
accessed_keys : Lens.t TS.t StorageKey_Set_t;
empty : TS.t;
make :
MonadVM.State.BlockState.t → Address.t →
MonadVM.Chain.Ethereum.Transaction.t → TS.t;
account : option bool → Address.Map.key → Lens.t TS.t Account.t;
initialize_access_sets :
MonadVM.Chain.Ethereum.Transaction.t → TS.t →
Address._Set.(RocqOfOCaml.OCamlSet.S.t) → TS.t;
M : MonadVM.Monad.State.State_result (_fargs := TS.M_fargs);
Precompiles :
MonadVM.Precompiles.Make.Make_result (_fargs := Precompiles_fargs);
transfer_ether :
Address.Map.key → Address.Map.key →
U256.Impl.(MonadVM.Numeric.Make.Impl.Impl_signature.t) → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
account_exists :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
get_storage : Address.Map.key → string → M.(SM.t) string;
set_storage :
Address.Map.key → string → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.StorageStatus.t × TS.t);
get_balance : Address.Map.key → M.(SM.t) U256.t;
get_code_size :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (int64 × TS.t);
get_code_hash :
Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t);
copy_code :
Address.Map.key → int → int → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (string × TS.t);
selfdestruct :
Address.Map.key → Address.Map.key → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
should_transfer : MonadVM.Evmc.Message.t → bool;
touch_account : string → M.(SM.t) unit;
touch_storage :
string → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (unit × TS.t);
process_call :
option MonadVM.Chain.Ethereum.Transaction.t → MonadVM.Evmc.Message.t →
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
process_syscall :
MonadVM.Evmc.Message.t → M.(SM.t) MonadVM.Evmc.Result.t;
contract_creation_address :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (Address.t × TS.t);
process_create :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_kind := call_kind;
call_impl :
call_kind → MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
try_increment_nonce :
Address.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (bool × TS.t);
call :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_from_eoa :
MonadVM.Chain.Ethereum.Transaction.t → MonadVM.Evmc.Message.t →
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
call_from_monad_system_transaction :
MonadVM.Evmc.Message.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.Result.t × TS.t);
get_tx_context :
TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Evmc.TxContext.t × TS.t);
get_block_hash :
MonadVM.Uint64.t → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t) (option string × TS.t);
emit_log :
Address.t → MonadVM.Byte_string.Bytes.t → list string → M.(SM.t) unit;
access_account :
string → M.(SM.t) MonadVM.Support.Variants.AccessStatus.t;
access_storage :
Address.t → string → TS.t →
MonadVM.Monad.Identity.Impl.(MonadVM.Monad.SIG.t)
(MonadVM.Support.Variants.AccessStatus.t × TS.t);
transient_storage : Address.Map.key → string → Lens.t TS.t string;
get_transient_storage : Address.Map.key → string → M.(SM.t) string;
set_transient_storage :
Address.Map.key → string → string → M.(SM.t) unit;
StorageKey_Set_t := StorageKey_Set_t;
}.
End Make_result.
Definition Make_result `{_fargs : FArgs} := @Make_result.signature _.
Arguments Make_result {_ _ _}.
Definition functor `{_fargs : FArgs}
:Make_result (StorageKey_Set_t := _) (call_kind := _) :=
{|
Make_result.StorageKey_Impl := TS.StorageKey.Impl;
Make_result.StorageKey_compare := TS.StorageKey.compare;
Make_result.StorageKey_Set := TS.StorageKey._Set;
Make_result.t__rocq_record_make :=
fun _rocq_record_field_initial_world_state
_rocq_record_field_world_state _rocq_record_field_current_block
_rocq_record_field_transient_storage
_rocq_record_field_accounts_created_in_current_transaction
_rocq_record_field_tx_origin _rocq_record_field_tx_gas_price
_rocq_record_field_tx_gas_limit _rocq_record_field_self_destruct
_rocq_record_field_logs _rocq_record_field_refund
_rocq_record_field_accessed_addresses _rocq_record_field_accessed_keys
⇒
{| TS.t.initial_world_state := _rocq_record_field_initial_world_state;
TS.t.world_state := _rocq_record_field_world_state;
TS.t.current_block := _rocq_record_field_current_block;
TS.t.transient_storage := _rocq_record_field_transient_storage;
TS.t.accounts_created_in_current_transaction :=
_rocq_record_field_accounts_created_in_current_transaction;
TS.t.tx_origin := _rocq_record_field_tx_origin;
TS.t.tx_gas_price := _rocq_record_field_tx_gas_price;
TS.t.tx_gas_limit := _rocq_record_field_tx_gas_limit;
TS.t.self_destruct := _rocq_record_field_self_destruct;
TS.t.logs := _rocq_record_field_logs;
TS.t.refund := _rocq_record_field_refund;
TS.t.accessed_addresses := _rocq_record_field_accessed_addresses;
TS.t.accessed_keys := _rocq_record_field_accessed_keys; |};
Make_result.t__rocq_record_get_initial_world_state :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.initial_world_state);
Make_result.t__rocq_record_get_world_state :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.world_state);
Make_result.t__rocq_record_get_current_block :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.current_block);
Make_result.t__rocq_record_get_transient_storage :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.transient_storage);
Make_result.t__rocq_record_get_accounts_created_in_current_transaction :=
fun _rocq_record_value ⇒
_rocq_record_value.(TS.t.accounts_created_in_current_transaction);
Make_result.t__rocq_record_get_tx_origin :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_origin);
Make_result.t__rocq_record_get_tx_gas_price :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_gas_price);
Make_result.t__rocq_record_get_tx_gas_limit :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.tx_gas_limit);
Make_result.t__rocq_record_get_self_destruct :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.self_destruct);
Make_result.t__rocq_record_get_logs :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.logs);
Make_result.t__rocq_record_get_refund :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.refund);
Make_result.t__rocq_record_get_accessed_addresses :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.accessed_addresses);
Make_result.t__rocq_record_get_accessed_keys :=
fun _rocq_record_value ⇒ _rocq_record_value.(TS.t.accessed_keys);
Make_result.TLens_initial_world_state := TS.TLens.initial_world_state;
Make_result.TLens_world_state := TS.TLens.world_state;
Make_result.TLens_current_block := TS.TLens.current_block;
Make_result.TLens_transient_storage := TS.TLens.transient_storage;
Make_result.TLens_accounts_created_in_current_transaction :=
TS.TLens.accounts_created_in_current_transaction;
Make_result.TLens_tx_origin := TS.TLens.tx_origin;
Make_result.TLens_tx_gas_price := TS.TLens.tx_gas_price;
Make_result.TLens_tx_gas_limit := TS.TLens.tx_gas_limit;
Make_result.TLens_self_destruct := TS.TLens.self_destruct;
Make_result.TLens_logs := TS.TLens.logs;
Make_result.TLens_refund := TS.TLens.refund;
Make_result.TLens_accessed_addresses := TS.TLens.accessed_addresses;
Make_result.TLens_accessed_keys := TS.TLens.accessed_keys;
Make_result.initial_world_state := initial_world_state;
Make_result.world_state := world_state;
Make_result.current_block := current_block;
Make_result.accounts_created_in_current_transaction :=
accounts_created_in_current_transaction;
Make_result.tx_origin := tx_origin;
Make_result.tx_gas_price := tx_gas_price;
Make_result.tx_gas_limit := tx_gas_limit;
Make_result.self_destruct := self_destruct;
Make_result.logs := logs;
Make_result.refund := refund;
Make_result.accessed_addresses := accessed_addresses;
Make_result.accessed_keys := accessed_keys;
Make_result.empty := empty;
Make_result.make := make;
Make_result.account := account;
Make_result.initialize_access_sets := initialize_access_sets;
Make_result.M := M;
Make_result.Precompiles := Precompiles;
Make_result.transfer_ether := transfer_ether;
Make_result.account_exists := account_exists;
Make_result.get_storage := get_storage;
Make_result.set_storage := set_storage;
Make_result.get_balance := get_balance;
Make_result.get_code_size := get_code_size;
Make_result.get_code_hash := get_code_hash;
Make_result.copy_code := copy_code;
Make_result.selfdestruct := selfdestruct;
Make_result.should_transfer := should_transfer;
Make_result.touch_account := touch_account;
Make_result.touch_storage := touch_storage;
Make_result.process_call := process_call;
Make_result.process_syscall := process_syscall;
Make_result.contract_creation_address := contract_creation_address;
Make_result.process_create := process_create;
Make_result.call_impl := call_impl;
Make_result.try_increment_nonce := try_increment_nonce;
Make_result.call := call;
Make_result.call_from_eoa := call_from_eoa;
Make_result.call_from_monad_system_transaction :=
call_from_monad_system_transaction;
Make_result.get_tx_context := get_tx_context;
Make_result.get_block_hash := get_block_hash;
Make_result.emit_log := emit_log;
Make_result.access_account := access_account;
Make_result.access_storage := access_storage;
Make_result.transient_storage := transient_storage;
Make_result.get_transient_storage := get_transient_storage;
Make_result.set_transient_storage := set_transient_storage
|}.
End Make.
Definition Make
(ChainParams : MonadVM.Chain.Monad.PARAMS)
(Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) :=
@Make.functor (Make.Build_FArgs ChainParams Vm).
Module Instantiate.
Class FArgs := {
ChainParams : MonadVM.Chain.Monad.PARAMS;
Vm_parameter :
∀ (Host : MonadVM.Evmc.HOST (t := TS.t)),
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
}.
Definition MonadVM_Evmc_Instantiate_include `{_fargs : FArgs} :=
MonadVM.Evmc.Instantiate
((ltac:(constructor) : MonadVM.Evmc.Vm_H_signature (t := TS.t)) :
MonadVM.Evmc.Vm_H_signature (t := TS.t))
(fun
(Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) ⇒
let module_coercion := Make ChainParams Vm in
{|
MonadVM.Evmc.HOST.account_exists :=
module_coercion.(Make.Make_result.account_exists);
MonadVM.Evmc.HOST.get_storage :=
module_coercion.(Make.Make_result.get_storage);
MonadVM.Evmc.HOST.set_storage :=
module_coercion.(Make.Make_result.set_storage);
MonadVM.Evmc.HOST.get_balance :=
module_coercion.(Make.Make_result.get_balance);
MonadVM.Evmc.HOST.get_code_size :=
module_coercion.(Make.Make_result.get_code_size);
MonadVM.Evmc.HOST.get_code_hash :=
module_coercion.(Make.Make_result.get_code_hash);
MonadVM.Evmc.HOST.copy_code :=
module_coercion.(Make.Make_result.copy_code);
MonadVM.Evmc.HOST.selfdestruct :=
module_coercion.(Make.Make_result.selfdestruct);
MonadVM.Evmc.HOST.call := module_coercion.(Make.Make_result.call);
MonadVM.Evmc.HOST.get_tx_context :=
module_coercion.(Make.Make_result.get_tx_context);
MonadVM.Evmc.HOST.get_block_hash :=
module_coercion.(Make.Make_result.get_block_hash);
MonadVM.Evmc.HOST.emit_log :=
module_coercion.(Make.Make_result.emit_log);
MonadVM.Evmc.HOST.access_account :=
module_coercion.(Make.Make_result.access_account);
MonadVM.Evmc.HOST.access_storage :=
module_coercion.(Make.Make_result.access_storage);
MonadVM.Evmc.HOST.get_transient_storage :=
module_coercion.(Make.Make_result.get_transient_storage);
MonadVM.Evmc.HOST.set_transient_storage :=
module_coercion.(Make.Make_result.set_transient_storage)
|}) Vm_parameter.
Inclusion of the module MonadVM_Evmc_Instantiate_include
Module Vm.
Definition execute `{_fargs : FArgs} :
MonadVM.Evmc.Message.t → MonadVM.Byte_string.Bytes.t → TS.t →
MonadVM.Evmc.Result.t × TS.t :=
MonadVM_Evmc_Instantiate_include.(MonadVM.Evmc.Instantiate.Instantiate_signature.Vm).(MonadVM.Evmc.Vm.SIG.execute).
End Vm.
Definition Vm `{_fargs : FArgs} :=
MonadVM_Evmc_Instantiate_include.(MonadVM.Evmc.Instantiate.Instantiate_signature.Vm).
Definition Host_fargs `{_fargs : FArgs} :=
Make.Build_FArgs ChainParams ltac:(refine (_ :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))); constructor; [refine (Vm.(MonadVM.Evmc.Vm.SIG.execute))]; shelve).
Definition Host `{_fargs : FArgs} : Make.Make_result (_fargs := Host_fargs) :=
(Make.functor (_fargs := (Host_fargs ))).
Module Instantiate_result.
Record signature `{_fargs : FArgs} {Host_StorageKey_Set_t : Set}
{Host_call_kind : Set} : Type := {
Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
Host :
Make.Make_result (_fargs := Host_fargs)
(StorageKey_Set_t := Host_StorageKey_Set_t)
(call_kind := Host_call_kind);
Host_StorageKey_Set_t := Host_StorageKey_Set_t;
Host_call_kind := Host_call_kind;
}.
End Instantiate_result.
Definition Instantiate_result `{_fargs : FArgs} :=
@Instantiate_result.signature _.
Arguments Instantiate_result {_ _ _}.
Definition functor `{_fargs : FArgs}
:Instantiate_result (Host_StorageKey_Set_t := _) (Host_call_kind := _) :=
{|
Instantiate_result.Vm := Vm;
Instantiate_result.Host := Host
|}.
End Instantiate.
Definition Instantiate
(ChainParams : MonadVM.Chain.Monad.PARAMS)
(Vm_parameter :
∀ (Host : MonadVM.Evmc.HOST (t := TS.t)),
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) :=
@Instantiate.functor (Instantiate.Build_FArgs ChainParams Vm_parameter).
Definition execute `{_fargs : FArgs} :
MonadVM.Evmc.Message.t → MonadVM.Byte_string.Bytes.t → TS.t →
MonadVM.Evmc.Result.t × TS.t :=
MonadVM_Evmc_Instantiate_include.(MonadVM.Evmc.Instantiate.Instantiate_signature.Vm).(MonadVM.Evmc.Vm.SIG.execute).
End Vm.
Definition Vm `{_fargs : FArgs} :=
MonadVM_Evmc_Instantiate_include.(MonadVM.Evmc.Instantiate.Instantiate_signature.Vm).
Definition Host_fargs `{_fargs : FArgs} :=
Make.Build_FArgs ChainParams ltac:(refine (_ :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))); constructor; [refine (Vm.(MonadVM.Evmc.Vm.SIG.execute))]; shelve).
Definition Host `{_fargs : FArgs} : Make.Make_result (_fargs := Host_fargs) :=
(Make.functor (_fargs := (Host_fargs ))).
Module Instantiate_result.
Record signature `{_fargs : FArgs} {Host_StorageKey_Set_t : Set}
{Host_call_kind : Set} : Type := {
Vm :
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)));
Host :
Make.Make_result (_fargs := Host_fargs)
(StorageKey_Set_t := Host_StorageKey_Set_t)
(call_kind := Host_call_kind);
Host_StorageKey_Set_t := Host_StorageKey_Set_t;
Host_call_kind := Host_call_kind;
}.
End Instantiate_result.
Definition Instantiate_result `{_fargs : FArgs} :=
@Instantiate_result.signature _.
Arguments Instantiate_result {_ _ _}.
Definition functor `{_fargs : FArgs}
:Instantiate_result (Host_StorageKey_Set_t := _) (Host_call_kind := _) :=
{|
Instantiate_result.Vm := Vm;
Instantiate_result.Host := Host
|}.
End Instantiate.
Definition Instantiate
(ChainParams : MonadVM.Chain.Monad.PARAMS)
(Vm_parameter :
∀ (Host : MonadVM.Evmc.HOST (t := TS.t)),
MonadVM.Evmc.Vm.SIG
(_fargs :=
MonadVM.Evmc.Vm.Build_FArgs (ltac:(constructor) :
MonadVM.Evmc.Vm_H_signature (t := TS.t)))) :=
@Instantiate.functor (Instantiate.Build_FArgs ChainParams Vm_parameter).