Skip to content

Link file for block_info.v, Part 2 #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eacac18
minor: small change to make PR visible
InfiniteEchoes Mar 21, 2025
c5a95c1
feat: Issue with `arithmetic`
InfiniteEchoes Mar 21, 2025
640c495
feat: Add `i256.v`
InfiniteEchoes Mar 21, 2025
b31bff4
minor: comments
InfiniteEchoes Mar 21, 2025
b407839
minor: comments
InfiniteEchoes Mar 21, 2025
6188953
minor: debugging `Into`
InfiniteEchoes Mar 22, 2025
41f15e0
suggestion commit as comment
clarus Mar 24, 2025
06461e6
minor: progress
InfiniteEchoes Mar 25, 2025
b3f96bc
feat: Progress on `arithmetic` with `i256_mod`
InfiniteEchoes Mar 25, 2025
9425080
minor: progress
InfiniteEchoes Mar 26, 2025
77bb5f3
minor: progress
InfiniteEchoes Mar 26, 2025
cc6de07
minor: move file to correct directory
InfiniteEchoes Mar 26, 2025
c22f4ea
feat: add `Uint` operation links
InfiniteEchoes Mar 26, 2025
1d63421
minor: progress
InfiniteEchoes Mar 26, 2025
3c359ef
minor: progress
InfiniteEchoes Mar 26, 2025
75bbf59
minor: fix parameters in `modular`
InfiniteEchoes Mar 26, 2025
0dda6e3
minor: progress
InfiniteEchoes Mar 26, 2025
15f0842
feat: add `pow` links
InfiniteEchoes Mar 26, 2025
6a13bb3
minor: progress on `arithmetic`
InfiniteEchoes Mar 27, 2025
a99ed9c
minor: reduce issues in `block_info` to `block`
InfiniteEchoes Mar 27, 2025
fcc17f9
minor: progress on `block`
InfiniteEchoes Mar 27, 2025
f859194
minor: progress
InfiniteEchoes Mar 27, 2025
0998589
minor: comment
InfiniteEchoes Mar 27, 2025
8f32e06
minor: deleted Host parameter that is never used
InfiniteEchoes Mar 27, 2025
5138fdf
minor: resetted `instructions`
InfiniteEchoes Mar 27, 2025
fbef042
minor: comment
InfiniteEchoes Mar 27, 2025
3af7b5d
minor: progress
InfiniteEchoes Mar 27, 2025
0c2f5b4
feat: Resolved most dependencies for `block_info`
InfiniteEchoes Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions CoqOfRust/core/convert/links/mod.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ pub trait Into<T>: Sized {
}
*)
Module Into.
Definition trait (Self T : Set) `{Link Self} `{Link T} : TraitMethod.Header.t :=
("core::convert::Into", [], [Φ T], Φ Self).

Definition Run_into (Self T : Set) `{Link Self} `{Link T} : Set :=
{into @
IsTraitMethod.t "core::convert::Into" [] [Φ T] (Φ Self) "into" into *
forall (self : Self),
{{ into [] [] [φ self] 🔽 T }}
}.
TraitMethod.C (trait Self T) "into" (fun method =>
forall (self : Ref.t Pointer.Kind.Ref Self),
Run.Trait method [] [] [ φ self ] T
).

Record Run (Self : Set) (T : Set) `{Link Self} `{Link T} : Set := {
Class Run (Self : Set) (T : Set) `{Link Self} `{Link T} : Set := {
into : Run_into Self T;
}.
End Into.
12 changes: 12 additions & 0 deletions CoqOfRust/revm/revm_interpreter/instructions/links/arithmetic.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Require Import revm.revm_context_interface.links.host.
Require Import revm.revm_interpreter.links.gas.
Require Import revm.revm_interpreter.links.interpreter.
Require Import revm.revm_interpreter.links.interpreter_types.
(* NOTE: might be deleted *)
(* Require Import revm.revm_interpreter.instructions.i256. *)
Require Import revm.revm_interpreter.instructions.arithmetic.
Require Import ruint.links.add.
Require Import ruint.links.cmp.
Expand Down Expand Up @@ -162,6 +164,16 @@ Proof.
destruct run_LoopControl_for_Control.
destruct run_StackTrait_for_Stack.
(* TODO: revm_interpreter::instructions::i256::i256_div *)
(* NOTE:
Trait instructions.i256.i256_div [] []
[lib.Uint.IsLink.(φ) value; lib.Uint.IsLink.(φ) value1]
(lib.Uint.t {| Integer.value := 256 |} {| Integer.value := 4 |})
Here's an interesting result: the goal says we need to prove `i256_div` belongs to some trait,
in othr word, it's an associated function.
Two problems here:
1. `i256_div` is not an associated function;
2. `i256_div` seems to be unlinkable. My tried to generate an instance but it seems to be unrelated.
*)
run_symbolic.
(* Defined. *)
Admitted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Require Import core.convert.links.mod.
Import Impl_SpecId.
Import Impl_Gas.
Import from.Impl_Uint.
(* TODO: check if we need to implement `into` function in `from` *)
(* Import into.Impl_Uint. *)

(* TODO(progress):
- finish link in `dependencies` and link to here
Expand Down Expand Up @@ -60,9 +58,7 @@ Proof.
destruct run_CfgGetter.
destruct run_Cfg_for_Cfg.
run_symbolic.
(* TODO: check `cfg::cfg` *)
Admitted.
(* Defined. *)
Defined.

(*
pub fn coinbase<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand Down Expand Up @@ -94,6 +90,8 @@ Proof.
destruct run_Host_for_H.
destruct run_BlockGetter.
destruct run_Block_for_Block.
(* TODO: why `core::convert::Into` still doesn't work? *)
(* assert ( forall (A : Set), A ) . *)
run_symbolic.
Admitted.

Expand Down
29 changes: 28 additions & 1 deletion CoqOfRust/revm/revm_interpreter/instructions/links/i256.v
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
(* Initial stub *)
Require Import CoqOfRust.CoqOfRust.
Require Import CoqOfRust.links.M.
Require Import revm.revm_interpreter.instructions.i256.

(* NOTE: This function isn't associated with a trait. I wonder if this is the correct way to translate it... *)
(* pub fn i256_div(mut first: U256, mut second: U256) -> U256 *)

Global Instance Instance_IsFunction_i256_div :
M.IsFunction.Trait "revm::revm_interpreter::instructions::i256::i256_div" instructions.i256.i256_div.
Admitted.
Global Typeclasses Opaque instructions.i256.i256_div.

(* NOTE: 2nd failed attempt:

Definition trait : TraitMethod.Header.t :=
("revm::revm_interpreter::instructions::i256", [], [], []).

Definition Run_i256_div : Set :=
TraitMethod.C trait "i256_div" (fun method =>
forall (first : Ref.t Pointer.Kind.MutRef U256.t)
(second : Ref.t Pointer.Kind.MutRef U256.t),
Run.Trait method [] [] [ φ first; φ second; ] U256.t
).

Class Run : Set := {
i256_div : Run_i256_div;
}.
*)
Loading