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 23 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.
43 changes: 23 additions & 20 deletions CoqOfRust/revm/links/dependencies.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ Require Import core.links.clone.
Require Import core.links.default.
Require Import ruint.links.lib.

(*
TODO:
- Start link with beneficiary's Address return type
- In `beneficiary`, link it to Address type(?)
- Link Addesss::into_word
- Link Uint::into
*)
Module U256.
Definition t : Set :=
Uint.t {| Integer.value := 256 |} {| Integer.value := 4 |}.
End U256.

Module alloy_primitives.
Module bits.
Expand Down Expand Up @@ -60,11 +57,11 @@ Module alloy_primitives.
forall (N : Usize.t),
core.convert.links.mod.From.Run (Self N) (T := array.t U8.t N).
End Impl_From_for_FixedBytes.
Module Impl_Into_for_FixedBytes.

Module Impl_Into_array_for_FixedBytes.
Definition Self (N : Usize.t) : Set :=
FixedBytes.t N.

(* fn into(self) -> Uint *)
Parameter into : forall (N : Usize.t), PolymorphicFunction.t.

Expand All @@ -77,7 +74,22 @@ Module alloy_primitives.
Parameter run :
forall (N : Usize.t),
core.convert.links.mod.Into.Run (Self N) (array.t U8.t N).
End Impl_Into_for_FixedBytes.
End Impl_Into_array_for_FixedBytes.

Module Impl_Into_U256_for_FixedBytes.
Definition Self : Set :=
FixedBytes.t {| Integer.value := 32 |}.

Parameter into : PolymorphicFunction.t.

Axiom Implements :
M.IsTraitInstance
"core::convert::Into" [] [ Φ U256.t ] (Φ Self)
[ ("into", InstanceField.Method into) ].

Parameter run :
core.convert.links.mod.Into.Run Self U256.t.
End Impl_Into_U256_for_FixedBytes.
End fixed.

Module address.
Expand Down Expand Up @@ -228,19 +240,10 @@ Module FixedBytes.
Φ := Ty.path "alloy_primitives::bits::fixed::FixedBytes";
φ := to_value;
}.

(* TODO:
- (alloy_primitives::FixedBytes) fn into(self) -> Uint
*)
End FixedBytes.

(** ** Here we define some aliases that are convenient *)

Module U256.
Definition t : Set :=
Uint.t {| Integer.value := 256 |} {| Integer.value := 4 |}.
End U256.

Module B256.
Definition t : Set :=
alloy_primitives.bits.links.fixed.FixedBytes.t {| Integer.value := 32 |}.
Expand Down
9 changes: 5 additions & 4 deletions CoqOfRust/revm/revm_context_interface/links/block.v
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@ Module BlockGetter.
Definition trait (Self : Set) `{Link Self} : TraitMethod.Header.t :=
("revm_context_interface::block::BlockGetter", [], [], Φ Self).

Definition Run_block (Self : Set) `{Link Self} : Set :=
Definition Run_block (Self : Set) `{Link Self} (types : Types.t) `{Types.AreLinks types} : Set :=
TraitMethod.C (trait Self) "block" (fun method =>
forall (self : Ref.t Pointer.Kind.Ref Self),
Run.Trait method [] [] [ φ self ] unit
(* Is there something wrong with `Self.Block` here? *)
Run.Trait method [] [] [ φ self ] (types.(Types.Block))
).

Class Run (Self : Set) `{Link Self} (types : Types.t) `{Types.AreLinks types} : Set := {
Class Run (Self : Set) `{Link Self} (types : Types.t) `{Types.AreLinks types} : Set := {
Block_IsAssociated :
IsTraitAssociatedType
"revm_context_interface::block::BlockGetter" [] [] (Φ Self)
"Block" (Φ types.(Types.Block));
run_Block_for_Block : Block.Run types.(Types.Block);
block : Run_block Self;
block : Run_block Self types;
}.
End BlockGetter.
17 changes: 16 additions & 1 deletion CoqOfRust/revm/revm_interpreter/gas/links/calc.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ Require Import CoqOfRust.CoqOfRust.
Require Import CoqOfRust.links.M.
Require Import core.num.mod.
Require Import core.num.links.mod.
Require Import revm_interpreter.gas.calc.
Require Import revm_specification.links.hardfork.
Require Import CoqOfRust.revm.links.dependencies.
Require revm_interpreter.gas.links.constants.
Require Import revm_interpreter.gas.calc.

Import Impl_u64.

Expand All @@ -23,3 +25,16 @@ Proof.
constructor.
run_symbolic.
Defined.

(* NOTE: since we don't have U256 for now, we use Usize instead *)
(* pub fn exp_cost(spec_id: SpecId, power: U256) -> Option<u64> *)
Instance run_exp_cost (spec_id : SpecId.t) (power : U256.t) :
Run.Trait
gas.calc.exp_cost [] [] [ φ spec_id; φ power ]
(option U64.t).
Proof.
constructor.
run_symbolic.
(* NOTE: Should I finish the proof? *)
Admitted.
(* Defined. *)
30 changes: 14 additions & 16 deletions CoqOfRust/revm/revm_interpreter/instructions/links/arithmetic.v
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
Require Import CoqOfRust.CoqOfRust.
Require Import CoqOfRust.links.M.
Require Import revm.revm_interpreter.instructions.arithmetic.
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.
Require Import revm.revm_interpreter.instructions.arithmetic.
Require Import revm.revm_interpreter.instructions.links.i256.
(* TODO: see if its necessary to import `option` *)
(* Require Import core.links.option. *)
Require Import ruint.links.add.
Require Import ruint.links.cmp.
Require Import ruint.links.div.
Require Import ruint.links.mul.
Require Import ruint.links.modular.
Require Import ruint.links.pow.
Require Import core.links.cmp.

Import Impl_Gas.
Import add.Impl_Uint.
Import cmp.Impl_Uint.
Import div.Impl_Uint.
Import mul.Impl_Uint.
Import modular.Impl_Uint.
Import pow.Impl_Uint.

(*
pub fn add<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand All @@ -38,8 +46,6 @@ Proof.
cbn.
eapply Run.Rewrite. {
progress repeat erewrite IsTraitAssociatedType_eq by apply run_InterpreterTypes_for_WIRE.
(* Seems like the code doesnt envolve proofs on `H` *)
(* progress repeat erewrite IsTraitAssociatedType_eq by apply run_Host_for_H. *)
reflexivity.
}
destruct run_InterpreterTypes_for_WIRE.
Expand Down Expand Up @@ -161,10 +167,8 @@ Proof.
destruct run_InterpreterTypes_for_WIRE.
destruct run_LoopControl_for_Control.
destruct run_StackTrait_for_Stack.
(* TODO: revm_interpreter::instructions::i256::i256_div *)
run_symbolic.
(* Defined. *)
Admitted.
Defined.

(*
pub fn rem<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand Down Expand Up @@ -219,10 +223,8 @@ Proof.
destruct run_InterpreterTypes_for_WIRE.
destruct run_LoopControl_for_Control.
destruct run_StackTrait_for_Stack.
(* TODO: revm_interpreter::instructions::i256::i256_mod *)
run_symbolic.
Admitted.
(* Defined. *)
Defined.

(*
pub fn addmod<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand All @@ -249,10 +251,8 @@ Proof.
destruct run_InterpreterTypes_for_WIRE.
destruct run_LoopControl_for_Control.
destruct run_StackTrait_for_Stack.
(* TODO: Uint::add_mod *)
run_symbolic.
Admitted.
(* Defined. *)
Defined.

(*
pub fn mulmod<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand All @@ -279,10 +279,8 @@ Proof.
destruct run_InterpreterTypes_for_WIRE.
destruct run_LoopControl_for_Control.
destruct run_StackTrait_for_Stack.
(* TODO: Uint::mul_mod *)
run_symbolic.
Admitted.
(* Defined. *)
Defined.

(*
pub fn exp<WIRE: InterpreterTypes, H: Host + ?Sized>(
Expand Down Expand Up @@ -312,7 +310,7 @@ Proof.
destruct run_RuntimeFlag_for_RuntimeFlag.
(* TODO:
- calc.gas.calc.exp_cost
- Uint::pow*)
*)
run_symbolic.
Admitted.
(* Defined. *)
Expand Down
Loading
Loading