Skip to content

Commit 895b850

Browse files
committed
Guard updating of registers identifier by ConsensusVersion::V12
1 parent f97936a commit 895b850

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

console/network/src/consensus_heights.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum ConsensusVersion {
4545
V10 = 10,
4646
/// V11: Expand array size limit to 512 and introduce ECDSA signature verification opcodes.
4747
V11 = 11,
48-
/// V12: Prevent connection to forked nodes.
48+
/// V12: Prevent connection to forked nodes, update FinalizeRegisters function_name for constructors.
4949
V12 = 12,
5050
}
5151

synthesizer/process/src/finalize.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,14 @@ fn finalize_constructor<N: Network, P: FinalizeStorage<N>>(
240240
// Get the constructor types.
241241
let constructor_types = stack.get_constructor_types()?.clone();
242242

243-
let identifier = Identifier::<N>::from_str("constructor")?;
243+
// Set the FinalizeRegisters function name for constructors.
244+
// Before ConsensusVersion::V12, this was wrongly using the program id as function name.
245+
let consensus_version = N::CONSENSUS_VERSION(state.block_height())?;
246+
let identifier = if consensus_version >= ConsensusVersion::V12 {
247+
Identifier::<N>::from_str("constructor")?
248+
} else {
249+
*stack.program_id().name()
250+
};
244251

245252
// Initialize the finalize registers.
246253
let mut registers = FinalizeRegisters::new(state, transition_id, identifier, constructor_types, nonce);

0 commit comments

Comments
 (0)