From 42bd9d6b327f52df570e46bd3cca9188d46b26e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 18 Jan 2024 14:49:20 +0100 Subject: [PATCH] pallet-contracts: Fix compilation on latest nightly Apparently they changed detection for visibility identifiers on traits, which broke more than it should. There is an issue open: https://github.com/rust-lang/rust/issues/119924 The easy solution for us is to move the declaration of the global variable outside of the trait. Closes: https://github.com/paritytech/polkadot-sdk/issues/2960 --- substrate/frame/contracts/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index a15006e6388c..533085f2b874 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -1228,6 +1228,9 @@ struct InternalOutput { result: Result, } +// Set up a global reference to the boolean flag used for the re-entrancy guard. +environmental!(executing_contract: bool); + /// Helper trait to wrap contract execution entry points into a single function /// [`Invokable::run_guarded`]. trait Invokable: Sized { @@ -1243,9 +1246,6 @@ trait Invokable: Sized { /// We enforce a re-entrancy guard here by initializing and checking a boolean flag through a /// global reference. fn run_guarded(self, common: CommonInput) -> InternalOutput { - // Set up a global reference to the boolean flag used for the re-entrancy guard. - environmental!(executing_contract: bool); - let gas_limit = common.gas_limit; // Check whether the origin is allowed here. The logic of the access rules