{"record":{"id":"c740c735f28a1930","repo":"datahaven-xyz/datahaven","slug":"invalidupgradeparameters-c740c7","errorCode":"InvalidUpgradeParameters","errorMessage":"InvalidUpgradeParameters","messagePattern":"InvalidUpgradeParameters","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"operator/pallets/system/src/lib.rs","lineNumber":281,"sourceCode":"        /// contract\n        ///\n        /// Fee required: No\n        ///\n        /// - `origin`: Must be `Root`.\n        /// - `impl_address`: The address of the implementation contract.\n        /// - `impl_code_hash`: The codehash of the implementation contract.\n        /// - `initializer`: Optionally call an initializer on the implementation contract.\n        #[pallet::call_index(0)]\n        #[pallet::weight((T::WeightInfo::upgrade(), DispatchClass::Operational))]\n        pub fn upgrade(\n            origin: OriginFor<T>,\n            impl_address: H160,\n            impl_code_hash: H256,\n            initializer: Option<Initializer>,\n        ) -> DispatchResult {\n            ensure_root(origin)?;\n\n            ensure!(\n                !impl_address.eq(&H160::zero()) && !impl_code_hash.eq(&H256::zero()),\n                Error::<T>::InvalidUpgradeParameters\n            );\n\n            let initializer_params_hash: Option<H256> = initializer\n                .as_ref()\n                .map(|i| H256::from(blake2_256(i.params.as_ref())));\n            let command = Command::Upgrade {\n                impl_address,\n                impl_code_hash,\n                initializer,\n            };\n            Self::send(PRIMARY_GOVERNANCE_CHANNEL, command, PaysFee::<T>::No)?;\n\n            Self::deposit_event(Event::<T>::Upgrade {\n                impl_address,\n                impl_code_hash,\n                initializer_params_hash,","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/datahaven-xyz/datahaven/blob/edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec/operator/pallets/system/src/lib.rs#L263-L299","documentation":"The legacy system pallet's `upgrade` extrinsic throws `Error::InvalidUpgradeParameters` under the same rule as system-v2: `impl_address` or `impl_code_hash` must not be zero. This variant uses `ensure_root` instead of a governance origin, but rejects zeroed upgrade targets to prevent bricking the system contract.","triggerScenarios":"Calling `upgrade(origin, impl_address, impl_code_hash, initializer)` with sudo/root origin while `impl_address == H160::zero()` or `impl_code_hash == H256::zero()`.","commonSituations":"Sudo scripts passing default/placeholder H160::zero() or H256::zero() because the implementation contract was never deployed; copy-pasted upgrade calls with zeroed fields; test fixtures forgetting to fill in real deployment artifacts.","solutions":["Deploy the new implementation and pass its actual address and keccak code hash.","Add pre-dispatch validation in the sudo script: fail fast if either value is zero.","Double-check call argument order when encoding the extrinsic."],"exampleFix":"// before\nSystem::upgrade(sudo_origin, H160::zero(), impl_code_hash, None)?;\n\n// after\nlet addr = H160::from_slice(&deployed_address_bytes);\nassert!(!addr.is_zero() && !impl_code_hash.is_zero());\nSystem::upgrade(sudo_origin, addr, impl_code_hash, None)?;","handlingStrategy":"validation","validationCode":"if (implAddress === H160::zero() || implCodeHash === H256::zero()) { bail!(\"zero upgrade target\"); }","typeGuard":"fn is_valid_upgrade_target(addr: H160, hash: H256) -> bool { !addr.is_zero() && !hash.is_zero() }","tryCatchPattern":"match System::upgrade(sudo_origin, impl_address, impl_code_hash, initializer) { Err(Error::InvalidUpgradeParameters) => { eprintln!(\"zeroed impl params\"); abort(); }, r => r? }","preventionTips":["Deploy first, upgrade second — never hand-craft zero placeholders","Unit-test sudo upgrade scripts with real artifacts","Assert non-zero values before encode/dispatch","Rehearse upgrades on stagenet with identical scripts"],"tags":["substrate","sudo","upgrade","zero-address","system-contract"],"backgroundTag":"invalid-argument-value","analyzedSha":"edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec","analyzedAt":"2026-09-13T19:19:32.206Z","contentChangedAt":"2026-09-13T19:19:32.206Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}