-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Fallback AccountERC7579.isValidSignature to native signer
#6443
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
base: master
Are you sure you want to change the base?
Changes from all commits
dbadcb4
6a1bed1
a2186a0
982ced2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'openzeppelin-solidity': patch | ||
| --- | ||
|
|
||
| `AccountERC7579`: Fallback to native validation if module validation fails | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,7 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75 | |
| } catch {} | ||
| } | ||
| } | ||
| return bytes4(0xffffffff); | ||
| return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would love to check with @ernestognw if that was not by design. Basically, if we do that we don't have 7739's security, and that could be unsafe. Lets discuss that. |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,52 +9,58 @@ const { shouldBehaveLikeAccountCore } = require('../Account.behavior'); | |
| const { shouldBehaveLikeAccountERC7579 } = require('./AccountERC7579.behavior'); | ||
| const { shouldBehaveLikeERC1271 } = require('../../utils/cryptography/ERC1271.behavior'); | ||
|
|
||
| async function fixture() { | ||
| const fixtureWithValidator = () => fixture(true); // parameters not supported by `loadFixture` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is problematique. lamdba function like that are not properly supported by |
||
| const fixtureWithoutValidator = () => fixture(false); | ||
|
|
||
| async function fixture(withValidator) { | ||
| // EOAs and environment | ||
| const [other] = await ethers.getSigners(); | ||
| const target = await ethers.deployContract('CallReceiverMock'); | ||
| const anotherTarget = await ethers.deployContract('CallReceiverMock'); | ||
|
|
||
| // ERC-7579 validator | ||
| const validator = await ethers.deployContract('$ERC7579ValidatorMock'); | ||
| const validator = withValidator ? await ethers.deployContract('$ERC7579ValidatorMock') : null; | ||
|
|
||
| // ERC-4337 signer | ||
| const signer = ethers.Wallet.createRandom(); | ||
|
|
||
| // ERC-4337 account | ||
| const helper = new ERC4337Helper(); | ||
| const mock = await helper.newAccount('$AccountERC7579Mock', [ | ||
| validator, | ||
| ethers.solidityPacked(['address'], [signer.address]), | ||
| ]); | ||
| const mock = await helper.newAccount( | ||
| validator ? '$AccountERC7579Mock' : '$AccountERC7579NativeValidationMock', | ||
| validator ? [validator, ethers.solidityPacked(['address'], [signer.address])] : [signer.address], | ||
| ); | ||
|
|
||
| // ERC-4337 Entrypoint domain | ||
| const entrypointDomain = await getDomain(predeploy.entrypoint.v09); | ||
|
|
||
| return { helper, validator, mock, entrypointDomain, signer, target, anotherTarget, other }; | ||
| } | ||
|
|
||
| describe('AccountERC7579', function () { | ||
| beforeEach(async function () { | ||
| Object.assign(this, await loadFixture(fixture)); | ||
|
|
||
| this.signer.signMessage = message => | ||
| ethers.Wallet.prototype.signMessage | ||
| .bind(this.signer)(message) | ||
| .then(sign => ethers.concat([this.validator.target, sign])); | ||
| this.signer.signTypedData = (domain, types, values) => | ||
| ethers.Wallet.prototype.signTypedData | ||
| .bind(this.signer)(domain, types, values) | ||
| .then(sign => ethers.concat([this.validator.target, sign])); | ||
| this.signUserOp = userOp => | ||
| ethers.Wallet.prototype.signTypedData | ||
| .bind(this.signer)(this.entrypointDomain, { PackedUserOperation }, userOp.packed) | ||
| .then(signature => Object.assign(userOp, { signature })); | ||
|
|
||
| this.userOp = { nonce: ethers.zeroPadBytes(ethers.hexlify(this.validator.target), 32) }; | ||
| }); | ||
|
|
||
| shouldBehaveLikeAccountCore(); | ||
| shouldBehaveLikeAccountERC7579(); | ||
| shouldBehaveLikeERC1271(); | ||
| }); | ||
| [true, false].forEach(withValidator => | ||
| describe(`AccountERC7579 ${withValidator ? '' : 'native signer validation fallback'}`, function () { | ||
| beforeEach(async function () { | ||
| Object.assign(this, await loadFixture(withValidator ? fixtureWithValidator : fixtureWithoutValidator)); | ||
| this.signer.signMessage = message => | ||
| ethers.Wallet.prototype.signMessage | ||
| .bind(this.signer)(message) | ||
| .then(sign => (withValidator ? ethers.concat([this.validator.target, sign]) : sign)); | ||
| this.signer.signTypedData = (domain, types, values) => | ||
| ethers.Wallet.prototype.signTypedData | ||
| .bind(this.signer)(domain, types, values) | ||
| .then(sign => (withValidator ? ethers.concat([this.validator.target, sign]) : sign)); | ||
| this.signUserOp = userOp => | ||
| ethers.Wallet.prototype.signTypedData | ||
| .bind(this.signer)(this.entrypointDomain, { PackedUserOperation }, userOp.packed) | ||
| .then(signature => Object.assign(userOp, { signature })); | ||
|
|
||
| this.userOp = withValidator ? { nonce: ethers.zeroPadBytes(ethers.hexlify(this.validator.target), 32) } : {}; | ||
| }); | ||
|
|
||
| if (withValidator) { | ||
| shouldBehaveLikeAccountCore(); | ||
| shouldBehaveLikeAccountERC7579(); | ||
| } | ||
| shouldBehaveLikeERC1271(); | ||
| }), | ||
| ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Narrow the changeset wording to the implemented cases.
This only falls back when no installed validator handles the signature or the validator call reverts; an installed validator returning
0xffffffffstill short-circuits as invalid. The current note reads broader than the implementation.✏️ Suggested wording
📝 Committable suggestion
🤖 Prompt for AI Agents