Skip to content

Commit 518fd94

Browse files
authored
Fix account abstraction upgradeable testing (#5248)
1 parent 95e19c5 commit 518fd94

11 files changed

Lines changed: 44 additions & 14 deletions

File tree

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ jobs:
130130
with:
131131
check_hidden: true
132132
check_filenames: true
133-
skip: package-lock.json,*.pdf
133+
skip: package-lock.json,*.pdf,vendor

contracts/abstraction/utils/ERC4337Utils.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ library ERC4337Utils {
6262
if (validationData == 0) {
6363
return (address(0), false);
6464
} else {
65-
(address agregator, uint48 validAfter, uint48 validUntil) = parseValidationData(validationData);
66-
return (agregator, block.timestamp > validUntil || block.timestamp < validAfter);
65+
(address aggregator_, uint48 validAfter, uint48 validUntil) = parseValidationData(validationData);
66+
return (aggregator_, block.timestamp > validUntil || block.timestamp < validAfter);
6767
}
6868
}
6969

contracts/abstraction/utils/ERC7579Utils.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ type ExecType is bytes1;
1111
type ModeSelector is bytes4;
1212
type ModePayload is bytes22;
1313

14+
// slither-disable-next-line unused-state
1415
library ERC7579Utils {
1516
using Packing for *;
1617

17-
CallType constant CALLTYPE_SINGLE = CallType.wrap(0x00);
18-
CallType constant CALLTYPE_BATCH = CallType.wrap(0x01);
19-
CallType constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);
20-
ExecType constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);
21-
ExecType constant EXECTYPE_TRY = ExecType.wrap(0x01);
18+
CallType internal constant CALLTYPE_SINGLE = CallType.wrap(0x00);
19+
CallType internal constant CALLTYPE_BATCH = CallType.wrap(0x01);
20+
CallType internal constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);
21+
ExecType internal constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);
22+
ExecType internal constant EXECTYPE_TRY = ExecType.wrap(0x01);
2223

2324
function encodeMode(
2425
CallType callType,

contracts/mocks/Stateless.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {ERC165} from "../utils/introspection/ERC165.sol";
2222
import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol";
2323
import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol";
2424
import {ERC721Holder} from "../token/ERC721/utils/ERC721Holder.sol";
25+
import {ERC4337Utils} from "../abstraction/utils/ERC4337Utils.sol";
26+
import {ERC7579Utils} from "../abstraction/utils/ERC7579Utils.sol";
2527
import {Heap} from "../utils/structs/Heap.sol";
2628
import {Math} from "../utils/math/Math.sol";
2729
import {MerkleProof} from "../utils/cryptography/MerkleProof.sol";

contracts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"files": [
66
"**/*.sol",
77
"/build/contracts/*.json",
8-
"!/mocks/**/*"
8+
"!/mocks/**/*",
9+
"!/vendor/erc4337-entrypoint/**/*"
910
],
1011
"scripts": {
1112
"prepack": "bash ../scripts/prepack.sh",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"private": true,
66
"files": [
77
"/contracts/**/*.sol",
8-
"!/contracts/mocks/**/*"
8+
"!/contracts/mocks/**/*",
9+
"!/contracts/vendor/erc4337-entrypoint"
910
],
1011
"scripts": {
1112
"compile": "hardhat compile",

scripts/upgradeable/patch-apply.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
6-
PATCH="$DIRNAME/upgradeable.patch"
6+
PATCH="$DIRNAME/${1:-upgradeable.patch}"
77

88
error() {
99
echo Error: "$*" >&2

scripts/upgradeable/patch-save.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
6-
PATCH="$DIRNAME/upgradeable.patch"
6+
PATCH="$DIRNAME/${1:-upgradeable.patch}"
77

88
error() {
99
echo Error: "$*" >&2

scripts/upgradeable/transpile.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ set -euo pipefail -x
55
VERSION="$(jq -r .version contracts/package.json)"
66
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
77

8+
# Apply patch to contracts that are transpiled
89
bash "$DIRNAME/patch-apply.sh"
910
sed -i'' -e "s/<package-version>/$VERSION/g" "contracts/package.json"
1011
git add contracts/package.json
1112

13+
# Build artifacts
1214
npm run clean
1315
npm run compile
1416

17+
# Check artifacts are correctly built
1518
build_info=($(jq -r '.input.sources | keys | if any(test("^contracts/mocks/.*\\bunreachable\\b")) then empty else input_filename end' artifacts/build-info/*))
1619
build_info_num=${#build_info[@]}
1720

@@ -20,10 +23,13 @@ if [ $build_info_num -ne 1 ]; then
2023
exit 1
2124
fi
2225

26+
# Apply changes to the excluded contracts (these don't need to in the artifact and may prevent compilation)
27+
git apply -3 "$DIRNAME/upgradeable.excluded.patch"
28+
2329
# -D: delete original and excluded files
2430
# -b: use this build info file
2531
# -i: use included Initializable
26-
# -x: exclude proxy-related contracts with a few exceptions
32+
# -x: exclude vendored and proxy-related contracts with a few exceptions
2733
# -p: emit public initializer
2834
# -n: use namespaces
2935
# -N: exclude from namespaces transformation
@@ -38,6 +44,8 @@ npx @openzeppelin/upgrade-safe-transpiler -D \
3844
-x '!contracts/proxy/ERC1967/ERC1967Utils.sol' \
3945
-x '!contracts/proxy/utils/UUPSUpgradeable.sol' \
4046
-x '!contracts/proxy/beacon/IBeacon.sol' \
47+
-x 'contracts/vendor/**/*' \
48+
-x '!contracts/vendor/compound/ICompoundTimelock.sol' \
4149
-p 'contracts/access/manager/AccessManager.sol' \
4250
-p 'contracts/finance/VestingWallet.sol' \
4351
-p 'contracts/governance/TimelockController.sol' \
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/contracts/vendor/erc4337-entrypoint/core/EntryPoint.sol b/contracts/vendor/erc4337-entrypoint/core/EntryPoint.sol
2+
index 778115b1..44501524 100644
3+
--- a/contracts/vendor/erc4337-entrypoint/core/EntryPoint.sol
4+
+++ b/contracts/vendor/erc4337-entrypoint/core/EntryPoint.sol
5+
@@ -15,10 +15,8 @@ import "./Helpers.sol";
6+
import "./NonceManager.sol";
7+
import "./UserOperationLib.sol";
8+
9+
-// import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
10+
-// import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
11+
-import "../../../utils/introspection/ERC165.sol"; // OZ edit
12+
-import "../../../utils/ReentrancyGuard.sol"; // OZ edit
13+
+import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
14+
+import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
15+
16+
/*
17+
* Account-Abstraction (EIP-4337) singleton EntryPoint implementation.

0 commit comments

Comments
 (0)