You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 883991e
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Add governance switches that stop CosmWasm contracts in two stages (#4564)
The wasm module has governance params for code upload and instantiation
but none for execution: `Keeper.execute` runs without any permission
check, so turning `MsgExecuteContract` off, or stopping contracts
altogether, currently takes a code change.
This adds two bool wasm params, set with ordinary param-change
proposals, that stop contracts in two stages. The first is
`msgExecuteContractDisabled`. While it is true,
`msgServer.ExecuteContract` returns `ErrMsgExecuteContractDisabled`
(wasm code 31) before it touches the contract. Every
`MsgExecuteContract` reaches that handler, whether it arrives in a
transaction, inside an authz `MsgExec`, or from a contract that
dispatches it, so the check lives only there. `NewMsgServerImpl` and
`wasm.NewHandler` now take the `*Keeper` and build the default
permission keeper themselves, which is what all their callers already
passed.
Calls that do not go through `MsgExecuteContract` keep working: the EVM
wasmd precompile, solo claims, gov `ExecuteContractProposal`, sudo,
migrate, instantiate and queries. A contract reached through the
precompile still runs, but an execute it dispatches to another contract
is refused. `Keeper.msgExecuteContractDisabled` reads the param without
charging gas and treats a missing key as false, so executions cost the
same gas as today and replays of blocks from before the param existed
keep their outcome.
The second, `contractExecutionDisabled`, stops every contract from
running. While it is true, `Keeper.instantiate`, `execute`, `migrate`
and `Sudo` return `ErrContractExecutionDisabled` (wasm code 32) before
they charge gas or touch state. Every path that runs contract code goes
through one of those four, and `reply` only runs inside them, so nothing
runs whatever the origin: `MsgExecuteContract` with or without authz,
contract-dispatched messages, the EVM wasmd precompile, solo claims and
wasm gov proposals all fail. Queries still answer, so pointer reads keep
working, and code upload stays under `uploadAccess`. While it is on,
solo claims of CW20 and CW721 assets fail, ERC20 and ERC721 pointers to
CW tokens cannot transfer, and governance cannot run a final migrate or
sudo without turning it off first. Both params are read through the same
gas-free `Keeper.getFlagParam`.
Sei's gov keeper refuses a param-change proposal for a key that is not
stored yet, so the wasm module moves to consensus version 2 and
`Migrator.Migrate1to2` stores both keys as false at whichever upgrade
first ships this. That write and the version bump are app-hash breaking
at that upgrade; nothing else changes until governance sets a param. The
v6.8 upgrade tests seed wasm at 1 in the v6.7 version map and require it
to reach 2 with both params stored as false, in process, against a
persisted v6.7 database, and across a live v6.7 to v6.8 upgrade. CheckTx
does not run messages, so a disabled `MsgExecuteContract` still lands in
a block and fails there with its fee charged. Keeper tests cover each
path with each param off and on, the gov proposals and the migration;
for `contractExecutionDisabled` they run every entry point and origin
and require a refused call to leave every store unchanged. An app test
delivers the direct and authz forms through real blocks, and the wasmd
precompile test requires its execute and instantiate to revert while its
query answers.
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Masih H. Derkani <m@derkani.org>
*[#4564](https://github.com/sei-protocol/sei-chain/pull/4564) Add two wasm params governance can set to stop CosmWasm contracts in stages. While `msgExecuteContractDisabled` is true, every `MsgExecuteContract` fails, whether sent directly, wrapped in an authz `MsgExec` or dispatched by a contract; the EVM wasmd precompile, solo claims and wasm gov proposals still execute. While `contractExecutionDisabled` is true, no contract runs: every instantiation, execution, migration and sudo call fails, whatever its origin, including the EVM wasmd and solo precompiles and wasm gov proposals; queries still work. The wasm module moves to consensus version 2 and stores both params as false at the upgrade. App-hash breaking at the upgrade height.
33
34
*[#4563](https://github.com/sei-protocol/sei-chain/pull/4563) Delete the retired feegrant store at the v6.8 upgrade: v6.7 kept it mounted for historical state access, and from the upgrade height v6.8 nodes no longer serve feegrant state at any height, so that history needs a v6.7 or older node. App-hash breaking at the upgrade height.
34
35
*[#4549](https://github.com/sei-protocol/sei-chain/pull/4549) Keep the tokenfactory `burn_tokens` Wasm message working after v6.8: a contract can still burn a `factory/` denom it created from its own balance, so the Silo and Eris liquid staking hubs and the Wormhole token translator keep their redemption paths. Minting and every other tokenfactory message stay removed.
35
36
*[#4536](https://github.com/sei-protocol/sei-chain/pull/4536) Remove the tokenfactory module behind the v6.8 upgrade: module, store, params, protobuf schema, CLI, wasm bindings, the bank `factory/` denom transfer allowlist and tooling are gone; only the tokenfactory Msg types remain decodable so historical blocks still trace. Existing `factory/` balances stay in bank but can no longer be minted or burned, and denoms that had a transfer allowlist become freely transferable. The upgrade deletes at most 1,000 allowlists from the bank store and leaves any beyond that in place, unenforced. App-hash breaking at the upgrade height.
0 commit comments