From 4426ca3c0c482e4b16a9d21fbb7f1e270f9a4a9c Mon Sep 17 00:00:00 2001 From: Derrick Lee Date: Fri, 14 Jan 2022 14:56:57 -0800 Subject: [PATCH] Add initial height, app version, evidence maxbytes to migration (#1134) * Add initial height, app version, evidence maxbytes * Update Evidence.MaxBytes to 50000 * Add test for Evidence.MaxBytes <= Block.MaxBytes --- migrate/v0_16/migrate.go | 7 +++++++ migrate/v0_16/migrate_test.go | 5 +++++ migrate/v0_16/testdata/genesis-v16.json | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/migrate/v0_16/migrate.go b/migrate/v0_16/migrate.go index 9725e632..d786b254 100644 --- a/migrate/v0_16/migrate.go +++ b/migrate/v0_16/migrate.go @@ -37,5 +37,12 @@ func Migrate(genDoc *tmtypes.GenesisDoc, ctx client.Context) (*tmtypes.GenesisDo genDoc.GenesisTime = GenesisTime genDoc.ChainID = ChainID + + genDoc.InitialHeight = 1 + + genDoc.ConsensusParams.Version.AppVersion = 1 + + genDoc.ConsensusParams.Evidence.MaxBytes = 50000 + return genDoc, nil } diff --git a/migrate/v0_16/migrate_test.go b/migrate/v0_16/migrate_test.go index e7a8bc06..de979e96 100644 --- a/migrate/v0_16/migrate_test.go +++ b/migrate/v0_16/migrate_test.go @@ -30,11 +30,16 @@ func TestMigrateGenesisDoc(t *testing.T) { expected := getTestDataJSON("genesis-v16.json") genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v15.json")) assert.NoError(t, err) + actualGenDoc, err := Migrate(genDoc, newClientContext()) assert.NoError(t, err) + actualJson, err := tmjson.Marshal(actualGenDoc) assert.NoError(t, err) + assert.JSONEq(t, expected, string(actualJson)) + + assert.LessOrEqual(t, actualGenDoc.ConsensusParams.Evidence.MaxBytes, actualGenDoc.ConsensusParams.Block.MaxBytes) } func TestMigrateFull(t *testing.T) { diff --git a/migrate/v0_16/testdata/genesis-v16.json b/migrate/v0_16/testdata/genesis-v16.json index 2de38997..d484eb04 100644 --- a/migrate/v0_16/testdata/genesis-v16.json +++ b/migrate/v0_16/testdata/genesis-v16.json @@ -10,10 +10,13 @@ }, "evidence": { "max_age_num_blocks": "100000", - "max_age_duration": "172800000000000" + "max_age_duration": "172800000000000", + "max_bytes": "50000" }, "validator": { "pub_key_types": ["ed25519"] }, - "version": {} + "version": { + "app_version": "1" + } }, "app_hash": "", "app_state": {