|
1 | 1 | (module |
2 | 2 | (import "seal0" "seal_input" (func $seal_input (param i32 i32))) |
3 | 3 | (import "seal0" "seal_balance" (func $seal_balance (param i32 i32))) |
4 | | - (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) |
5 | | - (import "seal0" "seal_instantiate" (func $seal_instantiate |
6 | | - (param i32 i32 i64 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) |
| 4 | + (import "seal2" "call" (func $seal_call (param i32 i32 i64 i64 i32 i32 i32 i32 i32 i32) (result i32))) |
| 5 | + (import "seal2" "instantiate" (func $seal_instantiate |
| 6 | + (param i32 i64 i64 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) |
7 | 7 | )) |
8 | 8 | (import "env" "memory" (memory 1 1)) |
9 | 9 |
|
|
43 | 43 | (set_local $exit_code |
44 | 44 | (call $seal_instantiate |
45 | 45 | (i32.const 24) ;; Pointer to the code hash. |
46 | | - (i32.const 32) ;; Length of the code hash. |
47 | | - (i64.const 0) ;; How much gas to devote for the execution. 0 = all. |
| 46 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 47 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 48 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
48 | 49 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
49 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
50 | 50 | (i32.const 9) ;; Pointer to input data buffer address |
51 | 51 | (i32.const 7) ;; Length of input data buffer |
52 | | - (i32.const 4294967295) ;; u32 max sentinel value: do not copy address |
53 | | - (i32.const 0) ;; Length is ignored in this case |
| 52 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy address |
| 53 | + (i32.const 0) ;; Length is ignored in this case |
54 | 54 | (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
55 | | - (i32.const 0) ;; Length is ignored in this case |
56 | | - (i32.const 0) ;; salt_ptr |
57 | | - (i32.const 0) ;; salt_le |
| 55 | + (i32.const 0) ;; Length is ignored in this case |
| 56 | + (i32.const 0) ;; salt_ptr |
| 57 | + (i32.const 0) ;; salt_le |
58 | 58 | ) |
59 | 59 | ) |
60 | 60 |
|
|
63 | 63 | (i32.eq (get_local $exit_code) (i32.const 2)) ;; ReturnCode::CalleeReverted |
64 | 64 | ) |
65 | 65 |
|
66 | | - ;; Fail to deploy the contract due to insufficient gas. |
| 66 | + ;; Fail to deploy the contract due to insufficient ref_time weight. |
67 | 67 | (set_local $exit_code |
68 | 68 | (call $seal_instantiate |
69 | 69 | (i32.const 24) ;; Pointer to the code hash. |
70 | | - (i32.const 32) ;; Length of the code hash. |
71 | | - (i64.const 1) ;; Supply too little gas |
| 70 | + (i64.const 1) ;; Supply too little ref_time weight |
| 71 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 72 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
72 | 73 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
73 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
74 | 74 | (i32.const 8) ;; Pointer to input data buffer address |
75 | 75 | (i32.const 8) ;; Length of input data buffer |
76 | 76 | (i32.const 4294967295) ;; u32 max sentinel value: do not copy address |
77 | | - (i32.const 0) ;; Length is ignored in this case |
| 77 | + (i32.const 0) ;; Length is ignored in this case |
78 | 78 | (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
79 | | - (i32.const 0) ;; Length is ignored in this case |
80 | | - (i32.const 0) ;; salt_ptr |
81 | | - (i32.const 0) ;; salt_le |
| 79 | + (i32.const 0) ;; Length is ignored in this case |
| 80 | + (i32.const 0) ;; salt_ptr |
| 81 | + (i32.const 0) ;; salt_le |
| 82 | + |
| 83 | + ) |
| 84 | + ) |
| 85 | + |
| 86 | + ;; Check for special trap exit status. |
| 87 | + (call $assert |
| 88 | + (i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped |
| 89 | + ) |
| 90 | + |
| 91 | + ;; Fail to deploy the contract due to insufficient ref_time weight. |
| 92 | + (set_local $exit_code |
| 93 | + (call $seal_instantiate |
| 94 | + (i32.const 24) ;; Pointer to the code hash. |
| 95 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 96 | + (i64.const 1) ;; Supply too little proof_size weight |
| 97 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
| 98 | + (i32.const 0) ;; Pointer to the buffer with value to transfer |
| 99 | + (i32.const 8) ;; Pointer to input data buffer address |
| 100 | + (i32.const 8) ;; Length of input data buffer |
| 101 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy address |
| 102 | + (i32.const 0) ;; Length is ignored in this case |
| 103 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
| 104 | + (i32.const 0) ;; Length is ignored in this case |
| 105 | + (i32.const 0) ;; salt_ptr |
| 106 | + (i32.const 0) ;; salt_le |
82 | 107 |
|
83 | 108 | ) |
84 | 109 | ) |
|
98 | 123 | (set_local $exit_code |
99 | 124 | (call $seal_instantiate |
100 | 125 | (i32.const 24) ;; Pointer to the code hash. |
101 | | - (i32.const 32) ;; Length of the code hash. |
102 | | - (i64.const 0) ;; How much gas to devote for the execution. 0 = all. |
| 126 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 127 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 128 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
103 | 129 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
104 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
105 | 130 | (i32.const 8) ;; Pointer to input data buffer address |
106 | 131 | (i32.const 8) ;; Length of input data buffer |
107 | | - (i32.const 16) ;; Pointer to the address output buffer |
108 | | - (i32.sub (get_local $sp) (i32.const 4)) ;; Pointer to the address buffer length |
109 | | - (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
110 | | - (i32.const 0) ;; Length is ignored in this case |
111 | | - (i32.const 0) ;; salt_ptr |
112 | | - (i32.const 0) ;; salt_le |
| 132 | + (i32.const 16) ;; Pointer to the address output buffer |
| 133 | + (i32.sub (get_local $sp) (i32.const 4)) ;; Pointer to the address buffer length |
| 134 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
| 135 | + (i32.const 0) ;; Length is ignored in this case |
| 136 | + (i32.const 0) ;; salt_ptr |
| 137 | + (i32.const 0) ;; salt_le |
113 | 138 |
|
114 | 139 | ) |
115 | 140 | ) |
|
139 | 164 | ;; Call the new contract and expect it to return failing exit code. |
140 | 165 | (set_local $exit_code |
141 | 166 | (call $seal_call |
| 167 | + (i32.const 0) ;; Set no flag |
142 | 168 | (i32.const 16) ;; Pointer to "callee" address. |
143 | | - (i32.const 32) ;; Length of "callee" address. |
144 | | - (i64.const 0) ;; How much gas to devote for the execution. 0 = all. |
| 169 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 170 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 171 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
145 | 172 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
146 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
147 | 173 | (i32.const 9) ;; Pointer to input data buffer address |
148 | 174 | (i32.const 7) ;; Length of input data buffer |
149 | | - (i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer |
150 | | - (i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len |
| 175 | + (i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer |
| 176 | + (i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len |
151 | 177 | ) |
152 | 178 | ) |
153 | 179 |
|
|
167 | 193 | ) |
168 | 194 | ) |
169 | 195 |
|
170 | | - ;; Fail to call the contract due to insufficient gas. |
| 196 | + ;; Fail to call the contract due to insufficient ref_time weight. |
171 | 197 | (set_local $exit_code |
172 | 198 | (call $seal_call |
| 199 | + (i32.const 0) ;; Set no flag |
173 | 200 | (i32.const 16) ;; Pointer to "callee" address. |
174 | | - (i32.const 32) ;; Length of "callee" address. |
175 | | - (i64.const 1) ;; Supply too little gas |
| 201 | + (i64.const 1) ;; Supply too little ref_time weight |
| 202 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 203 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
176 | 204 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
177 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
178 | 205 | (i32.const 8) ;; Pointer to input data buffer address |
179 | 206 | (i32.const 8) ;; Length of input data buffer |
180 | | - (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
181 | | - (i32.const 0) ;; Length is ignored in this cas |
| 207 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
| 208 | + (i32.const 0) ;; Length is ignored in this cas |
| 209 | + ) |
| 210 | + ) |
| 211 | + |
| 212 | + ;; Check for special trap exit status. |
| 213 | + (call $assert |
| 214 | + (i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::CalleeTrapped |
| 215 | + ) |
| 216 | + |
| 217 | + ;; Fail to call the contract due to insufficient proof_size weight. |
| 218 | + (set_local $exit_code |
| 219 | + (call $seal_call |
| 220 | + (i32.const 0) ;; Set no flag |
| 221 | + (i32.const 16) ;; Pointer to "callee" address. |
| 222 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 223 | + (i64.const 1) ;; Supply too little proof_size weight |
| 224 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
| 225 | + (i32.const 0) ;; Pointer to the buffer with value to transfer |
| 226 | + (i32.const 8) ;; Pointer to input data buffer address |
| 227 | + (i32.const 8) ;; Length of input data buffer |
| 228 | + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output |
| 229 | + (i32.const 0) ;; Length is ignored in this cas |
182 | 230 | ) |
183 | 231 | ) |
184 | 232 |
|
|
202 | 250 | ;; Call the contract successfully. |
203 | 251 | (set_local $exit_code |
204 | 252 | (call $seal_call |
| 253 | + (i32.const 0) ;; Set no flag |
205 | 254 | (i32.const 16) ;; Pointer to "callee" address. |
206 | | - (i32.const 32) ;; Length of "callee" address. |
207 | | - (i64.const 0) ;; How much gas to devote for the execution. 0 = all. |
| 255 | + (i64.const 0) ;; How much ref_time weight to devote for the execution. 0 = all. |
| 256 | + (i64.const 0) ;; How much proof_size weight to devote for the execution. 0 = all. |
| 257 | + (i32.const 0xffffffff) ;; u32 max sentinel value: pass no deposit limit. |
208 | 258 | (i32.const 0) ;; Pointer to the buffer with value to transfer |
209 | | - (i32.const 8) ;; Length of the buffer with value to transfer. |
210 | 259 | (i32.const 8) ;; Pointer to input data buffer address |
211 | 260 | (i32.const 8) ;; Length of input data buffer |
212 | | - (i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer |
213 | | - (i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len |
| 261 | + (i32.sub (get_local $sp) (i32.const 4)) ;; Ptr to output buffer |
| 262 | + (i32.sub (get_local $sp) (i32.const 8)) ;; Ptr to output buffer len |
214 | 263 | ) |
215 | 264 | ) |
216 | 265 |
|
|
0 commit comments