diff --git a/docs/common/mainnet/002-upgrades.md b/docs/common/mainnet/002-upgrades.md index f9235ad8..e83cbec0 100644 --- a/docs/common/mainnet/002-upgrades.md +++ b/docs/common/mainnet/002-upgrades.md @@ -1,5 +1,17 @@ # Mainnet upgrades +## V1.0.7 +Core binary: (alpine-linux/amd64): "". + +Also, you can build core from sources by yourself: Use <"https://github.com/rarimo/rarimo-core"> repo and `chains/mainnet` branch. + +Upgrade will perform automatically if you are using `cosmovisor` under Alpine linux. +Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. + +Upgrade v1.0.7 introduces fixes to the `rarimocore` module: +- Adding feature to clear old TSS violation reports. +- Manual unfreeze of all TSS parties without necessity to reshare keys. + ## V1.0.6 Core binary: (alpine-linux/amd64): "" diff --git a/x/rarimocore/keeper/abci.go b/x/rarimocore/keeper/abci.go index 8e948c85..ce1ed186 100644 --- a/x/rarimocore/keeper/abci.go +++ b/x/rarimocore/keeper/abci.go @@ -17,7 +17,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) { party.Status = types.PartyStatus_Slashed party.FreezeEndBlock = 0 - - k.SetParams(ctx, param) } + + k.SetParams(ctx, param) } diff --git a/x/rarimocore/keeper/msg_server_report_violation.go b/x/rarimocore/keeper/msg_server_report_violation.go index 29f527d6..c11fe3ca 100644 --- a/x/rarimocore/keeper/msg_server_report_violation.go +++ b/x/rarimocore/keeper/msg_server_report_violation.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "strconv" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -58,14 +59,14 @@ func (t msgServer) ReportViolation(goCtx context.Context, msg *types.MsgCreateVi alreadyIncremented = alreadyIncremented || (sessionReported == msg.SessionId) } - // If party was not incremented then increment. - // If violations reaches threshold then party becomes frozen. + // Trying to apply new violation if was not applied yet. if !alreadyIncremented { + // Check that already have enough reports to confirm violation if uint64(len(reports)) >= params.Threshold { - party.ViolationsCount++ - party.ReportedSessions = append(party.ReportedSessions, msg.SessionId) + confirmViolation(party, msg.SessionId) } + // If violations reaches threshold then party becomes frozen. if party.ViolationsCount == params.MaxViolationsCount { party.Status = types.PartyStatus_Frozen party.FreezeEndBlock = uint64(ctx.BlockHeight()) + params.FreezeBlocksPeriod @@ -89,3 +90,29 @@ func (t msgServer) ReportViolation(goCtx context.Context, msg *types.MsgCreateVi return &types.MsgCreateViolationReportResponse{}, nil } + +// confirmViolation updates party entry with: +// 1. increments violations counter +// 2. adds new sessionId to the reported sessions +// 3. removes old reports with corresponding decreasing of counter +func confirmViolation(party *types.Party, sessionId string) { + party.ReportedSessions = append(party.ReportedSessions, sessionId) + + // we are assuming that session ids is an integer values encoded into string + sessionIdInt, _ := strconv.Atoi(sessionId) + + // dropReportSessionDelta is an amount of sessions when report is considered to old and can be removed + const dropReportSessionDelta = 100 + + actualReportedSessions := make([]string, 0, len(party.ReportedSessions)) + + for _, ssi := range party.ReportedSessions { + ssiInt, _ := strconv.Atoi(ssi) + if ssiInt+dropReportSessionDelta > sessionIdInt { + actualReportedSessions = append(actualReportedSessions, ssi) + } + } + + party.ReportedSessions = actualReportedSessions + party.ViolationsCount = uint64(len(party.ReportedSessions)) +}