-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from lavanet/CNS-734-use-antehandler-to-mark…
…-redelegation-tx CNS-734: use antehandler to mark redelegation
- Loading branch information
Showing
9 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# this script is adding another validator to the chain (without a running node) (this validator will be soon jailed due to inactivity) | ||
clear | ||
rm -rf ~/.lava_test | ||
lavad init validator2 --chain-id lava --home ~/.lava_test | ||
lavad config broadcast-mode sync --home ~/.lava_test | ||
lavad config keyring-backend test --home ~/.lava_test | ||
lavad keys add validator2 --home ~/.lava_test | ||
|
||
GASPRICE="0.000000001ulava" | ||
lavad tx bank send $(lavad keys show alice -a) $(lavad keys show validator2 -a --home ~/.lava_test) 500000ulava -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE | ||
|
||
lavad tx staking create-validator -y --from validator2 --amount="50000ulava" --pubkey=$(lavad tendermint show-validator --home ~/.lava_test) --commission-rate="0.10" \ | ||
--commission-max-rate="0.20" \ | ||
--commission-max-change-rate="0.01" \ | ||
--min-self-delegation="1000" \ | ||
--gas-adjustment "1.5" \ | ||
--gas "auto" \ | ||
--gas-prices $GASPRICE \ | ||
--home ~/.lava_test | ||
|
||
lavad tx staking redelegate lava@valoper1yhzkfrcdwf2hwpc4cre8er5tamp6wdm4stx2ec lava@valoper1z025w20ms6cpdht585nhsw682jph4yc7hx0gqc 500000000000ulava -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ante | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
"github.com/lavanet/lava/x/dualstaking/keeper" | ||
) | ||
|
||
// RedelegationFlager sets the dualstaking redelegation flag when needed. | ||
// when the user sends redelegation tx we dont want the hooks to do anything | ||
type RedelegationFlager struct { | ||
keeper.Keeper | ||
} | ||
|
||
func NewRedelegationFlager(dualstaking keeper.Keeper) RedelegationFlager { | ||
return RedelegationFlager{Keeper: dualstaking} | ||
} | ||
|
||
func (rf RedelegationFlager) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | ||
redelegations := false | ||
others := false | ||
for _, msg := range tx.GetMsgs() { | ||
if _, ok := msg.(*stakingtypes.MsgBeginRedelegate); ok { | ||
redelegations = true | ||
} else { | ||
others = true | ||
} | ||
} | ||
|
||
if redelegations && others { | ||
return ctx, fmt.Errorf("cannot send batch requests with redelegation messages") | ||
} | ||
|
||
keeper.DisableDualstakingHook = redelegations | ||
|
||
return next(ctx, tx, simulate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters