Skip to content

adietrichs/aa-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AA Bytecode Insertion Tool

Prototype of a python3 tool for modifying EVM bytecode (as outputted by solc, including the constructor code) to include the account abstraction (AA) bytecode prefix. Note: This tool is only meant to be used for AA prototyping. Going forward, it is supposed to be replaced by a proper solidity integration.

Usage

usage: process.py [-h] [-e ENTRYPOINT] bytecode

positional arguments:
  bytecode              Contract bytecode

optional arguments:
  -h, --help            show this help message and exit
  -e ENTRYPOINT, --entrypoint ENTRYPOINT
                        Entry point address. Defaults to 0xffffffffffffffffffffffffffffffffffffffff

Using the AA contract from example.sol:

$ python process.py `solc --bin example.sol | tail -1`
0x6080604052600160005534801561001557600080fd5b50610189806100256000396000f3fe3373ffffffffffffffffffffffffffffffffffffffff1460245736601f57005b600080fd5b6080604052348015600f906100dd5750600080fd5b50600436106032906100dd575060003560e01c8063e5aa3d58146037906100dd57508063e5c19b2d146053906100dd57505b600080fd5b603d607e6100dd565b6040518082815260200191505060405180910390f35b607c600480360360208110156067906100dd5750600080fd5b810190808035906020019092919050505060846100dd565b005b600054816100dd565b80600081905550506100dd56fe5b9050565b6100398161000f146100d9575061006b81610032146100d9575061007081610037146100d957506100798161003d146100d9575061008f81610053146100d957506100a881610067146100d957506100c08161007c146100d957506100c28161007e146100d957506100cb81610084146100d95750fea2646970667358221220cc817a8419acce4ce2e50a6fcc8d94cd4f8cc267975e675fdc7ae925cde6221864736f6c63430006060033

For testing purposes the AA entry point can be changed to a specified Ethereum address via the entrypoint argument, e.g.:

$ python process.py `solc --bin example.sol | tail -1` -e 0x04D867459000b8371B7D88c2De900F6a4C074a00

After deploying the modified bytecode, the contract can be used as before via the entry point address. Calls from any other address (including read access) will fail.

For analysis of the bytecode this decompilation tool can be useful. Bytecodes for the example.sol:

Original bytecode with constructor:
6080604052600160005534801561001557600080fd5b5060c4806100246000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063e5aa3d58146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506084565b005b60005481565b806000819055505056fea26469706673582212201439e38108e1ca88e305c64349ff7a261f21cc4385eec971ce78d492bf80848c64736f6c63430006060033

Original bytecode without constructor:
6080604052348015600f57600080fd5b506004361060325760003560e01c8063e5aa3d58146037578063e5c19b2d146053575b600080fd5b603d607e565b6040518082815260200191505060405180910390f35b607c60048036036020811015606757600080fd5b81019080803590602001909291905050506084565b005b60005481565b806000819055505056fea26469706673582212201439e38108e1ca88e305c64349ff7a261f21cc4385eec971ce78d492bf80848c64736f6c63430006060033

Modified bytecode with constructor:
6080604052600160005534801561001557600080fd5b50610189806100256000396000f3fe337304d867459000b8371b7d88c2de900f6a4c074a001460245736601f57005b600080fd5b6080604052348015600f906100dd5750600080fd5b50600436106032906100dd575060003560e01c8063e5aa3d58146037906100dd57508063e5c19b2d146053906100dd57505b600080fd5b603d607e6100dd565b6040518082815260200191505060405180910390f35b607c600480360360208110156067906100dd5750600080fd5b810190808035906020019092919050505060846100dd565b005b600054816100dd565b80600081905550506100dd56fe5b9050565b6100398161000f146100d9575061006b81610032146100d9575061007081610037146100d957506100798161003d146100d9575061008f81610053146100d957506100a881610067146100d957506100c08161007c146100d957506100c28161007e146100d957506100cb81610084146100d95750fea2646970667358221220cc817a8419acce4ce2e50a6fcc8d94cd4f8cc267975e675fdc7ae925cde6221864736f6c63430006060033

Modified bytecode without constructor:
337304d867459000b8371b7d88c2de900f6a4c074a001460245736601f57005b600080fd5b6080604052348015600f906100dd5750600080fd5b50600436106032906100dd575060003560e01c8063e5aa3d58146037906100dd57508063e5c19b2d146053906100dd57505b600080fd5b603d607e6100dd565b6040518082815260200191505060405180910390f35b607c600480360360208110156067906100dd5750600080fd5b810190808035906020019092919050505060846100dd565b005b600054816100dd565b80600081905550506100dd56fe5b9050565b6100398161000f146100d9575061006b81610032146100d9575061007081610037146100d957506100798161003d146100d9575061008f81610053146100d957506100a881610067146100d957506100c08161007c146100d957506100c28161007e146100d957506100cb81610084146100d95750fea2646970667358221220cc817a8419acce4ce2e50a6fcc8d94cd4f8cc267975e675fdc7ae925cde6221864736f6c63430006060033

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages