Skip to content

Commit

Permalink
Finish logic and test slashing provider chain
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitys7 committed Aug 30, 2024
1 parent bcf1dae commit 3b26cde
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions tests/e2e/slashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ func TestSlashingProviderChain(t *testing.T) {
require.Equal(t, validator1.GetTokens(), sdk.NewInt(90_900_000))

// Assert sudo msg has been sent to contract
require.Equal(t, 200_000_000, providerCli.QueryVaultBalance())
require.Equal(t, 150_000_000, providerCli.QueryMaxLien())
require.Equal(t, 30_000_000, providerCli.QuerySlashableAmount())
require.Equal(t, 190_000_000, providerCli.QueryVaultBalance())
require.Equal(t, 140_000_000, providerCli.QueryMaxLien())
require.Equal(t, 28_000_000, providerCli.QuerySlashableAmount())
require.Equal(t, 50_000_000, providerCli.QueryVaultFreeBalance())
}
Binary file modified tests/testdata/mesh_converter.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_external_staking.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_native_staking.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_native_staking_proxy.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_osmosis_price_provider.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_remote_price_feed.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_simple_price_feed.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_vault.wasm.gz
Binary file not shown.
Binary file modified tests/testdata/mesh_virtual_staking.wasm.gz
Binary file not shown.
17 changes: 12 additions & 5 deletions x/meshsecurityprovider/keeper/adapter.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"fmt"

"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -96,13 +94,22 @@ func (s StakingDecorator) SlashWithInfractionReason(ctx sdk.Context, consAddr sd
params := s.k.GetParams(ctx)
nativeStakingAddr := sdk.MustAccAddressFromBech32(params.NativeStakingAddress)

fmt.Println("nativeStakingAddr: ", nativeStakingAddr)
validator := s.StakingKeeper.ValidatorByConsAddr(ctx, consAddr)

if infraction == stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN {
s.k.SendJailHandlingMsg(ctx, nativeStakingAddr, nil, []string{consAddr.String()})
err := s.k.SendJailHandlingMsg(ctx, nativeStakingAddr, []string{}, []string{validator.GetOperator().String()})
if err != nil {
meshsecuritykeeper.ModuleLogger(ctx).
Error("can not send tombstone handling message to native-staking contract")
}
}

if infraction == stakingtypes.Infraction_INFRACTION_DOWNTIME {
s.k.SendJailHandlingMsg(ctx, nativeStakingAddr, []string{consAddr.String()}, nil)
err := s.k.SendJailHandlingMsg(ctx, nativeStakingAddr, []string{validator.GetOperator().String()}, []string{})
if err != nil {
meshsecuritykeeper.ModuleLogger(ctx).
Error("can not send jail handling message to native-staking contract")
}
}
return s.Slash(ctx, consAddr, infractionHeight, power, slashFactor)
}
Expand Down
5 changes: 1 addition & 4 deletions x/meshsecurityprovider/keeper/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"encoding/json"
"fmt"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -16,9 +15,7 @@ func (k Keeper) doSudoCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg con
if err != nil {
return errorsmod.Wrap(err, "marshal sudo msg")
}
resp, err := k.wasmKeeper.Sudo(ctx, contractAddr, bz)
fmt.Println("sudo call: ", string(resp))
fmt.Println("msg: ", string(bz))
_, err = k.wasmKeeper.Sudo(ctx, contractAddr, bz)
return err
}

Expand Down

0 comments on commit 3b26cde

Please sign in to comment.