Adds initial versions of our account abstraction contracts#243
Adds initial versions of our account abstraction contracts#243smartcontracts wants to merge 10 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Nice! This LGTM! The thing that really needs to be changed / updated / tested more about this is the actual transaction encoding & decoding that will be used by the sequencer.
For instance, we really need to add tests which generate the calldata in exactly the way that the sequencer will generate calldata (using the same function even), and then make sure that the signatures are recovered correctly. That's currently missing but definitely is something we need to add.
Instead of adding it to this PR; however, I am down to create a new ticket for finalizing the sequencer tx data format and knock out that ticket during the contracts refactor. That said, open to suggestions if we want to knock that out now.
Ah and another ticket we need to add (or implement in this PR) is making the sequencer decompressor & EOA contracts upgradable. This is going to be required for upgrading the fee mechanism post launch
Either way, I'm approving and we can chat about the best way to proceed wrt making tickets for or implementing:
- calldata decoding/encoding (finalizing the format that the sequencer will use)
- Adding fee collection to the (ECDSA) EOA Contract
- Making the EOA Contracts upgradable.
packages/contracts/contracts/optimistic-ethereum/accounts/ECDSAContractAccount.sol
Outdated
Show resolved
Hide resolved
| /** | ||
| * @title ECDSAContractAccount | ||
| */ | ||
| contract ECDSAContractAccount { |
There was a problem hiding this comment.
Right now this EOA contract is not upgradable but it definitely should be & also shouldn't be hard to make it. This contract won't have to change too much but we just need to make a more generalized: EOAContract which starts out with it's implementationAddress pointing at this contract, as well as a simple function
So it's important that we allow upgradability
should add a very simple function to this in order to enable upgradability --
function upgrade(address newImplementationAddress) {
ExecutionManger em = ExecutionManager(msg.sender);
require(em.ovmCALLER() == em.ovmADDRESS());
implementationAddress = newImplementationAddress;
}
This can be the final form of the EOAContract
There was a problem hiding this comment.
So the parent / upgradable contract would look something like:
contract EOA {
address implementationAddress;
function() public {
ExecutionManger em = ExecutionManager(msg.sender)
address target;
bytes memory returndata;
if (implementationAddress == address(0)) {
(target, returndata) = em.ovmCALL(ECDSAContractAccount_ADDRESS, calldata) // call the ECDSAContractAccount
} else {
(target, returndata) = em.ovmCALL(implementationAddress, calldata) // call the alt implementation
}
em.ovmCALL(target, returndata)
}
function upgrade() {
ExecutionManger em = ExecutionManager(msg.sender);
require(em.ovmCALLER() == em.ovmADDRESS());
implementationAddress = newImplementationAddress;
}
}
There was a problem hiding this comment.
Good point! I'll add this.
| _s | ||
| ) == OVMUtils.ovmADDRESS(address(executionManager)), | ||
| "Provided signature is invalid." | ||
| ); |
There was a problem hiding this comment.
Ugh one horrible note is that if we transpile revert (which we have to) we will need to transpile this contract so that we don't actually REVERT when this require fails. 😭
I guess this is an argument for not adding upgradability until we have the final version of the contracts because we'll have to change a bunch of stuff when we rewrite these contracts anyway
| bytes32 _messageHash | ||
| ) | ||
| { | ||
| return keccak256(_message); |
There was a problem hiding this comment.
So this native "recover" logic should probably be replaced with -- https://github.com/ethereum-optimism/optimism-monorepo/pull/243/files#diff-4a7bd8c005926e358a62f04b6d552157L187 recoverEOAAddress(...) or equivalent. Unfortunately the actual signature recovery logic for normal Ethereum transactions is a bit complex (you have to RLP encode 2 zero values) and so we need to update this to work end-to-end.
I'm down to put off finalizing the tx decoding and the specific sequencer calldata format util later but if we do we should definitely create tickets for it.
There was a problem hiding this comment.
Oh, alternatively our SequencerMessageDecompressor actually constructs the exact RLP encoded calldata and then passes that directly into the ECDSAAccountContract.
No matter what, this decoding logic will definitely need to be updated.
| /** | ||
| * @title OVMUtils | ||
| */ | ||
| library OVMUtils { |
There was a problem hiding this comment.
This confused me so much but then I remembered we don't ABI encode our parameters ughhhh
There was a problem hiding this comment.
Agh yeah. I'm gonna rename this to be more clear that it's a wrapper around the ExecutionManager.
| ); | ||
| } | ||
|
|
||
| return _ret; |
There was a problem hiding this comment.
Ah I just realized that this does not include fee logic! We'll need to add an ERC20 contract precompile which is at a fixed address & which we use for collecting fees inside of the EOA account.
Again, either we add it here / include in this PR or we'll need to make another ticket for it
| raw[3] = RLPWriter.encodeAddress(_transaction.to); | ||
| raw[4] = RLPWriter.encodeUint(0); | ||
| raw[5] = RLPWriter.encodeBytes(_transaction.data); | ||
| raw[6] = RLPWriter.encodeUint(108); |
There was a problem hiding this comment.
Instead of hardcoding 108, shouldn't this use something like:
uint256 id;
assembly {
id := chainid()
}
raw[6] = RLPWriter.encodeUint(id);
packages/contracts/contracts/optimistic-ethereum/utils/libraries/TransactionParser.sol
Show resolved
Hide resolved
|
|
||
| let serializedTransaction: string | ||
| if (transactionType === 2) { | ||
| serializedTransaction = ethers.utils.defaultAbiCoder.encode( |
There was a problem hiding this comment.
I like the usage of defaultAbiCoder.encode more than my above implementation of serializeEthSignTransaction, we should create a function in ovm-utils
|
|
||
| enum TransactionType { | ||
| EOA_CONTRACT_CREATION, | ||
| NATIVE_ETH_TRANSACTION, |
There was a problem hiding this comment.
What do you think about calling this EIP155 instead of NATIVE_ETH_TRANSACTION? I think its more descriptive of its type
|
closed in favor of ethereum-optimism/contracts#33 |
* Add CHANGELOG * Add update changelog Makefile target
* fix: I-0 * fix: I-1 * fix: I-2 * fix: I-3 * fix: I-6 * fix: I-7 * fix: I-9 * fix: pre pr
* feat: add shared lockbox (#126) * feat: create shared lockbox contract with its interface and unit tests * chore: polish tests and interfaces * chore: run pre-pr * chore: improve natspec * chore: run pre-pr * chore: update compiler version * feat: integrate portal to lockbox (#139) * feat: integrate portal to lockbox * fix: pr fixes * test: refactor assert * feat: add liquidity migrator contract with its unit test and interface (#128) * feat: create shared lockbox contract with its interface and unit tests * chore: polish tests and interfaces * chore: run pre-pr * chore: improve natspec * chore: run pre-pr * feat: add liqudity migrator contract with its unit test and interface * chore: remove underscore on stack var * chore: add todo * chore: run pre-pr * chore: add contract title natspec and proxied * refactor: integrate testing suite with common test * chore: pre-pr * chore: add spec test * feat: integrate system config with superchain config (#140) * feat: integrate portal to lockbox * fix: pr fixes * test: refactor assert * feat: integrate system config with superchain config * fix: remove OPCM interop * test: add dependency counter test * feat: manage dependency set on superchain config (#138) * chore: add zero dependencies check (#142) * fix: pre pr * feat: Add pause check (#145) * feat: Add pause check Co-authored-by: 0xParticle <particle@defi.sucks> Co-authored-by: gotzenx <78360669+gotzenx@users.noreply.github.com> Co-authored-by: Joxess <joxes@defi.sucks> * test: add tests natspecs --------- Co-authored-by: 0xParticle <particle@defi.sucks> Co-authored-by: gotzenx <78360669+gotzenx@users.noreply.github.com> Co-authored-by: Joxess <joxes@defi.sucks> * fix: pre pr and interfaces imports * feat: add upgrader role to superchain config (#163) * feat: use superchain config lockbox in portal (#164) * feat: use superchain config lockbox in portal * test: add new sharedlockbox test * fix: pre pr * feat: liquidity migrator deployment (#166) * feat: liquidity migrator deployment * test: fix comment * test: fix internal variables names * feat: dependency set refactor (#170) * feat: dependency set refactor * fix: deploy script variable name * fix: pr * fix: pr * fix: pre pr * fix: semgrep * fix: merge conflict * [WIP] feat: new lockbox (#192) * chore: partial implementation comments * feat: new lockbox * feat: introduce dependency manager predeploy * feat: remove timestamp check from CrossL2Inbox * feat: introduce cluster manager role and remove immutables * fix: remove unnecessary code, fix tests and setup * feat: use unstructured storage and OZ v5 * fix: L2ToL2CDM dependency set check * fix: dependency manager gas limit * feat: refactor interop feature contracts (#200) * feat: refactor interop feature contracts * fix: add noops comment * feat: adds OptimismPortal migrated flag * test: add missing tests * fix: portal interop storage naming --------- Co-authored-by: Skeletor Spaceman <skeletorspaceman@gmail.com> * fix: pre pr, setup and tests * fix: remove system config interop and add interop portal target check (#205) * fix: remove system config interop and add interop portal check * fix: interop portal target check order * fix: remove wrong comment * fix: refactor portal noops function (#206) * test: add dependency manager and portal interop tests (#209) * feat: initialize shared lockbox in interop portal (#211) * feat: initialize shared lockbox in interop portal * fix: refactor shared lockbox storage getter * fix: lockbox pr fixes (#214) * fix: pre pr * fix: semver lock * fix: semver lock * feat: descope dependency manager (#242) * feat: descope dependency manager * test: fix tests * test: fix tests * chore: improve eth liquidity test (#248) * fix: internal review fixes (#243) * fix: I-0 * fix: I-1 * fix: I-2 * fix: I-3 * fix: I-6 * fix: I-7 * fix: I-9 * fix: pre pr * fix: pre pr * fix: portal withdrawal checks (#255) * fix: portal withdrawal checks * fix: include current withdrawal check * fix: remove unused interop contracts (#256) * test: fix flake tests (#257) * fix: adjust op-deployer interop scripts (#262) * fix: pre pr * fix op-deployer tests * remove dependency code * fix lint * use Bob account --------- Co-authored-by: Disco <131301107+0xDiscotech@users.noreply.github.com> Co-authored-by: AgusDuha <81362284+agusduha@users.noreply.github.com> Co-authored-by: agusduha <agusnduha@gmail.com> Co-authored-by: 0xParticle <particle@defi.sucks> Co-authored-by: gotzenx <78360669+gotzenx@users.noreply.github.com> Co-authored-by: Joxess <joxes@defi.sucks> Co-authored-by: Skeletor Spaceman <skeletorspaceman@gmail.com>
* feat: small fixes and kona deriver * fixes * fixes * start derivation fixes * first valid payload * cleanup * fixes * fix: lints * updates * fix: lints * fix: bin cleanup * fix: lints * fix: ignore tests for now * fix: blob decoding * fix: tests and logs * fix: validation * fix: update deps * feat: superchain registry types * fix: make sync less verbose by default * fix: print l2 attributes timestamp * fix: pipeline interface and cursor updates * fixes * cleanup * fix: broken tests from scr * fix: ecotone batches working * attempt cov fix * fix: move kona-sync to example * fix: move validation to trusted-sync example * fix(examples): validation hardcoded canyon timestamp * fix: exclude examples in cannon and asterisc builds * fix(primitives): make types impl hash * chore: clean kona-derive examples * fix(kona-derive): remove async bound on online pipeline constructor * fix: batch encoding/decoding tests * fix: batch reader test * fix(derive): last batch queue test * chore: remove execution validation log match * fix: nit * nit fix --------- Co-authored-by: clabby <ben@clab.by>
Resolves #243 --------- Co-authored-by: Einar Rasmussen <einar@oplabs.co> Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
Description
Helloooo, as always. This PR adds various contracts that enable basic account abstraction for EOAs. Here's the overview for the newly added contracts:
ECDSAContractAccountECDSAContractAccountis a super simple contract that verifies transaction signatures and runsovmCALLorovmCREATE. It has a single entrypoint:SequencerMessageDecompressorSequencerMessageDecompressoris middleware that allows the sequencer to run custom decompression steps to reduce calldata size. Currently, it also allows the sequencer to generateECDSAContractAccountcontracts on behalf of a user via the newovmCREATEEOAopcode without requiring the user to sign two different transactions.ExecutionManager(changes)ExecutionManagernow has three new functions,ovmCREATEEOA,ovmSETNONCE, andovmGETNONCE, which make it possible to dynamically generateECDSAContractAccountcontracts on behalf of users.Metadata
Fixes
Contributing Agreement
-[x] I have read and understood the Optimism Contributing Guide and Code of Conduct and am following those guidelines in this pull request.