@@ -3,6 +3,61 @@ Require Import CoqOfRust.links.M.
3
3
Require Import CoqOfRust.revm.links.dependencies.
4
4
Require Import CoqOfRust.revm.links.primitives.bytecode.eof.
5
5
6
+ (*
7
+ #[derive(Debug, Clone, PartialEq, Eq)]
8
+ #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9
+ pub enum EOFCreateKind {
10
+ Tx {
11
+ initdata: Bytes,
12
+ },
13
+ Opcode {
14
+ initcode: Eof,
15
+ input: Bytes,
16
+ created_address: Address,
17
+ },
18
+ }
19
+ *)
20
+
21
+ Module EOFCreateKind.
22
+ Inductive t : Type :=
23
+ | Tx (initdata : Bytes.t)
24
+ | Opcode (initcode : Eof.t) (input : Bytes.t) (created_address : Address.t).
25
+
26
+ Global Instance IsLink : Link t := {
27
+ Φ := Ty.path "revm_interpreter::interpreter::eof_create_input::EOFCreateKind";
28
+ φ k :=
29
+ match k with
30
+ | Tx initdata =>
31
+ Value.StructRecord "revm_interpreter::interpreter::eof_create_input::EOFCreateKind::Tx" [
32
+ ("initdata", φ initdata)
33
+ ]
34
+ | Opcode initcode input created_address =>
35
+ Value.StructRecord "revm_interpreter::interpreter::eof_create_input::EOFCreateKind::Opcode" [
36
+ ("initcode", φ initcode);
37
+ ("input", φ input);
38
+ ("created_address", φ created_address)
39
+ ]
40
+ end ;
41
+ }.
42
+ End EOFCreateKind.
43
+
44
+ (*
45
+ impl EOFCreateKind {
46
+ /// Returns created address
47
+ pub fn created_address(&self) -> Option<&Address> {
48
+ match self {
49
+ EOFCreateKind::Opcode {
50
+ created_address, ..
51
+ } => Some(created_address),
52
+ EOFCreateKind::Tx { .. } => None,
53
+ }
54
+ }
55
+ }
56
+ *)
57
+
58
+
59
+
60
+
6
61
(*
7
62
/// Inputs for EOF create call.
8
63
#[derive(Debug, Default, Clone, PartialEq, Eq)]
@@ -21,7 +76,7 @@ Require Import CoqOfRust.revm.links.primitives.bytecode.eof.
21
76
}
22
77
*)
23
78
24
- Module EOFCreateInput .
79
+ Module EOFCreateInputs .
25
80
Record t : Set := {
26
81
caller : Address.t;
27
82
created_address : Address.t;
@@ -31,14 +86,78 @@ Module EOFCreateInput.
31
86
}.
32
87
33
88
Global Instance IsLink : Link t := {
34
- Φ := Ty.path "revm_interpreter::interpreter::eof_create_input::EOFCreateInput ";
89
+ Φ := Ty.path "revm_interpreter::interpreter::eof_create_input::EOFCreateInputs ";
35
90
φ x :=
36
- Value.StructRecord "revm_interpreter::interpreter::eof_create_input::EOFCreateInput " [
91
+ Value.StructRecord "revm_interpreter::interpreter::eof_create_input::EOFCreateInputs " [
37
92
("caller", φ x.(caller));
38
93
("created_address", φ x.(created_address));
39
94
("value", φ x.(value));
40
95
("eof_init_code", φ x.(eof_init_code));
41
96
("gas_limit", φ x.(gas_limit))
42
97
];
43
98
}.
44
- End EOFCreateInput.
99
+ End EOFCreateInputs.
100
+
101
+ Module Impl_EOFCreateInputs.
102
+ Definition Self := EOFCreateInputs.t.
103
+
104
+ (*
105
+ pub fn new(caller: Address, value: U256, gas_limit: u64, kind: EOFCreateKind) -> Self {
106
+ //let (eof_init_code, input) = Eof::decode_dangling(tx.data.clone())?;
107
+ EOFCreateInputs {
108
+ caller,
109
+ value,
110
+ gas_limit,
111
+ kind,
112
+ }
113
+ }
114
+ *)
115
+
116
+ Parameter address_default : Address.t.
117
+ Parameter eof_decode : Bytes.t -> Eof.t.
118
+
119
+ Definition new (caller : Address.t) (value : U256.t)
120
+ (gas_limit : U64.t) (kind : EOFCreateKind.t) : Self :=
121
+ {| EOFCreateInputs.caller := caller;
122
+ EOFCreateInputs.created_address :=
123
+ match kind with
124
+ | EOFCreateKind.Opcode _ _ addr => addr
125
+ | EOFCreateKind.Tx _ => address_default
126
+ end ;
127
+ EOFCreateInputs.value := value;
128
+ EOFCreateInputs.eof_init_code :=
129
+ match kind with
130
+ | EOFCreateKind.Opcode code _ _ => code
131
+ | EOFCreateKind.Tx data => eof_decode data
132
+ end ;
133
+ EOFCreateInputs.gas_limit := gas_limit |}.
134
+
135
+ (*
136
+ pub fn new_opcode(
137
+ caller: Address,
138
+ created_address: Address,
139
+ value: U256,
140
+ eof_init_code: Eof,
141
+ gas_limit: u64,
142
+ input: Bytes,
143
+ ) -> EOFCreateInputs {
144
+ EOFCreateInputs::new(
145
+ caller,
146
+ value,
147
+ gas_limit,
148
+ EOFCreateKind::Opcode {
149
+ initcode: eof_init_code,
150
+ input,
151
+ created_address,
152
+ },
153
+ )
154
+ }
155
+ *)
156
+
157
+ Definition new_opcode (caller : Address.t) (created_address : Address.t)
158
+ (value : U256.t) (eof_init_code : Eof.t)
159
+ (gas_limit : U64.t) (input : Bytes.t) : Self :=
160
+ new caller value gas_limit (EOFCreateKind.Opcode eof_init_code input created_address).
161
+
162
+ End Impl_EOFCreateInputs.
163
+
0 commit comments