refactor: dedupe create/lock/init helpers, simplify deployment-code build#35
Merged
chunter-cb merged 3 commits intoJul 13, 2026
Conversation
…uild
- Add _prepare() shared by createAccount and computeAddress so the
effective salt, deployment code, and address are built and hashed once
instead of twice (avoids constructing/keccak-ing the ~24KB code buffer
and the actors commitment a second time per creation).
- Rebuild _buildDeploymentCode with a single abi.encodePacked of the
14-byte loader + bytecode, dropping the byte-by-byte copy loop.
- Add _isInitialized() and use it in createAccount/importAccount,
removing the triplicated localSequence/multichainSequence check and
restated "localSequence doubles as the initialized flag" comment.
- Rewrite _checkAndClearLock in terms of _isLocked so the lazy-clear rule
("LOCKED still set but no longer locked") is self-evident.
- Fix isActor NatSpec: it reports authorization, not liveness (no expiry
check); standardize getActorConfig on the >= K1_AUTHENTICATOR idiom.
…henticator - Mark ERC1271_SELECTOR `internal constant` (was the only constant with no explicit visibility), matching SECP256K1_HALF_ORDER. - Document why _authorizeActor accepts a non-zero authenticator with no code: authenticators may be counterfactual or intentionally codeless sentinels, so it fails closed at authentication time by design.
2 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Five targeted dedupe/cleanup changes to
AccountConfiguration.sol. No behavior change — all 355 tests pass, including the deterministic-address and max-size-bytecode create tests._prepare()shared bycreateAccount+computeAddress.createAccountpreviously built and hashed everything twice:computeAddressderived the address (effective salt + actors commitment + deployment-code hash), then the tail rebuilt the deployment code and salt from scratch. For a max-size account that's constructing and keccak-ing a ~24KB buffer — and recomputing the actors commitment — twice._prepare(userSalt, bytecode, initialActors) → (account, effectiveSalt, deploymentCode)does it once for both callers._buildDeploymentCodeviaabi.encodePacked. Replaces the 14 indexed byte-stores + trailing bounded copy loop with a singleabi.encodePacked(bytes1(0x61), bytes2(uint16(n)), hex\"600e600039\", bytes1(0x61), bytes2(uint16(n)), hex\"6000f3\", bytecode). Same loader bytes, compiles to a calldatacopy, easier to audit against the opcode comment.isActorNatSpec fix + idiom standardization.isActorpromised "live" but doesn't check expiry (intentional —_revokeActorneeds to revoke expired actors); corrected the doc to "authorized (possibly expired)". StandardizedgetActorConfig's non-zero-authenticator test on the>= K1_AUTHENTICATORnamespace idiom already used byisActor._checkAndClearLockin terms of_isLocked. The three-branch flag decode was duplicated across_isLocked/_checkAndClearLock. Nowif (_isLocked(st)) return true;then clear iffFLAG_LOCKEDis still set — making the lazy-clear rule self-evident rather than re-derived._isInitialized()helper. ThelocalSequence != 0 || multichainSequence != 0check (and its restated comment) was triplicated acrosscreateAccount/importAccount; centralized into one helper.Notes
style/compiler-pins-and-dedup(PR style: pin compiler version, dedupe helpers #34), continuing that PR's dedupe theme and building on_disableInlineSelf. Retarget tomainonce fix: shadowed-local warnings + zero-commitment policy actor note + style + optimizations #33/style: pin compiler version, dedupe helpers #34 land.Test plan
forge fmt+forge buildclean on 0.8.36forge test— 355 passed, 0 failed