Skip to content

[🧠 Smart Account] EIP-7702 upgrade/downgrade service#1906

Merged
jungcome7 merged 6 commits intoroy/evm-smart-accountfrom
roy/keplr-2044
Apr 2, 2026
Merged

[🧠 Smart Account] EIP-7702 upgrade/downgrade service#1906
jungcome7 merged 6 commits intoroy/evm-smart-accountfrom
roy/keplr-2044

Conversation

@jungcome7
Copy link
Copy Markdown
Contributor

@jungcome7 jungcome7 commented Mar 31, 2026

#1905에서 만든 Type 4 직렬화와 authorization 서명을 활용하여, Smart Account 업/다운그레이드를 실제 수행하는 서비스를 구현합니다. UI는 후속 PR에서 구현합니다.

변경사항

  • 업/다운그레이드, 상태 조회, 수수료 조회를 위한 4개 메시지 추가 (approveExternal: false로 외부 dApp 호출 차단)
  • sendEip7702Tx 9단계 플로우 구현 (dummy auth → fillUnsignedEVMTx로 gas/fee/nonce batch 조회 → nonce+1로 진짜 auth 서명 → 브로드캐스트 → retry() 폴링)
  • 외부 dApp이 authorizationList가 포함된 TX 서명을 요청하면 3개 지점에서 독립적으로 차단
    • signEthereum에서 env.isInternalMsg를 확인하여 외부 메시지면 거부
    • prepareAndSignTransaction에서 authorizationList가 있으면 무조건 거부
    • 위 두 곳을 통과하더라도 validateAuthorizationList에서 허용된 delegator 주소인지, chainId=0이 아닌지 검증
  • 가스 추정은 EIP-7702 전용 함수를 만들지 않고 기존 fillUnsignedEVMTx를 그대로 재사용
    • eth_estimateGas 파라미터에 dummy authorizationList를 포함하면 RPC 노드가 authorization intrinsic gas(PER_EMPTY_ACCOUNT_COST = 25,000)를 자동으로 계산하므로, 수동 overhead 추가가 불필요
    • 기존 파이프라인의 1.3x gas 버퍼, 20블록 feeHistory, mean/median priorityFee 분석이 그대로 적용되어 일반 TX와 동일한 수치로 추정

커밋

sendEip7702Tx 흐름

체인이 EIP-7702를 지원하는지, 하드웨어 지갑이 아닌지 검증
  │
  ▼
eth_getCode로 현재 delegation 상태 확인 (ready/supported/unsupported)
  │
  ▼
dummy auth로 fillUnsignedEVMTx 호출 → gas, fee, nonce를 batch RPC 1회로 조회
  │
  ▼
반환된 nonce+1로 진짜 authorization 서명 (self-sponsoring 규칙)
  │
  ▼
filled 결과에 진짜 authList를 덮어써서 Type 4 TX 조립
  │
  ▼
signEthereumPreAuthorized로 서명 (UI 확인은 메시지 전송 전에 완료)
  │
  ▼
RLP 직렬화 → eth_sendRawTransaction 브로드캐스트
  │
  ▼
retry()로 receipt 폴링, revert 감지 시 에러 throw

Test plan

  • UI PR 완성 후 Sepolia testnet에서 업그레이드/다운그레이드 E2E 검증

🤖 Generated with Claude Code

후속 PR — UI + ObservableQuery 마이그레이션

#1910에서 이 PR의 백엔드 서비스를 사용하는 UI 페이지를 구현합니다. 동시에 GetSmartAccountDelegationStatusMsg(메시지 기반 상태 조회)를 MobX ObservableQuery로 마이그레이션하여, 자동 캐시와 관찰 시 자동 fetch를 지원합니다. 이에 따라 해당 메시지/핸들러/init 등록은 #1910에서 삭제됩니다.

@jungcome7 jungcome7 requested a review from a team as a code owner March 31, 2026 09:07
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
keplr-wallet-extension Ready Ready Preview, Comment Apr 1, 2026 5:14am

Request Review

@jungcome7 jungcome7 changed the title feat: EIP-7702 smart account upgrade/downgrade backend (KEPLR-2044) [🧠 Smart Account] EIP-7702 upgrade/downgrade backend Mar 31, 2026
@jungcome7 jungcome7 self-assigned this Mar 31, 2026
@jungcome7 jungcome7 changed the title [🧠 Smart Account] EIP-7702 upgrade/downgrade backend [🧠 Smart Account] EIP-7702 upgrade/downgrade service Mar 31, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11371a73c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

undefined,
chainId
);
return parseDelegation(code ?? "0x", ALLOWED_DELEGATORS);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return unsupported status on chains without EIP-7702

getDelegationStatus always parses eth_getCode without checking the chain feature flag, so on non-7702 chains EOAs will be reported as "ready" (because code is 0x). That makes callers think upgrade is available, but upgradeToSmartAccount immediately fails later with "This chain does not support EIP-7702.", creating a broken flow for any UI that relies on this status endpoint. Add the same eip-7702 feature guard used in getAtomicCapability before returning delegation status.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다. getAtomicCapability와 동일하게 getChainFeatures guard를 추가했습니다.

Comment on lines +25 to +28
typeof auth.chainId === "string"
? parseInt(auth.chainId, auth.chainId.startsWith("0x") ? 16 : 10)
: Number(auth.chainId);
if (numericChainId === 0 || !Number.isFinite(numericChainId)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject malformed authorization chain IDs

validateAuthorizationList uses parseInt and only rejects 0/non-finite values, so malformed values like "1abc" or negative IDs like "-1" pass validation. In internal signing flows this means invalid authorization entries are accepted and signed instead of being rejected at validation time, leading to hard-to-debug signing/broadcast failures and weakening the intended guardrail around authorization metadata. Enforce a strict positive-integer check (full-string validation) for chainId.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateAuthorizationList에 도달하는 chainId는 항상 evmInfo.chainId(number, 양의 정수)에서 옵니다. string chainId가 들어오는 외부 dApp 경로는 signEthereumprepareAndSignTransaction에서 이미 차단되므로 현재로서는 발생하지 않습니다.

jungcome7 and others added 5 commits March 31, 2026 19:00
…pe in tx-executor

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jungcome7 jungcome7 changed the base branch from roy/keplr-2043 to roy/evm-smart-account March 31, 2026 11:36
@jungcome7
Copy link
Copy Markdown
Contributor Author

jungcome7 commented Apr 1, 2026

참고

#1910에서 이 PR의 GetSmartAccountDelegationStatusMsg를 MobX ObservableQuery로 마이그레이션했습니다.
delegation 상태가 여러 UI에서 반복 참조되어 쿼리 캐시 활용이 필요하므로, 해당 메시지/핸들러/init 등록/서비스 메서드를 삭제하고 ObservableQuery로 대체합니다.

Copy link
Copy Markdown
Member

@piatoss3612 piatoss3612 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 먼저 병합하시죠

@jungcome7 jungcome7 merged commit a5d3abc into roy/evm-smart-account Apr 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants