Skip to content

Commit cb6f067

Browse files
committed
chore(migrations): remove temporary patch from v3 to v4 storage migration
1 parent 678b5d7 commit cb6f067

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

node/src/storage_mngr/node_migrations.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,20 @@ fn migrate_chain_state_v3_to_v4(old_chain_state_bytes: &[u8]) -> Vec<u8> {
6262
let db_version: u32 = 4;
6363
let db_version_bytes = db_version.to_le_bytes();
6464

65-
// This little trick makes sure that we don't run a migration on a v4 chain state that was
66-
// incorrectly tagged as v3 in the context of a development release, by checking if the bytes
67-
// match a pattern where the environment enum is stored at a certain position
68-
if old_chain_state_bytes[5..9] == [0x02, 0x00, 0x00, 0x00] {
69-
// Extra fields in ChainState v4:
70-
let protocol_info = ProtocolInfo::default();
71-
let protocol_info_bytes = serialize(&protocol_info).unwrap();
72-
let stakes = StakesTracker::default();
73-
let stakes_bytes = serialize(&stakes).unwrap();
74-
75-
[
76-
&db_version_bytes,
77-
&old_chain_state_bytes[4..5],
78-
&protocol_info_bytes,
79-
&old_chain_state_bytes[5..],
80-
&stakes_bytes,
81-
]
82-
.concat()
83-
} else {
84-
[&db_version_bytes, &old_chain_state_bytes[4..]].concat()
85-
}
65+
// Extra fields in ChainState v4:
66+
let protocol_info = ProtocolInfo::default();
67+
let protocol_info_bytes = serialize(&protocol_info).unwrap();
68+
let stakes = StakesTracker::default();
69+
let stakes_bytes = serialize(&stakes).unwrap();
70+
71+
[
72+
&db_version_bytes,
73+
&old_chain_state_bytes[4..5],
74+
&protocol_info_bytes,
75+
&old_chain_state_bytes[5..],
76+
&stakes_bytes,
77+
]
78+
.concat()
8679
}
8780

8881
fn migrate_chain_state(mut bytes: Vec<u8>) -> Result<ChainState, failure::Error> {

0 commit comments

Comments
 (0)