Repository navigation
refactor(kms-auth): deploy app proxies through the DstackApp implementation - #1623
Merged
Merged
Conversation
…tation Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
refactor/kms-contract-size-2
branch
from
November 19, 2026 05:03
2ac2713 to
14aca40
Compare
kvinwang
enabled auto-merge
November 19, 2026 05:03
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.
Problem
DstackKmsis 24,113 bytes, against the 24,576-byte EIP-170 limit. The test upgrade targetDstackKmsV2has 231 bytes left, so almost any addition toDstackKmsfailsforge build --sizes. A per-platform TCB policy, for example, needs about 1.9 KB. #1569 already took the cheap wins (custom errors, range-only setters).The largest single item is
deployAndRegisterApp'snew ERC1967Proxy(...): it embeds the proxy's creation code (1,007 bytes) and theERC1967Utilscode it pulls in.Fix
DstackAppgainsdeployProxy(initData), which runsnew ERC1967Proxy(address(this), initData)and refuses to run through a proxy (notDelegated).DstackKms.deployAndRegisterAppcalls it onappImplementation. Nothing new is deployed:appImplementationis already a deployedDstackApp, and the app proxies are still OpenZeppelinERC1967Proxy. Anyone may calldeployProxy, but that is the same as deploying a proxy themselves.DstackKmsDstackKmsV2DstackAppAlternatives measured:
optimizer_runs = 1saves only 265 bytes.via_irsaves about 1.6 KB, but it changes code generation for every contract. An external library or a separate factory adds a deployment step.Upgrade note
appImplementationmust be a currentDstackApp. A released one has nodeployProxy, sodeployAndRegisterAppreverts until it is replaced; nothing else is affected.Upgrade.s.sol:UpgradeKmsnow deploys aDstackAppand sets it in the sameupgradeToAndCall, so the scripted upgrade is still one command. The CHANGELOG andscript/README.mddescribe the manual path.Verification
forge clean && forge test --ffi: 117 passed, including upgrade-safety validation. The newtest_ReleasedKmsDeploysAppsOnceItsAppImplementationIsCurrentupgrades a v0.6.0 KMS and checks three things:deployAndRegisterAppreverts whileappImplementationis the released app; aftersetAppImplementation, it deploys a correctly initialized app; and an app proxy refusesdeployProxy.FOUNDRY_DYNAMIC_TEST_LINKING=false):DstackKmsSymbolicTest11/11,DstackKmsEpochSymbolicTest13/13,DstackAppSymbolicTest5/5.