mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 00:17:27 +00:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									1a51d1fb00
								
							
						
					
					
						commit
						4426ca3c0c
					
				@ -37,5 +37,12 @@ func Migrate(genDoc *tmtypes.GenesisDoc, ctx client.Context) (*tmtypes.GenesisDo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	genDoc.GenesisTime = GenesisTime
 | 
						genDoc.GenesisTime = GenesisTime
 | 
				
			||||||
	genDoc.ChainID = ChainID
 | 
						genDoc.ChainID = ChainID
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						genDoc.InitialHeight = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						genDoc.ConsensusParams.Version.AppVersion = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						genDoc.ConsensusParams.Evidence.MaxBytes = 50000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return genDoc, nil
 | 
						return genDoc, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -30,11 +30,16 @@ func TestMigrateGenesisDoc(t *testing.T) {
 | 
				
			|||||||
	expected := getTestDataJSON("genesis-v16.json")
 | 
						expected := getTestDataJSON("genesis-v16.json")
 | 
				
			||||||
	genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v15.json"))
 | 
						genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v15.json"))
 | 
				
			||||||
	assert.NoError(t, err)
 | 
						assert.NoError(t, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	actualGenDoc, err := Migrate(genDoc, newClientContext())
 | 
						actualGenDoc, err := Migrate(genDoc, newClientContext())
 | 
				
			||||||
	assert.NoError(t, err)
 | 
						assert.NoError(t, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	actualJson, err := tmjson.Marshal(actualGenDoc)
 | 
						actualJson, err := tmjson.Marshal(actualGenDoc)
 | 
				
			||||||
	assert.NoError(t, err)
 | 
						assert.NoError(t, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert.JSONEq(t, expected, string(actualJson))
 | 
						assert.JSONEq(t, expected, string(actualJson))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						assert.LessOrEqual(t, actualGenDoc.ConsensusParams.Evidence.MaxBytes, actualGenDoc.ConsensusParams.Block.MaxBytes)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMigrateFull(t *testing.T) {
 | 
					func TestMigrateFull(t *testing.T) {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								migrate/v0_16/testdata/genesis-v16.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								migrate/v0_16/testdata/genesis-v16.json
									
									
									
									
										vendored
									
									
								
							@ -10,10 +10,13 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    "evidence": {
 | 
					    "evidence": {
 | 
				
			||||||
      "max_age_num_blocks": "100000",
 | 
					      "max_age_num_blocks": "100000",
 | 
				
			||||||
      "max_age_duration": "172800000000000"
 | 
					      "max_age_duration": "172800000000000",
 | 
				
			||||||
 | 
					      "max_bytes": "50000"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "validator": { "pub_key_types": ["ed25519"] },
 | 
					    "validator": { "pub_key_types": ["ed25519"] },
 | 
				
			||||||
    "version": {}
 | 
					    "version": {
 | 
				
			||||||
 | 
					      "app_version": "1"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "app_hash": "",
 | 
					  "app_hash": "",
 | 
				
			||||||
  "app_state": {
 | 
					  "app_state": {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user