-
Notifications
You must be signed in to change notification settings - Fork 3
Stack too deep when migrating Gnosis Safe #142
Copy link
Copy link
Closed
Labels
Description
Description
Safe extensively uses the proxy pattern in its contract architecture, which easily triggers the maximum call stack depth limit. For example, the simulation feature for multi-sig transactions (essential for Safe usage) involves the following call stack:
SafeProxy
└─(delegatecall)→ SafeSingleton
└─(call)→ CompatibilityFallbackHandler
└─(call)→ SafeProxy
└─(delegatecall)→ SafeSingleton
└─(delegatecall)→ SimulateTxAccessor
└─(call/delegatecall)→ targetContract
The current maximum call stack depth in Revive is insufficient to support this basic use case.
How to Reproduce
- Clone and setup the repository
git clone https://github.com/papermoonio/safe-polkadot-poc
cd safe-polkadot-poc
pnpm install- Create
.envfile
Create a.envfile in the project root:
LOCAL_PRIV_KEY=0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
LOCAL_PRIV_KEY_2=0xxxx
- Run the scripts
# 1. Deploy all contracts
USE_POLKAVM=true npx hardhat run scripts/deployAll.ts --network local
# 2. Execute simulation script
USE_POLKAVM=true npx hardhat run scripts/simulate.ts --network localError Messages
Hardhat reports:
ProviderError: execution reverted:
Substrate node logs show:
2025-07-29 22:53:37.001 TRACE tokio-runtime-worker runtime::revive::strace: call(flags_and_callee: 34359935056, ref_time_limit: 18446744073709551615, proof_size_limit: 18446744073709551615, deposit_and_value: 18446172606835849216, input_data: 131312, output_data: 18446172465102192720) = Err(TrapReason::SupervisorError(Module(ModuleError { index: 80, error: [5, 0, 0, 0], message: Some("MaxCallDepthReached") }))) gas_consumed: Weight { ref_time: 554262959, proof_size: 9078 }
Impact
- Gnosis Safe cannot function properly on Polkadot
- Multi-sig wallets and DAOs using Safe infrastructure are blocked
- Any protocol using similar proxy patterns may face the same limitation
Proposed Solution
Increase the maximum call stack depth limit in Revive to support complex but legitimate contract patterns like those used in Gnosis Safe.
Reactions are currently unavailable