Skip to content

Commit

Permalink
Merge pull request #1818 from radixdlt/feature/update-system-field-kind
Browse files Browse the repository at this point in the history
Update SystemFieldKind to be backward compatible
  • Loading branch information
iamyulong authored May 20, 2024
2 parents 5bf2177 + cbd296e commit 7a8a340
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion radix-engine-interface/src/types/node_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sbor::rust::prelude::*;
pub const BOOT_LOADER_PARTITION: PartitionNumber = PartitionNumber(32u8);

#[repr(u8)]
#[derive(Debug, Copy, Clone, Sbor, PartialEq, Eq, Hash, PartialOrd, Ord, FromRepr)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, FromRepr)]
pub enum BootLoaderField {
KernelBoot = 0,
SystemBoot = 1,
Expand Down
24 changes: 9 additions & 15 deletions radix-engine/src/transaction/system_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@ pub struct SystemFieldStructure {
// for the toolkit which parses it opaquely at the moment when doing transaction preview
// in the wallet. This change doesn't apply because BootLoader substates are only edited
// during transaction preview.
//
// Node depends on this structure, so append only.
#[derive(Debug, Clone, ScryptoSbor, PartialEq, Eq)]
pub enum SystemFieldKind {
TypeInfo,
BootLoader(BootLoaderFieldKind),
}

#[derive(Clone, Debug, ScryptoSbor, PartialEq, Eq)]
pub enum BootLoaderFieldKind {
KernelBoot,
SystemBoot,
VmBoot,
SystemBoot,
KernelBoot,
}

#[derive(Debug, Clone, ScryptoSbor, PartialEq, Eq)]
Expand Down Expand Up @@ -234,15 +231,12 @@ impl<'a, S: SubstateDatabase> SubstateSchemaMapper<'a, S> {
let field_num = key
.for_field()
.expect("BootLoader substates are expected to be fields");
let kind = match *field_num {
BOOT_LOADER_KERNEL_BOOT_FIELD_KEY => BootLoaderFieldKind::KernelBoot,
BOOT_LOADER_SYSTEM_SUBSTATE_FIELD_KEY => {
BootLoaderFieldKind::SystemBoot
}
BOOT_LOADER_VM_BOOT_FIELD_KEY => BootLoaderFieldKind::VmBoot,
match *field_num {
BOOT_LOADER_KERNEL_BOOT_FIELD_KEY => SystemFieldKind::KernelBoot,
BOOT_LOADER_SYSTEM_SUBSTATE_FIELD_KEY => SystemFieldKind::SystemBoot,
BOOT_LOADER_VM_BOOT_FIELD_KEY => SystemFieldKind::VmBoot,
field_num => panic!("Unknown boot loader field kind: {field_num}"),
};
SystemFieldKind::BootLoader(kind)
}
},
})
}
Expand Down
6 changes: 3 additions & 3 deletions radix-engine/src/transaction/transaction_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,14 @@ fn format_substate_value<'a, F: fmt::Write>(
SystemFieldKind::TypeInfo => {
(TYPE_INFO_SUBSTATE_SCHEMA.0, &TYPE_INFO_SUBSTATE_SCHEMA.1)
}
SystemFieldKind::BootLoader(BootLoaderFieldKind::VmBoot) => {
SystemFieldKind::VmBoot => {
(VM_BOOT_SUBSTATE_SCHEMA.0, &VM_BOOT_SUBSTATE_SCHEMA.1)
}
SystemFieldKind::BootLoader(BootLoaderFieldKind::SystemBoot) => (
SystemFieldKind::SystemBoot => (
SYSTEM_BOOT_SUBSTATE_SCHEMA.0,
&SYSTEM_BOOT_SUBSTATE_SCHEMA.1,
),
SystemFieldKind::BootLoader(BootLoaderFieldKind::KernelBoot) => (
SystemFieldKind::KernelBoot => (
KERNEL_BOOT_SUBSTATE_SCHEMA.0,
&KERNEL_BOOT_SUBSTATE_SCHEMA.1,
),
Expand Down

0 comments on commit 7a8a340

Please sign in to comment.