Skip to content
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

Feat/advanced create2 testing #1922

Open
wants to merge 21 commits into
base: arith-dev
Choose a base branch
from
Open

Conversation

amkCha
Copy link
Collaborator

@amkCha amkCha commented Mar 19, 2025

This suite aims at testing advanced CREATE2 scenarii using smart contracts.
It tests 5 deployment scenarii with the same init code through a smart contract piloting the deployment.
SmartContractTestValidator is a generic TransactionProcessingValidator to validate log presence and data produced by the tests.


Test coverage :

  • 0.1% condition coverage on Unit tests

  • Smart Contracts overview
  1. CustomCreate2

CustomCreate2 is the smart contract used to pilot the deployment of a complex initCodeC
CustomCreate2 stores an initCodeC and a salt used for subsequent deployments
CustomCreate2 has different create2 methods to have deployment scenarii within the same transaction
CustomCreate2 can CALL/STATICCALL itself and contractC

  1. initCodeC - init code of ContractC

initCodeC can be piloted by CustomCreate2 via the value passed in the transaction
value 1 Wei enables a storage modification in ContractC
value 2 Wei calls CustomCreate2 back to trigger an immediate redeployment of ContractC
value 3 Wei triggers a self-destruct of ContractC
value 4 Wei triggers a revert on demand

  1. ContractC

ContractC can modify storage, revert on demand, self-destruct on demand, and call back
CustomCreate2 to trigger a redeployment of ContractC


  • Description of the 5 scenarii tested

SCENARIO 1 - Deploy ContractC through CustomCreate2, modify storage, self-destruct ContractC
SCENARIO 2 - Deploy ContractC and attempt redeployment after in same transaction
SCENARIO 3 - Deploy ContractC and the deployment attempts redeployment, empty bytecode is deployed, call ContractC to modify storage, revert on demand
SCENARIO 4 - Attempt ContractC deployment with a staticCall
SCENARIO 5 - Four ContractC deployment attempts : (1) with max value, (2) acceptable value, (3) max value and (4) acceptable value

@amkCha amkCha force-pushed the feat/advanced-create2-testing branch from ebd26fc to 3d8d8de Compare March 19, 2025 11:17
@amkCha amkCha marked this pull request as ready for review March 19, 2025 16:58
@@ -34,7 +34,7 @@ public static class ToyMultiTransactionBuilder {
* @return an instance of {@link List<Transaction>}
*/
public List<Transaction> build(
ToyTransactionBuilder[] toyTxBuilders, ToyAccount senderAccount) {
List<ToyTransactionBuilder> toyTxBuilders, ToyAccount senderAccount) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the type from array to list for the builder parameters when creating multiple transactions for the same account, for it to be easier to add builders during testing

transactionBuilderLeadingDelegateCallerToCreateAnAccount,
transactionBuilderLeadingDelegateCallerToSelfDestruct,
transactionBuilderDeployingDelegateCallerAgain,
transactionBuilderLeadingDelegateCallerToAttemptCreateAgainThusRaisingFailureConditionF);
Copy link
Collaborator Author

@amkCha amkCha Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment for changing the method's signature in ToyMultiTransaction

@@ -61,7 +61,7 @@ void testBlockwiseDeplNo() {
// Block 1
.addBlock(
List.of(
tc.deployWithCreate2(
tc.deployWithCreate2_withRevertTrigger(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep TestingBase as it was for deployWithCreate2 and create new function to have it revertable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant