Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dynamic commission acc seq fix #386

Merged
merged 5 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/upgrades/forks/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ var VersionMapEnableFork = upgrades.Fork{
UpgradeHeight: fork.VersionMapEnableHeight,
BeginForkLogic: runForkLogicVersionMapEnable,
}

type Acc struct {
Address string
Sequence uint64
}

var affectedAccounts = []Acc{}

var AccAddressFixFork = upgrades.Fork{
UpgradeName: "v2.3.1",
UpgradeHeight: fork.AccAddressFixHeight,
BeginForkLogic: runForkLogicCorrectAccountSequence,
}
18 changes: 18 additions & 0 deletions app/upgrades/forks/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,21 @@ func runForkLogicVersionMapEnable(ctx sdk.Context, keppers *keepers.AppKeepers,
keppers.UpgradeKeeper.SetModuleVersionMap(ctx, mm.GetVersionMap())
}
}

func runForkLogicCorrectAccountSequence(ctx sdk.Context, keppers *keepers.AppKeepers, mm *module.Manager) {
if ctx.ChainID() == core.ColumbusChainID {
// Correct account sequence
for _, acc := range affectedAccounts {
account := keppers.AccountKeeper.GetAccount(ctx, sdk.MustAccAddressFromBech32(acc.Address))
// check if local account sequence is equal to targeted account sequence
if account.GetSequence() == acc.Sequence {
ctx.Logger().Info(fmt.Sprintf("Account %s sequence is already correct", acc.Address))
continue
}

account.SetSequence(acc.Sequence)
keppers.AccountKeeper.SetAccount(ctx, account)
ctx.Logger().Info(fmt.Sprintf("Account %s sequence is corrected to %d", acc.Address, acc.Sequence))
}
}
}
4 changes: 3 additions & 1 deletion custom/auth/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
NewMinInitialDepositDecorator(options.GovKeeper, options.TreasuryKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
NewFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TreasuryKeeper),
dyncommante.NewDyncommDecorator(options.DyncommKeeper, options.StakingKeeper),

// Do not add any other decorators below this point unless explicitly explain.
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(&options.IBCKeeper),
dyncommante.NewDyncommDecorator(options.DyncommKeeper, options.StakingKeeper),
), nil
}
1 change: 1 addition & 0 deletions types/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ const (
// Revert Min Commission slip during v2.2.0 upgrade
FixMinCommissionHeight = int64(14_890_000)
nghuyenthevinh2000 marked this conversation as resolved.
Show resolved Hide resolved
FixMinCommissionHeightRebel = int64(16_300_000)
AccAddressFixHeight = int64(0)
)