|
14 | 14 | */ |
15 | 15 | package net.consensys.linea.zktracer.instructionprocessing.createTests.failure; |
16 | 16 |
|
| 17 | +import static net.consensys.linea.testing.ToyTransaction.ToyTransactionBuilder; |
17 | 18 | import static net.consensys.linea.zktracer.instructionprocessing.createTests.trivial.RootLevel.salt01; |
18 | 19 | import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.keyPair; |
19 | 20 | import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.userAccount; |
|
27 | 28 | import net.consensys.linea.testing.BytecodeCompiler; |
28 | 29 | import net.consensys.linea.testing.ToyAccount; |
29 | 30 | import net.consensys.linea.testing.ToyExecutionEnvironmentV2; |
| 31 | +import net.consensys.linea.testing.ToyMultiTransaction; |
30 | 32 | import net.consensys.linea.testing.ToyTransaction; |
31 | 33 | import org.apache.tuweni.bytes.Bytes; |
32 | 34 | import org.hyperledger.besu.datatypes.Address; |
|
41 | 43 | * |
42 | 44 | * <p>- we start with an account {@link #entryPoint}; |
43 | 45 | * |
44 | | - * <p>- in {@link #transactionDeployingDelegateCaller} we call {@link #entryPoint} with empty call |
45 | | - * data which leads to the deployment of {@link #delegateCaller}; |
| 46 | + * <p>- in {@link #transactionBuilderDeployingDelegateCaller} we call {@link #entryPoint} with empty |
| 47 | + * call data which leads to the deployment of {@link #delegateCaller}; |
46 | 48 | * |
47 | | - * <p>- in {@link #transactionLeadingDelegateCallerToCreateAnAccount} we call {@link #entryPoint} |
48 | | - * with nonempty call data which leads it calling {@link #delegateCaller} which leads to it doing a |
49 | | - * <b>DELEGATECALL</b> to {@link #simpleCreator} thus deploying a new account with {@link |
50 | | - * #delegateCaller}'s nonce =1; |
| 49 | + * <p>- in {@link #transactionBuilderLeadingDelegateCallerToCreateAnAccount} we call {@link |
| 50 | + * #entryPoint} with nonempty call data which leads it calling {@link #delegateCaller} which leads |
| 51 | + * to it doing a <b>DELEGATECALL</b> to {@link #simpleCreator} thus deploying a new account with |
| 52 | + * {@link #delegateCaller}'s nonce =1; |
51 | 53 | * |
52 | | - * <p>- in {@link #transactionLeadingDelegateCallerToSelfDestruct} we call {@link #entryPoint} with |
53 | | - * nonempty call data which leads it calling {@link #delegateCaller} which leads to it doing a |
54 | | - * <b>DELEGATECALL</b> to {@link #simpleSelfDestructor} self destructing; |
| 54 | + * <p>- in {@link #transactionBuilderLeadingDelegateCallerToSelfDestruct} we call {@link |
| 55 | + * #entryPoint} with nonempty call data which leads it calling {@link #delegateCaller} which leads |
| 56 | + * to it doing a <b>DELEGATECALL</b> to {@link #simpleSelfDestructor} self destructing; |
55 | 57 | * |
56 | | - * <p>- in {@link #transactionDeployingDelegateCallerAgain} we call {@link #entryPoint} with empty |
57 | | - * call data again which leads to the deployment of {@link #delegateCaller} <i>again</i>; |
| 58 | + * <p>- in {@link #transactionBuilderDeployingDelegateCallerAgain} we call {@link #entryPoint} with |
| 59 | + * empty call data again which leads to the deployment of {@link #delegateCaller} <i>again</i>; |
58 | 60 | * |
59 | | - * <p>- in {@link #transactionLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF} |
60 | | - * we call {@link #entryPoint} with nonempty call data which leads it calling {@link |
61 | | - * #delegateCaller} which leads to it doing a <b>DELEGATECALL</b> to {@link #simpleCreator} thus |
62 | | - * <i>attempting</i> to redeploy at the same address where it did the first deployment; indeed |
63 | | - * {@link #delegateCaller}'s nonce is again =1; deploying a new account at nonce 1; |
| 61 | + * <p>- in {@link |
| 62 | + * #transactionBuilderLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF} we call |
| 63 | + * {@link #entryPoint} with nonempty call data which leads it calling {@link #delegateCaller} which |
| 64 | + * leads to it doing a <b>DELEGATECALL</b> to {@link #simpleCreator} thus <i>attempting</i> to |
| 65 | + * redeploy at the same address where it did the first deployment; indeed {@link #delegateCaller}'s |
| 66 | + * nonce is again =1; deploying a new account at nonce 1; |
64 | 67 | */ |
65 | 68 | @ExtendWith(UnitTestWatcher.class) |
66 | 69 | public class CreateInducedFailureTest { |
@@ -201,67 +204,60 @@ public class CreateInducedFailureTest { |
201 | 204 | .address(targetAddress) |
202 | 205 | .build(); |
203 | 206 |
|
204 | | - final Transaction transactionDeployingDelegateCaller = |
| 207 | + final ToyTransactionBuilder transactionBuilderDeployingDelegateCaller = |
205 | 208 | ToyTransaction.builder() |
206 | | - .sender(userAccount) |
207 | 209 | .to(entryPoint) |
208 | 210 | .keyPair(keyPair) |
209 | 211 | .value(Wei.of(0xffff)) |
210 | 212 | .gasLimit(1_000_000L) |
211 | | - .gasPrice(Wei.of(8)) |
212 | | - .build(); |
| 213 | + .gasPrice(Wei.of(8)); |
213 | 214 |
|
214 | | - final Transaction transactionLeadingDelegateCallerToCreateAnAccount = |
| 215 | + final ToyTransactionBuilder transactionBuilderLeadingDelegateCallerToCreateAnAccount = |
215 | 216 | ToyTransaction.builder() |
216 | | - .sender(userAccount.raiseNonceBy(1)) |
217 | 217 | .to(entryPoint) |
218 | 218 | .keyPair(keyPair) |
219 | 219 | .value(Wei.of(0xeeee)) |
220 | 220 | .gasLimit(1_000_000L) |
221 | 221 | .gasPrice(Wei.of(8)) |
222 | | - .payload(leftPaddedAddress1) |
223 | | - .build(); |
| 222 | + .payload(leftPaddedAddress1); |
224 | 223 |
|
225 | | - final Transaction transactionLeadingDelegateCallerToSelfDestruct = |
| 224 | + final ToyTransactionBuilder transactionBuilderLeadingDelegateCallerToSelfDestruct = |
226 | 225 | ToyTransaction.builder() |
227 | | - .sender(userAccount.raiseNonceBy(2)) |
228 | 226 | .to(entryPoint) |
229 | 227 | .keyPair(keyPair) |
230 | 228 | .value(Wei.of(0xdddd)) |
231 | 229 | .gasLimit(1_000_000L) |
232 | 230 | .gasPrice(Wei.of(8)) |
233 | | - .payload(leftPaddedAddress2) |
234 | | - .build(); |
| 231 | + .payload(leftPaddedAddress2); |
235 | 232 |
|
236 | | - final Transaction transactionDeployingDelegateCallerAgain = |
| 233 | + final ToyTransactionBuilder transactionBuilderDeployingDelegateCallerAgain = |
237 | 234 | ToyTransaction.builder() |
238 | | - .sender(userAccount.raiseNonceBy(3)) |
239 | 235 | .to(entryPoint) |
240 | 236 | .keyPair(keyPair) |
241 | 237 | .value(Wei.of(0xcccc)) |
242 | 238 | .gasLimit(1_000_000L) |
243 | | - .gasPrice(Wei.of(8)) |
244 | | - .build(); |
| 239 | + .gasPrice(Wei.of(8)); |
245 | 240 |
|
246 | | - final Transaction |
247 | | - transactionLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF = |
| 241 | + final ToyTransactionBuilder |
| 242 | + transactionBuilderLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF = |
248 | 243 | ToyTransaction.builder() |
249 | | - .sender(userAccount.raiseNonceBy(4)) |
250 | 244 | .to(entryPoint) |
251 | 245 | .keyPair(keyPair) |
252 | 246 | .value(Wei.of(0xbbbb)) |
253 | 247 | .gasLimit(1_000_000L) |
254 | 248 | .gasPrice(Wei.of(8)) |
255 | | - .payload(leftPaddedAddress1) |
256 | | - .build(); |
| 249 | + .payload(leftPaddedAddress1); |
| 250 | + |
| 251 | + final ToyTransactionBuilder[] toyTransactionBuilders = { |
| 252 | + transactionBuilderDeployingDelegateCaller, |
| 253 | + transactionBuilderLeadingDelegateCallerToCreateAnAccount, |
| 254 | + transactionBuilderLeadingDelegateCallerToSelfDestruct, |
| 255 | + transactionBuilderDeployingDelegateCallerAgain, |
| 256 | + transactionBuilderLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF |
| 257 | + }; |
257 | 258 |
|
258 | 259 | final List<Transaction> transactions = |
259 | | - List.of( |
260 | | - transactionDeployingDelegateCaller, |
261 | | - transactionLeadingDelegateCallerToCreateAnAccount, |
262 | | - transactionLeadingDelegateCallerToSelfDestruct, |
263 | | - transactionDeployingDelegateCallerAgain, |
264 | | - transactionLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF); |
| 260 | + ToyMultiTransaction.builder().build(toyTransactionBuilders, userAccount); |
265 | 261 |
|
266 | 262 | final List<ToyAccount> accounts = |
267 | 263 | List.of(userAccount, entryPoint, simpleSelfDestructor, simpleCreator); |
|
0 commit comments