Skip to content

Commit

Permalink
Updating Version
Browse files Browse the repository at this point in the history
Test Fixing and changelog update
Fix for sync from scratch. Ignoring additional parameters on key heights so apphash is not changed.
  • Loading branch information
Otto V authored and oten91 committed Aug 16, 2022
1 parent 629a388 commit 08df721
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
AppVersion = "BETA-0.9.0"
AppVersion = "RC-0.9.0"
)

// NewPocketCoreApp is a constructor function for PocketCoreApp
Expand Down
16 changes: 9 additions & 7 deletions app/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ func TestChangeParamsMaxBlocksizeBeforeActivationHeight(t *testing.T) {
<-evtChan // Wait for block
//Before Activation of the parameter ACL do not exist and the value and parameter should be 0 or nil
firstquery, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pocketcore/BlockByteSize")
assert.Equal(t, "0", firstquery.Value)
assert.Equal(t, "", firstquery.Value)
memCli, stopCli, evtChan := subscribeTo(t, tmTypes.EventTx)
//Tx wont modify anything as ACL is not configured (Txresult should be gov code 5)
tx, err := gov.ChangeParamsTx(memCodec(), memCli, kb, cb.GetAddress(), "pocketcore/BlockByteSize", 9000000, "test", 10000, false)
Expand Down Expand Up @@ -987,18 +987,18 @@ func TestChangepip22ParamsBeforeActivationHeight(t *testing.T) {
_, _, evtChan := subscribeTo(t, tmTypes.EventNewBlock)
<-evtChan // Wait for block
//Before Activation of the parameter ACL do not exist and the value and parameter should be 0 or nil
firstquery, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pos/ServicerStakeFloorMultiplier")
assert.Equal(t, "0", firstquery.Value)
firstquery, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pos/ServicerStakeWeightMultiplier")
assert.Equal(t, "", firstquery.Value)
memCli, stopCli, evtChan := subscribeTo(t, tmTypes.EventTx)
//Tx wont modify anything as ACL is not configured (Txresult should be gov code 5)
tx, err := gov.ChangeParamsTx(memCodec(), memCli, kb, cb.GetAddress(), "pos/ServicerStakeFloorMultiplier", 150000, "test", 10000, false)
tx, err := gov.ChangeParamsTx(memCodec(), memCli, kb, cb.GetAddress(), "pos/ServicerStakeWeightMultiplier", 1, "test", 10000, false)
assert.Nil(t, err)
assert.NotNil(t, tx)
select {
case _ = <-evtChan:
//fmt.Println(res)
assert.Nil(t, err)
o, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pos/ServicerStakeFloorMultiplier")
o, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pos/ServicerStakeWeightMultiplier")
//value should be equal to the first query of the param
assert.Equal(t, firstquery.Value, o.Value)
cleanup()
Expand All @@ -1020,7 +1020,7 @@ func TestChangeParamsMaxBlocksizeAfterActivationHeight(t *testing.T) {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
codec.TestMode = -2
codec.UpgradeFeatureMap[codec.BlockSizeModifyKey] = tc.upgrades.codecUpgrade.height
codec.UpgradeFeatureMap[codec.BlockSizeModifyKey] = tc.upgrades.codecUpgrade.height + 1
if tc.upgrades != nil { // NOTE: Use to perform neccesary upgrades for test
codec.UpgradeHeight = tc.upgrades.codecUpgrade.height
_ = memCodecMod(tc.upgrades.codecUpgrade.upgradeMod)
Expand All @@ -1034,6 +1034,7 @@ func TestChangeParamsMaxBlocksizeAfterActivationHeight(t *testing.T) {
assert.Nil(t, err)
_, _, evtChan := subscribeTo(t, tmTypes.EventNewBlock)
<-evtChan // Wait for block
<-evtChan // Wait for another block
//After Activation of the parameter ACL should be created(allowing modifying the value) and parameter should have default value of 4000000
o, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pocketcore/BlockByteSize")
assert.Equal(t, "4000000", o.Value)
Expand Down Expand Up @@ -1065,7 +1066,7 @@ func TestChangeParamspip22afterActivationHeight(t *testing.T) {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
codec.TestMode = -3
codec.UpgradeFeatureMap[codec.RSCALKey] = tc.upgrades.codecUpgrade.height
codec.UpgradeFeatureMap[codec.RSCALKey] = tc.upgrades.codecUpgrade.height + 1
if tc.upgrades != nil { // NOTE: Use to perform neccesary upgrades for test
codec.UpgradeHeight = tc.upgrades.codecUpgrade.height
_ = memCodecMod(tc.upgrades.codecUpgrade.upgradeMod)
Expand All @@ -1079,6 +1080,7 @@ func TestChangeParamspip22afterActivationHeight(t *testing.T) {
assert.Nil(t, err)
_, _, evtChan := subscribeTo(t, tmTypes.EventNewBlock)
<-evtChan // Wait for block
<-evtChan // Wait for another block
//After Activation of the parameter ACL should be created(allowing modifying the value) and parameter should have default value of 4000000
o, _ := PCA.QueryParam(PCA.LastBlockHeight(), "pos/ServicerStakeFloorMultiplier")
assert.Equal(t, "15000000000", o.Value)
Expand Down
5 changes: 3 additions & 2 deletions doc/releases/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
- Mempool Refinements :
- Tx max life in mempool is 2 blocks, after that txs are considered stale and evicted from the mempool
so they won't get to the block.
- add validation for edge case on cache equals to 0.
- backport tendermint #6068 (terminate broadcastEvidenceRoutine when peer is stopped)
- Add validation for edge case on cache equals to 0.
- Backport tendermint #6068 (terminate broadcastEvidenceRoutine when peer is stopped)
- Add new rpc endpoint /query/accounts.
- New config.json option to enable/disable authToken generation on start (auth.json).
- Implementation of PIP22 (Stake Weighted Servicer Rewards)[RSCAL][VEDIT].
- Customizable Max Block Size bytes and new tendermint evidence age.[BLOCK].
- Fix sync from scratch issue related to handling of new additional parameters.

## RC-0.8.3

Expand Down
15 changes: 14 additions & 1 deletion types/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const (
var (
ParamsKey = NewKVStoreKey(paramsKey)
ParamsTKey = NewTransientStoreKey(paramsTKey)
// AdditionalParametersKeys Tracks the keys for parameter added on the live network for RC-0.9.0 and future releases
AdditionalParametersKeys = []string{"BlockByteSize",
"ServicerStakeFloorMultiplier", "ServicerStakeWeightMultiplier",
"ServicerStakeWeightCeiling", "ServicerStakeFloorMultiplierExponent"}
)

// Individual parameter store for each keeper
Expand Down Expand Up @@ -291,7 +295,16 @@ func (s Subspace) SetParamSet(ctx Ctx, ps ParamSet) {
// since SetStruct is meant to be used in InitGenesis
// so this method will not be called frequently
v := reflect.Indirect(reflect.ValueOf(pair.Value)).Interface()
s.Set(ctx, pair.Key, v)
//if we are on the genesis or at codec upgrade height (heights where we call setParamSet For all the modules)
//ignore the additional parameter as they will alter the apphash
if ctx.BlockHeight() < 3 || ctx.IsOnUpgradeHeight() {
if !ContainsString(AdditionalParametersKeys, (string)(pair.Key)) {
s.Set(ctx, pair.Key, v)
}
} else {
s.Set(ctx, pair.Key, v)

}
}
}

Expand Down
9 changes: 9 additions & 0 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,12 @@ func TimeTrack(start time.Time) {
log.Println(fmt.Sprintf("%s took %s", name, elapsed))
}
}

func ContainsString(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
8 changes: 8 additions & 0 deletions x/nodes/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func NewHandler(k keeper.Keeper) sdk.Handler {

func handleStake(ctx sdk.Ctx, msg types.MsgStake, k keeper.Keeper, signer crypto.PublicKey) sdk.Result {
defer sdk.TimeTrack(time.Now())

if k.Cdc.IsAfterNonCustodialUpgrade(ctx.BlockHeight()) {
err := msg.CheckServiceUrlLength(msg.ServiceUrl)
if err != nil {
return err.Result()
}
}

pk := msg.PublicKey
addr := pk.Address()
// create validator object using the message fields
Expand Down
9 changes: 6 additions & 3 deletions x/nodes/keeper/reward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ func TestKeeper_rewardFromRelaysPIP22NoEXP(t *testing.T) {
validator4 types.Validator
}

codec.UpgradeFeatureMap[codec.RSCALKey] = -1
codec.UpgradeFeatureMap[codec.RSCALKey] = 3
context, _, keeper := createTestInput(t, true)
context = context.WithBlockHeight(3)
p := keeper.GetParams(context)
p.ServicerStakeFloorMultiplier = types.DefaultServicerStakeFloorMultiplier
p.ServicerStakeWeightMultiplier = types.DefaultServicerStakeWeightMultiplier
Expand Down Expand Up @@ -282,8 +283,9 @@ func TestKeeper_checkPIP22CheckCeiling(t *testing.T) {
validator2 types.Validator
}

codec.UpgradeFeatureMap[codec.RSCALKey] = -1
codec.UpgradeFeatureMap[codec.RSCALKey] = 3
context, _, keeper := createTestInput(t, true)
context = context.WithBlockHeight(3)
p := keeper.GetParams(context)
p.ServicerStakeFloorMultiplier = types.DefaultServicerStakeFloorMultiplier
p.ServicerStakeWeightMultiplier = types.DefaultServicerStakeWeightMultiplier
Expand Down Expand Up @@ -343,8 +345,9 @@ func TestKeeper_rewardFromRelaysPIP22EXP(t *testing.T) {
validator4 types.Validator
}

codec.UpgradeFeatureMap[codec.RSCALKey] = -1
codec.UpgradeFeatureMap[codec.RSCALKey] = 3
context, _, keeper := createTestInput(t, true)
context = context.WithBlockHeight(3)
p := keeper.GetParams(context)
p.ServicerStakeFloorMultiplier = types.DefaultServicerStakeFloorMultiplier
p.ServicerStakeWeightMultiplier = types.DefaultServicerStakeWeightMultiplier
Expand Down
7 changes: 7 additions & 0 deletions x/nodes/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ func (msg MsgStake) ToProto() MsgProtoStake {
}
}

func (msg MsgStake) CheckServiceUrlLength(url string) sdk.Error {
if len(url) > 255 {
return ErrInvalidServiceURL(DefaultCodespace, fmt.Errorf("url too long"))
}
return nil
}

func (*MsgProtoStake) XXX_MessageName() string {
return "x.nodes.MsgProtoStake8"
}
Expand Down
3 changes: 0 additions & 3 deletions x/nodes/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func ValidateServiceURL(u string) sdk.Error {
if !strings.Contains(u, period) {
return ErrInvalidServiceURL(ModuleName, fmt.Errorf("must contain one '.'"))
}
if len(u) > 255 {
return ErrInvalidServiceURL(ModuleName, fmt.Errorf("url too long"))
}

return nil
}
Expand Down

0 comments on commit 08df721

Please sign in to comment.