From 635561b0c898d867f522db3380454ba78d992806 Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Tue, 4 Apr 2023 23:28:15 +0100 Subject: [PATCH] [loader] Fix linker/loader backward compatibility (#10409) ## Description When running with backward compatibility enabled, we were incorrectly returning 0x0 as the original package ID for packages, and then passing that in as the package ID for the function being called, which caused an error when we tried to fetch a package at that address. ## Test Plan Re-sync fullnode with testnet, running the new node software, previously it was forking immediately, now it works fine. --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [x] breaking change for FNs (FN binary must upgrade) - [x] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --- crates/sui-adapter/src/programmable_transactions/context.rs | 2 +- .../src/programmable_transactions/linkage_view.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/sui-adapter/src/programmable_transactions/context.rs b/crates/sui-adapter/src/programmable_transactions/context.rs index 32d8e21e34ba9..c744bda4772a7 100644 --- a/crates/sui-adapter/src/programmable_transactions/context.rs +++ b/crates/sui-adapter/src/programmable_transactions/context.rs @@ -217,7 +217,7 @@ impl<'vm, 'state, 'a, 'b, S: StorageView> ExecutionContext<'vm, 'state, 'a, 'b, let resolver = self.session.get_resolver(); if resolver.has_linkage(package_id) { // Setting same context again, can skip. - return Ok(resolver.original_package_id()); + return Ok(resolver.original_package_id().unwrap_or(*package_id)); } let package = diff --git a/crates/sui-adapter/src/programmable_transactions/linkage_view.rs b/crates/sui-adapter/src/programmable_transactions/linkage_view.rs index 045b2234ef450..508b36147474d 100644 --- a/crates/sui-adapter/src/programmable_transactions/linkage_view.rs +++ b/crates/sui-adapter/src/programmable_transactions/linkage_view.rs @@ -183,11 +183,11 @@ impl<'state, S: StorageView> LinkageView<'state, S> { self.state_view } - pub fn original_package_id(&self) -> AccountAddress { + pub fn original_package_id(&self) -> Option { if let LinkageInfo::Set(linkage) = &self.linkage_info { - linkage.runtime_id + Some(linkage.runtime_id) } else { - AccountAddress::ZERO + None } }