Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts: use compiled rust tests #2347

Merged
merged 84 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
50d39a6
Add uapi and tests-contracts pallets
pgherveou Nov 15, 2023
5396bf6
wip
pgherveou Nov 15, 2023
2fbc2c3
Add prelude
pgherveou Nov 15, 2023
c2712f2
Add build.rs file
pgherveou Nov 17, 2023
b6dbd52
fmt
pgherveou Nov 17, 2023
28bc1e2
nit
pgherveou Nov 17, 2023
c396af7
fix
pgherveou Nov 17, 2023
974f33c
fixes
pgherveou Nov 17, 2023
03910c7
Update substrate/frame/contracts/fixtures/build.rs
pgherveou Nov 17, 2023
c4a8bb6
nit
pgherveou Nov 17, 2023
4f895ec
rm dummy.wat
pgherveou Nov 17, 2023
ce4f1ed
fixes
pgherveou Nov 17, 2023
ccbd83e
fix
pgherveou Nov 17, 2023
9016b63
fix
pgherveou Nov 17, 2023
f02512e
test
pgherveou Nov 17, 2023
11990ce
use encoded rust_flags
pgherveou Nov 17, 2023
46c4844
Update substrate/frame/contracts/fixtures/contracts/dummy.rs
pgherveou Nov 17, 2023
d0e18a1
Update substrate/frame/contracts/fixtures/Cargo.toml
pgherveou Nov 17, 2023
0cd6b90
Review part 1
pgherveou Nov 17, 2023
01550ba
Clean up Ptr stuff
pgherveou Nov 17, 2023
eb61dd7
smarter hashing
pgherveou Nov 17, 2023
a539a87
cleanup warnings
pgherveou Nov 17, 2023
2d321fd
add common
pgherveou Nov 17, 2023
2eb6227
Merge branch 'master' into pg/contracts_rust_tests
pgherveou Nov 18, 2023
697f7e1
clippy fix
pgherveou Nov 18, 2023
8da3043
fix clippy 2
pgherveou Nov 18, 2023
d9889e1
rm missing ink! stuff
pgherveou Nov 18, 2023
fe32a96
add back rm code
pgherveou Nov 20, 2023
a4451fc
Add call.wat
pgherveou Nov 20, 2023
db39e91
Adds Api trait
pgherveou Nov 21, 2023
68430f9
Refactoring primitives & uapi
pgherveou Nov 21, 2023
dad8fec
Move types to uapi and add docs
pgherveou Nov 22, 2023
cf47609
update call.rs
pgherveou Nov 22, 2023
a98e7af
fix lints
pgherveou Nov 22, 2023
213a01f
fix sys funcs
pgherveou Nov 24, 2023
eefde89
sort & clean up
pgherveou Nov 24, 2023
89aa067
fix fixture
pgherveou Nov 24, 2023
47fba86
Fix doc tests
pgherveou Nov 24, 2023
6cfb441
fix comments
pgherveou Nov 24, 2023
d999682
fix cargo doc links
pgherveou Nov 24, 2023
3336bb6
Compile with warning flags
pgherveou Nov 24, 2023
ea67819
fix some doc
pgherveou Nov 24, 2023
b976c17
add more docs
pgherveou Nov 24, 2023
09e8a59
fix runtime-benchmarks build
pgherveou Nov 24, 2023
84ba07b
Fix substrate-node
pgherveou Nov 24, 2023
153fe9f
fix dep
pgherveou Nov 24, 2023
56c6f25
fix primitives
pgherveou Nov 24, 2023
619d9a4
Merge branch 'master' into pg/contracts_rust_tests
pgherveou Nov 27, 2023
992e967
fix wasm32 legacy
pgherveou Nov 27, 2023
77c23ba
Remove features std from fixtures
pgherveou Nov 27, 2023
01261c7
PR review remove unused cargo dep
pgherveou Nov 27, 2023
a9a8e50
PR review Make sure fixtures are formatted
pgherveou Nov 27, 2023
04dbc5e
Fix fmt & lock
pgherveou Nov 27, 2023
d3871f3
rm println from build.rs
pgherveou Nov 27, 2023
d2d6e0c
fix formatting
pgherveou Nov 27, 2023
2ced8ea
Rename ptr_and_len_from_slice
pgherveou Nov 27, 2023
308c42f
Rename fn ptr_from_slice
pgherveou Nov 27, 2023
8907f0a
rm todo comment
pgherveou Nov 27, 2023
835d26f
Apply suggestions from code review
pgherveou Nov 27, 2023
c997c88
Update unstable comments
pgherveou Nov 27, 2023
8e9f317
rm inline
pgherveou Nov 27, 2023
a33ce94
rm unneeded uapi dep
pgherveou Nov 27, 2023
f3a2a21
rm legacy call uapi
pgherveou Nov 27, 2023
9c22f77
rm pub on legacy_compile_module
pgherveou Nov 27, 2023
4c15e5b
leftover
pgherveou Nov 27, 2023
b55b370
moved riscv32 and wasm32 under api
pgherveou Nov 27, 2023
f14996e
remove extern crate uapi
pgherveou Nov 27, 2023
c1e60bd
rm unneeded dep
pgherveou Nov 27, 2023
2a42b9f
move common inside contracts
pgherveou Nov 27, 2023
a8efa67
fmt
pgherveou Nov 27, 2023
08a6325
print both stdout & stderr
pgherveou Nov 28, 2023
887b70f
Fix format - skip on macos CI
pgherveou Nov 28, 2023
f5a5427
nit
pgherveou Nov 28, 2023
683e687
move cfg attribute to crate
pgherveou Nov 28, 2023
b978822
Update conditional compilation
pgherveou Nov 28, 2023
7fb1943
Update substrate/frame/contracts/fixtures/build.rs
pgherveou Nov 28, 2023
66c140d
Apply suggestions from code review
pgherveou Nov 28, 2023
6ef2866
fix tab / space mixed ups
pgherveou Nov 28, 2023
8922251
rm deps reserved for risc-v
pgherveou Nov 28, 2023
78f8ddf
rm leftover
pgherveou Nov 28, 2023
97f22a4
fix doc links
pgherveou Nov 28, 2023
39e423f
Add back scale to uapi
pgherveou Nov 29, 2023
b188eca
Merge branch 'master' into pg/contracts_rust_tests
pgherveou Nov 29, 2023
7c9322b
fix merge - rm call.wat
pgherveou Nov 29, 2023
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
92 changes: 66 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ members = [
"substrate/frame/collective",
"substrate/frame/contracts",
"substrate/frame/contracts/fixtures",
"substrate/frame/contracts/fixtures/contracts/common",
"substrate/frame/contracts/uapi",
"substrate/frame/contracts/mock-network",
"substrate/frame/contracts/primitives",
"substrate/frame/contracts/proc-macro",
"substrate/frame/conviction-voting",
"substrate/frame/core-fellowship",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pallet-transaction-payment-rpc-runtime-api = { path = "../../../../../substrate/
pallet-utility = { path = "../../../../../substrate/frame/utility", default-features = false}
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false}
pallet-contracts = { path = "../../../../../substrate/frame/contracts", default-features = false}
pallet-contracts-primitives = { path = "../../../../../substrate/frame/contracts/primitives", default-features = false}

# Polkadot
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false }
Expand Down Expand Up @@ -102,7 +101,6 @@ std = [
"pallet-authorship/std",
"pallet-balances/std",
"pallet-collator-selection/std",
"pallet-contracts-primitives/std",
"pallet-contracts/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-message-queue/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ impl_runtime_apis! {
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult<Balance, EventRecord> {
) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call(
origin,
Expand All @@ -608,10 +608,10 @@ impl_runtime_apis! {
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_contracts_primitives::Code<Hash>,
code: pallet_contracts::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance, EventRecord> {
) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate(
origin,
Expand All @@ -631,7 +631,7 @@ impl_runtime_apis! {
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
determinism: pallet_contracts::Determinism,
) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance> {
) -> pallet_contracts::CodeUploadResult<Hash, Balance> {
Contracts::bare_upload_code(
origin,
code,
Expand All @@ -643,7 +643,7 @@ impl_runtime_apis! {
fn get_storage(
address: AccountId,
key: Vec<u8>,
) -> pallet_contracts_primitives::GetStorageResult {
) -> pallet_contracts::GetStorageResult {
Contracts::get_storage(address, key)
}
}
Expand Down
2 changes: 0 additions & 2 deletions substrate/bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pallet-broker = { path = "../../../frame/broker", default-features = false}
pallet-child-bounties = { path = "../../../frame/child-bounties", default-features = false}
pallet-collective = { path = "../../../frame/collective", default-features = false}
pallet-contracts = { path = "../../../frame/contracts", default-features = false}
pallet-contracts-primitives = { path = "../../../frame/contracts/primitives", default-features = false}
pallet-conviction-voting = { path = "../../../frame/conviction-voting", default-features = false}
pallet-core-fellowship = { path = "../../../frame/core-fellowship", default-features = false}
pallet-democracy = { path = "../../../frame/democracy", default-features = false}
Expand Down Expand Up @@ -171,7 +170,6 @@ std = [
"pallet-broker/std",
"pallet-child-bounties/std",
"pallet-collective/std",
"pallet-contracts-primitives/std",
"pallet-contracts/std",
"pallet-conviction-voting/std",
"pallet-core-fellowship/std",
Expand Down
10 changes: 5 additions & 5 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@ impl_runtime_apis! {
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult<Balance, EventRecord> {
) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call(
origin,
Expand All @@ -2517,10 +2517,10 @@ impl_runtime_apis! {
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_contracts_primitives::Code<Hash>,
code: pallet_contracts::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance, EventRecord>
) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
{
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate(
Expand All @@ -2541,7 +2541,7 @@ impl_runtime_apis! {
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
determinism: pallet_contracts::Determinism,
) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance>
) -> pallet_contracts::CodeUploadResult<Hash, Balance>
{
Contracts::bare_upload_code(
origin,
Expand All @@ -2554,7 +2554,7 @@ impl_runtime_apis! {
fn get_storage(
address: AccountId,
key: Vec<u8>,
) -> pallet_contracts_primitives::GetStorageResult {
) -> pallet_contracts::GetStorageResult {
Contracts::get_storage(
address,
key
Expand Down
4 changes: 1 addition & 3 deletions substrate/frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ frame-benchmarking = { path = "../benchmarking", default-features = false, optio
frame-support = { path = "../support", default-features = false}
frame-system = { path = "../system", default-features = false}
pallet-balances = { path = "../balances", default-features = false , optional = true}
pallet-contracts-primitives = { path = "primitives", default-features = false}
pallet-contracts-uapi = { path = "uapi" }
pallet-contracts-proc-macro = { path = "proc-macro" }
sp-api = { path = "../../primitives/api", default-features = false}
sp-core = { path = "../../primitives/core", default-features = false}
Expand Down Expand Up @@ -83,8 +83,6 @@ std = [
"frame-system/std",
"log/std",
"pallet-balances?/std",
"pallet-contracts-fixtures/std",
"pallet-contracts-primitives/std",
"pallet-contracts-proc-macro/full",
"pallet-insecure-randomness-collective-flip/std",
"pallet-proxy/std",
Expand Down
1 change: 0 additions & 1 deletion substrate/frame/contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
version - 1,
)?;

println!("cargo:rerun-if-changed=src/migration");
Ok(())
}
16 changes: 11 additions & 5 deletions substrate/frame/contracts/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ description = "Fixtures for testing contracts pallet."

[dependencies]
wat = "1"
frame-system = { path = "../../system", default-features = false}
sp-runtime = { path = "../../../primitives/runtime", default-features = false}
frame-system = { path = "../../system" }
sp-runtime = { path = "../../../primitives/runtime" }
anyhow = "1.0.0"

[build-dependencies]
parity-wasm = "0.45.0"
tempfile = "3.8.1"
toml = "0.8.8"
twox-hash = "1.6.3"
anyhow = "1.0.0"
cfg-if = { version = "1.0", default-features = false }

[features]
default = [ "std" ]
std = [ "frame-system/std", "sp-runtime/std" ]

Loading