Wires the reputation slash the dispute path left as a TODO (2289e156), via depinject (x/modelregistry -> x/reputation, no import cycle). - x/reputation: new public SlashReputation(ctx, addr, points) keeper method — saturating decrement (floors at 0, never underflows), emits slash_reputation event; missing address is a safe no-op. Keeper test: reduce / floor-at-0 / unknown-address no-op. - x/modelregistry: ReputationKeeper interface (expected_keepers) + keeper field + NewKeeper param; depinject auto-binds the reputation keeper output to the interface input (validated by TestNewApp — same pattern reputation uses to consume the marketplace keeper). - DisputeInferenceJob now slashes job.Provider by DisputeReputationPenalty (=1), best-effort (dispute already persisted; slash error never rolls it back). Test fixture asserts the slash. Completes the P4 inference-settlement surface: attestation -> dispute -> slash. Verified: go build ./... clean, go vet clean, go test ./x/modelregistry/... ./x/reputation/... ./app/... green incl. TestNewApp, no proto changes.
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package modelregistry
|
|
|
|
import (
|
|
"cosmossdk.io/core/address"
|
|
"cosmossdk.io/core/appmodule"
|
|
"cosmossdk.io/core/store"
|
|
"cosmossdk.io/depinject"
|
|
"cosmossdk.io/depinject/appconfig"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
|
|
"clawchain/x/modelregistry/keeper"
|
|
"clawchain/x/modelregistry/types"
|
|
)
|
|
|
|
var _ depinject.OnePerModuleType = AppModule{}
|
|
|
|
func (AppModule) IsOnePerModuleType() {}
|
|
|
|
func init() {
|
|
appconfig.Register(
|
|
&types.Module{},
|
|
appconfig.Provide(ProvideModule),
|
|
)
|
|
}
|
|
|
|
type ModuleInputs struct {
|
|
depinject.In
|
|
|
|
Config *types.Module
|
|
StoreService store.KVStoreService
|
|
Cdc codec.Codec
|
|
AddressCodec address.Codec
|
|
|
|
BankKeeper types.BankKeeper
|
|
ReputationKeeper types.ReputationKeeper
|
|
}
|
|
|
|
type ModuleOutputs struct {
|
|
depinject.Out
|
|
|
|
ModelRegistryKeeper keeper.Keeper
|
|
Module appmodule.AppModule
|
|
}
|
|
|
|
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
|
authority := authtypes.NewModuleAddress(types.GovModuleName)
|
|
if in.Config.Authority != "" {
|
|
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
|
}
|
|
k := keeper.NewKeeper(
|
|
in.StoreService,
|
|
in.Cdc,
|
|
in.AddressCodec,
|
|
authority,
|
|
in.BankKeeper,
|
|
in.ReputationKeeper,
|
|
)
|
|
m := NewAppModule(in.Cdc, k, in.BankKeeper)
|
|
|
|
return ModuleOutputs{ModelRegistryKeeper: k, Module: m}
|
|
}
|