-
Notifications
You must be signed in to change notification settings - Fork 555
AA benchmark tests #577
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
+570
−2
Merged
AA benchmark tests #577
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
397bd07
add yarn aabenchmark
WhiteOakKong eab689e
lint/prettier
WhiteOakKong dba56da
Merge branch 'thirdweb-dev:main' into AA-benchmark-test
WhiteOakKong b43a546
fix foundry.toml
WhiteOakKong ac01c92
Merge branch 'main' into AA-benchmark-test
nkrishang 95b9930
Merge branch 'main' into AA-benchmark-test
nkrishang 0b89514
format
nkrishang 3365f91
remove libs incompatible with forge coverage
nkrishang 754d954
prettier ignore file w bytecode
nkrishang e7ced34
rename import
nkrishang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ node_modules/ | |
typechain/ | ||
|
||
# files | ||
src/test/smart-wallet/utils/AABenchmarkArtifacts.sol | ||
coverage.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.0; | ||
|
||
// Test utils | ||
import "../../utils/BaseTest.sol"; | ||
|
||
// Account Abstraction setup for smart wallets. | ||
import { IEntryPoint } from "contracts/prebuilts/account/utils/Entrypoint.sol"; | ||
|
||
import { AccountFactory } from "contracts/prebuilts/account/non-upgradeable/AccountFactory.sol"; | ||
import "contracts/lib/TWStrings.sol"; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
contract AABenchmarkPrepare is BaseTest { | ||
AccountFactory private accountFactory; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
accountFactory = new AccountFactory(IEntryPoint(payable(address(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789)))); | ||
} | ||
|
||
function test_prepareBenchmarkFile() public { | ||
address accountFactoryAddress = address(accountFactory); | ||
bytes memory accountFactoryBytecode = accountFactoryAddress.code; | ||
|
||
address accountImplAddress = accountFactory.accountImplementation(); | ||
bytes memory accountImplBytecode = accountImplAddress.code; | ||
|
||
string memory accountFactoryAddressString = string.concat( | ||
"address constant THIRDWEB_ACCOUNT_FACTORY_ADDRESS = ", | ||
TWStrings.toHexStringChecksummed(accountFactoryAddress), | ||
";" | ||
); | ||
string memory accountFactoryBytecodeString = string.concat( | ||
'bytes constant THIRDWEB_ACCOUNT_FACTORY_BYTECODE = hex"', | ||
TWStrings.toHexStringNoPrefix(accountFactoryBytecode), | ||
'"', | ||
";" | ||
); | ||
|
||
string memory accountImplAddressString = string.concat( | ||
"address constant THIRDWEB_ACCOUNT_IMPL_ADDRESS = ", | ||
TWStrings.toHexStringChecksummed(accountImplAddress), | ||
";" | ||
); | ||
string memory accountImplBytecodeString = string.concat( | ||
'bytes constant THIRDWEB_ACCOUNT_IMPL_BYTECODE = hex"', | ||
TWStrings.toHexStringNoPrefix(accountImplBytecode), | ||
'"', | ||
";" | ||
); | ||
|
||
string memory path = "src/test/smart-wallet/utils/AABenchmarkArtifacts.sol"; | ||
|
||
vm.removeFile(path); | ||
|
||
vm.writeLine(path, ""); | ||
vm.writeLine(path, "pragma solidity ^0.8.0;"); | ||
vm.writeLine(path, "interface ThirdwebAccountFactory {"); | ||
vm.writeLine( | ||
path, | ||
" function createAccount(address _admin, bytes calldata _data) external returns (address);" | ||
); | ||
vm.writeLine( | ||
path, | ||
" function getAddress(address _adminSigner, bytes calldata _data) external view returns (address);" | ||
); | ||
vm.writeLine(path, "}"); | ||
|
||
vm.writeLine(path, "interface ThirdwebAccount {"); | ||
vm.writeLine(path, " function execute(address _target, uint256 _value, bytes calldata _calldata) external;"); | ||
vm.writeLine(path, "}"); | ||
vm.writeLine(path, accountFactoryAddressString); | ||
vm.writeLine(path, accountImplAddressString); | ||
vm.writeLine(path, accountFactoryBytecodeString); | ||
vm.writeLine(path, accountImplBytecodeString); | ||
|
||
vm.writeLine(path, ""); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.0; | ||
|
||
import "./AATestBase.sol"; | ||
import { ThirdwebAccountFactory, ThirdwebAccount, THIRDWEB_ACCOUNT_FACTORY_ADDRESS, THIRDWEB_ACCOUNT_IMPL_ADDRESS, THIRDWEB_ACCOUNT_FACTORY_BYTECODE, THIRDWEB_ACCOUNT_IMPL_BYTECODE } from "./AABenchmarkArtifacts.sol"; | ||
|
||
contract ProfileThirdwebAccount is AAGasProfileBase { | ||
ThirdwebAccountFactory factory; | ||
|
||
function setUp() external { | ||
initializeTest("thirdwebAccount"); | ||
factory = ThirdwebAccountFactory(THIRDWEB_ACCOUNT_FACTORY_ADDRESS); | ||
vm.etch(address(factory), THIRDWEB_ACCOUNT_FACTORY_BYTECODE); | ||
vm.etch(THIRDWEB_ACCOUNT_IMPL_ADDRESS, THIRDWEB_ACCOUNT_IMPL_BYTECODE); | ||
setAccount(); | ||
} | ||
|
||
function fillData( | ||
address _to, | ||
uint256 _value, | ||
bytes memory _data | ||
) internal view override returns (bytes memory) { | ||
return abi.encodeWithSelector(ThirdwebAccount.execute.selector, _to, _value, _data); | ||
} | ||
|
||
function getSignature(UserOperation memory _op) internal view override returns (bytes memory) { | ||
return signUserOpHash(key, _op); | ||
} | ||
|
||
function createAccount(address _owner) internal override { | ||
// if (address(account).code.length == 0) { | ||
factory.createAccount(_owner, ""); | ||
// } | ||
} | ||
|
||
function getAccountAddr(address _owner) internal view override returns (IAccount) { | ||
return IAccount(factory.getAddress(_owner, "")); | ||
} | ||
|
||
function getInitCode(address _owner) internal view override returns (bytes memory) { | ||
return abi.encodePacked(address(factory), abi.encodeWithSelector(factory.createAccount.selector, _owner, "")); | ||
} | ||
|
||
function getDummySig(UserOperation memory _op) internal pure override returns (bytes memory) { | ||
return | ||
hex"fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"; | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / Slither
Assembly usage