Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use frame_support::{
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned, EnsureWithSuccess,
EnsureNever, EnsureRoot, EnsureSigned, EnsureWithSuccess,
};
use pallet_ethereum::PostLogContent;
use pallet_evm::{FeeCalculator, GasWeightMapping, Runner};
Expand Down Expand Up @@ -791,8 +791,8 @@ impl pallet_contracts::Config for Runtime {
type Environment = ();
type Migrations = ();
type Xcm = ();
type UploadOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type UploadOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}
Expand Down
6 changes: 3 additions & 3 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use frame_support::{
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned, EnsureWithSuccess,
EnsureNever, EnsureRoot, EnsureSigned, EnsureWithSuccess,
};
use pallet_ethereum::PostLogContent;
use pallet_evm::{FeeCalculator, GasWeightMapping, Runner};
Expand Down Expand Up @@ -789,8 +789,8 @@ impl pallet_contracts::Config for Runtime {
type Environment = ();
type Migrations = ();
type Xcm = ();
type UploadOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type UploadOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}
Expand Down
6 changes: 3 additions & 3 deletions runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use frame_support::{
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned,
EnsureNever, EnsureRoot, EnsureSigned,
};
use pallet_ethereum::PostLogContent;
use pallet_evm::{FeeCalculator, GasWeightMapping, Runner};
Expand Down Expand Up @@ -756,8 +756,8 @@ impl pallet_contracts::Config for Runtime {
type Environment = ();
type Migrations = ();
type Xcm = ();
type UploadOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type UploadOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureNever<<Self as frame_system::Config>::AccountId>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}
Expand Down
74 changes: 74 additions & 0 deletions tests/integration/src/contracts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// This file is part of Astar.

// Copyright (C) Stake Technologies Pte.Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later

// Astar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Astar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

use crate::setup::*;
use sp_runtime::DispatchError;

/// New WASM code uploads are frozen.
#[test]
fn upload_code_is_disabled() {
new_test_ext().execute_with(|| {
assert_noop!(
Contracts::upload_code(
RuntimeOrigin::signed(ALICE),
vec![],
None,
pallet_contracts::Determinism::Enforced,
),
DispatchError::BadOrigin,
);
});
}

/// Deploying a new contract with inline code is frozen.
#[test]
fn instantiate_with_code_is_disabled() {
new_test_ext().execute_with(|| {
assert_noop!(
Contracts::instantiate_with_code(
RuntimeOrigin::signed(ALICE),
0u128,
Weight::zero(),
None,
vec![],
vec![],
vec![],
),
DispatchError::BadOrigin,
);
});
}

/// Instantiating from an existing code hash is frozen.
#[test]
fn instantiate_is_disabled() {
new_test_ext().execute_with(|| {
assert_noop!(
Contracts::instantiate(
RuntimeOrigin::signed(ALICE),
0u128,
Weight::zero(),
None,
Default::default(),
vec![],
vec![],
),
DispatchError::BadOrigin,
);
});
}
3 changes: 3 additions & 0 deletions tests/integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ mod proxy;
#[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))]
mod assets;

#[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))]
mod contracts;

#[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))]
mod dispatch_precompile_filter;

Expand Down
Loading