caelum0x bfa64e91a9 fix(privacy): bind shielded pool to native denom and repair integration tests
The shielded pool let Shield accept any denom via msg.Coins while Unshield
always paid out a hardcoded "stake" denom. On a chain whose bond denom is
"uclaw" this is a correctness/security defect: withdrawals either break or
drain the pool of the wrong asset.

- Add types.PoolDenom() (= chain bond denom) as the single source of truth.
- Shield/Unshield/ibc_shield now operate exclusively on the native denom;
  foreign denoms are rejected with ErrUnsupportedDenom. The pool is single-denom.
- IBC auto-shield only shields the native denom (foreign vouchers are skipped;
  the middleware already treats this as a soft failure).
- Add regression tests asserting the single-denom invariant (the old tests used
  a denom-ignoring mock and never exercised the bug).
- Repair the bit-rotted integration-tagged suite: tests predating the
  MinShieldAmount=1000 rule shielded sub-1000 amounts. Bump amounts >=1000,
  scaling private-transfer values to preserve the input=output balance.
2026-05-31 07:33:17 +03:00

39 lines
1.0 KiB
Go

package simulation
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"clawchain/x/privacy/keeper"
"clawchain/x/privacy/types"
)
func SimulateMsgShield(
ak types.AuthKeeper,
bk types.BankKeeper,
k keeper.Keeper,
txGen client.TxConfig,
) simtypes.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)
msgSrv := keeper.NewMsgServerImpl(k)
msg := &types.MsgShield{
Creator: simAccount.Address.String(),
Amount: uint64(r.Intn(10) + 1),
Coins: types.PoolDenom(),
}
_, err := msgSrv.Shield(sdk.WrapSDKContext(ctx), msg)
if err != nil {
return simtypes.NewOperationMsg(msg, false, err.Error()), nil, nil
}
return simtypes.NewOperationMsg(msg, true, ""), nil, nil
}
}