diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a77ca824997..5d5f394a568 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ variables: CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" # CI_IMAGE is changed to "-:staging" when the CI image gets rebuilt # read more https://github.com/paritytech/scripts/pull/244 - CI_IMAGE: "paritytech/ink-ci-linux:production" + CI_IMAGE: "paritytech/ink-ci-linux:staging" PURELY_STD_CRATES: "ink/codegen metadata engine" ALSO_WASM_CRATES: "env storage storage/traits allocator prelude primitives ink ink/macro ink/ir" ALL_CRATES: "${PURELY_STD_CRATES} ${ALSO_WASM_CRATES}" diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 36fccda7f57..9d5282bea85 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -75,11 +75,32 @@ pub struct Call { data: Vec, } +#[derive( + Debug, Clone, Copy, scale::Encode, scale::Decode, PartialEq, Eq, serde::Serialize, +)] +pub enum Determinism { + /// The execution should be deterministic and hence no indeterministic instructions are + /// allowed. + /// + /// Dispatchables always use this mode in order to make on-chain execution deterministic. + Deterministic, + /// Allow calling or uploading an indeterministic code. + /// + /// This is only possible when calling into `pallet-contracts` directly via + /// [`crate::Pallet::bare_call`]. + /// + /// # Note + /// + /// **Never** use this mode for on-chain execution. + AllowIndeterminism, +} + /// A raw call to `pallet-contracts`'s `upload`. #[derive(Debug, scale::Encode, scale::Decode)] pub struct UploadCode { code: Vec, storage_deposit_limit: Option, + determinism: Determinism, } /// A struct that encodes RPC parameters required to instantiate a new smart contract. @@ -105,6 +126,7 @@ where origin: C::AccountId, code: Vec, storage_deposit_limit: Option, + determinism: Determinism, } /// A struct that encodes RPC parameters required for a call to a smart contract. @@ -278,6 +300,7 @@ where origin: signer.account_id().clone(), code, storage_deposit_limit, + determinism: Determinism::Deterministic, }; let func = "ContractsApi_upload_code"; let params = rpc_params![func, Bytes(scale::Encode::encode(&call_request))]; @@ -308,6 +331,7 @@ where UploadCode:: { code, storage_deposit_limit, + determinism: Determinism::Deterministic, }, Default::default(), ) diff --git a/crates/ink/tests/ui/contract/fail/message-hygiene-checked.stderr b/crates/ink/tests/ui/contract/fail/message-hygiene-checked.stderr index cce9b1f97a6..8e64a7e9f8c 100644 --- a/crates/ink/tests/ui/contract/fail/message-hygiene-checked.stderr +++ b/crates/ink/tests/ui/contract/fail/message-hygiene-checked.stderr @@ -1,8 +1,8 @@ -error[E0201]: duplicate definitions with name `message_checked`: +error[E0592]: duplicate definitions with name `message_checked` --> tests/ui/contract/fail/message-hygiene-checked.rs:16:9 | 1 | #[ink::contract] - | ---------------- previous definition of `message_checked` here + | ---------------- other definition for `message_checked` ... 16 | pub fn message_checked(&self) {} - | ^^^ duplicate definition + | ^^^ duplicate definitions for `message_checked` diff --git a/examples/flipper/lib.rs b/examples/flipper/lib.rs index 58f191054d6..14f4f39b042 100644 --- a/examples/flipper/lib.rs +++ b/examples/flipper/lib.rs @@ -16,7 +16,7 @@ pub mod flipper { /// Creates a new flipper smart contract initialized to `false`. #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(Default::default()) } @@ -39,7 +39,7 @@ pub mod flipper { #[ink::test] fn default_works() { - let flipper = Flipper::default(); + let flipper = Flipper::new_default(); assert!(!flipper.get()); } diff --git a/examples/incrementer/lib.rs b/examples/incrementer/lib.rs index 2a2699963ae..bc232aeab40 100644 --- a/examples/incrementer/lib.rs +++ b/examples/incrementer/lib.rs @@ -14,7 +14,7 @@ mod incrementer { } #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(Default::default()) } @@ -35,7 +35,7 @@ mod incrementer { #[ink::test] fn default_works() { - let contract = Incrementer::default(); + let contract = Incrementer::new_default(); assert_eq!(contract.get(), 0); } diff --git a/examples/lang-err-integration-tests/call-builder/lib.rs b/examples/lang-err-integration-tests/call-builder/lib.rs index b09258a7915..5459e33548a 100755 --- a/examples/lang-err-integration-tests/call-builder/lib.rs +++ b/examples/lang-err-integration-tests/call-builder/lib.rs @@ -104,7 +104,7 @@ mod call_builder { .expect("instantiate failed") .account_id; - let flipper_constructor = FlipperRef::default(); + let flipper_constructor = FlipperRef::new_default(); let flipper_acc_id = client .instantiate( "integration_flipper", diff --git a/examples/lang-err-integration-tests/contract-ref/lib.rs b/examples/lang-err-integration-tests/contract-ref/lib.rs index af9119f0006..9ab9ec45ab3 100755 --- a/examples/lang-err-integration-tests/contract-ref/lib.rs +++ b/examples/lang-err-integration-tests/contract-ref/lib.rs @@ -13,7 +13,7 @@ mod contract_ref { #[ink(constructor)] pub fn new(version: u32, flipper_code_hash: Hash) -> Self { let salt = version.to_le_bytes(); - let flipper = FlipperRef::default() + let flipper = FlipperRef::new_default() .endowment(0) .code_hash(flipper_code_hash) .salt_bytes(salt) diff --git a/examples/lang-err-integration-tests/integration-flipper/lib.rs b/examples/lang-err-integration-tests/integration-flipper/lib.rs index bae9853ae8f..c000ad24802 100644 --- a/examples/lang-err-integration-tests/integration-flipper/lib.rs +++ b/examples/lang-err-integration-tests/integration-flipper/lib.rs @@ -21,7 +21,7 @@ pub mod integration_flipper { /// Creates a new integration_flipper smart contract initialized to `false`. #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(Default::default()) } @@ -58,7 +58,7 @@ pub mod integration_flipper { async fn e2e_can_flip_correctly( mut client: ink_e2e::Client, ) -> E2EResult<()> { - let constructor = FlipperRef::default(); + let constructor = FlipperRef::new_default(); let contract_acc_id = client .instantiate( "integration_flipper", @@ -110,7 +110,7 @@ pub mod integration_flipper { async fn e2e_message_error_reverts_state( mut client: ink_e2e::Client, ) -> E2EResult<()> { - let constructor = FlipperRef::default(); + let constructor = FlipperRef::new_default(); let contract_acc_id = client .instantiate("integration_flipper", &ink_e2e::bob(), constructor, 0, None) .await diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index e0dfcbb2df8..14207c5c169 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -146,7 +146,7 @@ mod mother { } #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Default::default() } @@ -197,7 +197,7 @@ mod mother { #[ink::test] fn echo_auction_works() { let auction = Auction::default(); - let mut contract = Mother::default(); + let mut contract = Mother::new_default(); assert_eq!(contract.echo_auction(auction.clone()), auction); } diff --git a/examples/rand-extension/lib.rs b/examples/rand-extension/lib.rs index 5dc4f0a3318..8585f4cf305 100755 --- a/examples/rand-extension/lib.rs +++ b/examples/rand-extension/lib.rs @@ -80,7 +80,7 @@ mod rand_extension { /// /// Constructors may delegate to other constructors. #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(Default::default()) } @@ -114,7 +114,7 @@ mod rand_extension { /// We test if the default constructor does its job. #[ink::test] fn default_works() { - let rand_extension = RandExtension::default(); + let rand_extension = RandExtension::new_default(); assert_eq!(rand_extension.get(), [0; 32]); } @@ -141,7 +141,7 @@ mod rand_extension { } } ink::env::test::register_chain_extension(MockedExtension); - let mut rand_extension = RandExtension::default(); + let mut rand_extension = RandExtension::new_default(); assert_eq!(rand_extension.get(), [0; 32]); // when diff --git a/examples/upgradeable-contracts/set-code-hash/lib.rs b/examples/upgradeable-contracts/set-code-hash/lib.rs index 3708f29e336..ac900f0d494 100644 --- a/examples/upgradeable-contracts/set-code-hash/lib.rs +++ b/examples/upgradeable-contracts/set-code-hash/lib.rs @@ -19,7 +19,7 @@ pub mod incrementer { /// Creates a new counter smart contract initialized to `0`. #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(0) } diff --git a/examples/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs b/examples/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs index 7afd26e2af7..8f5f054d45e 100644 --- a/examples/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs +++ b/examples/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs @@ -24,7 +24,7 @@ pub mod incrementer { /// Creates a new counter smart contract initialized to `0`. #[ink(constructor)] - pub fn default() -> Self { + pub fn new_default() -> Self { Self::new(0) }