Skip to content

Commit 5ccf13c

Browse files
committed
refactor: remove left over sandbox usage
1 parent eac34e7 commit 5ccf13c

File tree

15 files changed

+315
-327
lines changed

15 files changed

+315
-327
lines changed

ARCHITECTURE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ ink! contracts are compiled to RISC-V bytecode for
6060
This is how ink! smart contracts are executed on a blockchain:
6161
they are uploaded to a blockchain that runs PolkaVM, PolkaVM then
6262
interprets them.
63-
As contracts are executed in a sandbox execution environment on the
63+
As contracts are executed in an isolated runtime environment on the
6464
blockchain itself we compile them to a `no_std` environment.
6565
More specifically they are executed by the [`pallet-revive`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive),
6666
a module of the Polkadot SDK blockchain framework. This module takes ink!
67-
smart contracts and runs them in a PolkaVM sandbox environment.
67+
smart contracts and runs them in a PolkaVM execution environment.
6868
It also provides an API to smart contracts for anything a smart contract
6969
needs: storing + retrieving data, calling other contracts, sending value,
7070
fetching the block number, ….
@@ -250,9 +250,9 @@ most smart-contract-specific events: `Called`, `ContractCodeUpdated, CodeStored`
250250
The `Instantiated` event was brought back in a later PR.
251251

252252
(5) `pallet-revive` included `revm` as a non-optional dependency. As ink! has to
253-
depend on `pallet-revive` for some features (e.g. sandboxed E2E testing), this
253+
depend on `pallet-revive` for some features (e.g. runtime-only E2E testing), this
254254
results in over 75 more child dependencies having to be build now. This increased
255-
build times for sandboxed E2E tests significantly.
255+
build times for runtime-only E2E tests significantly.
256256
[We proposed](https://github.com/paritytech/polkadot-sdk/pull/9689) putting anything
257257
`revm` behind a feature flag, but Parity is not open to it.
258258

RELEASES_CHECKLIST.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ in the future.
6060
- Release `cargo-contract` crates.
6161
- Request update of `drink` client, which depends on the `cargo-contract` crates.
6262
- Release `ink_e2e`.
63-
1. The `ink_sandbox` crate depends on a git commit of `polkadot-sdk`, hence it
63+
1. The `ink_runtime` crate depends on a git commit of `polkadot-sdk`, hence it
6464
currently cannot be published to crates.io.
6565
1. Do a dry run:
6666
```bash
6767
fd Cargo.toml crates/ | \
6868
grep -v e2e | \
69-
grep -v sandbox | \
69+
grep -v crates/runtime/ | \
7070
xargs -n1 cargo no-dev-deps publish --allow-dirty --dry-run --manifest-path
7171
```
72-
This command ignores the `e2e` and `sandbox` folder: The `e2e` crates depend on the `cargo-contract/contract-build`
72+
This command ignores the `e2e` and `crates/runtime` folders: The `e2e` crates depend on the `cargo-contract/contract-build`
7373
crate, so if you want to publish those, you need to publish `cargo-contract/contract-build` first.
74-
The `sandbox` is ignored, as it depends on some crates via their `git` ref.
74+
The runtime emulator is ignored, as it depends on some crates via their `git` ref.
7575
It uses [`no-dev-deps`](https://crates.io/crates/cargo-no-dev-deps)
7676
for publishing, so that the `dev-dependencies` of ink! are ignored for publishing.
7777
They are not needed and due to a cycle it's also not possible to publish with them.

crates/e2e/macro/src/config.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ impl Node {
7676
/// The runtime emulator that should be used within `TestExternalities`
7777
#[derive(Clone, Eq, PartialEq, Debug, darling::FromMeta)]
7878
pub struct RuntimeOnly {
79-
/// The sandbox runtime type (e.g., `ink_runtime::DefaultRuntime`)
80-
pub sandbox: syn::Path,
79+
/// The runtime type (e.g., `ink_runtime::DefaultRuntime`)
80+
pub runtime: syn::Path,
8181
/// The client type implementing the backend traits (e.g.,
8282
/// `ink_runtime::RuntimeClient`)
8383
pub client: syn::Path,
8484
}
8585

8686
impl RuntimeOnly {
8787
pub fn runtime_path(&self) -> syn::Path {
88-
self.sandbox.clone()
88+
self.runtime.clone()
8989
}
9090
pub fn client_path(&self) -> syn::Path {
9191
self.client.clone()
@@ -234,7 +234,7 @@ impl RuntimeBackendArg {
234234
fn into_backend_meta(self) -> NestedMeta {
235235
let runtime = self.runtime();
236236
syn::parse_quote! {
237-
backend(runtime_only(sandbox = #runtime, client = ::ink_runtime::RuntimeClient))
237+
backend(runtime_only(runtime = #runtime, client = ::ink_runtime::RuntimeClient))
238238
}
239239
}
240240
}
@@ -254,7 +254,7 @@ mod tests {
254254
fn config_works_backend_runtime_only() {
255255
let input = quote! {
256256
environment = crate::CustomEnvironment,
257-
backend(runtime_only(sandbox = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
257+
backend(runtime_only(runtime = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
258258
};
259259
let config = parse_config(input);
260260

@@ -266,7 +266,7 @@ mod tests {
266266
assert_eq!(
267267
config.backend(),
268268
Backend::RuntimeOnly(RuntimeOnly {
269-
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
269+
runtime: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
270270
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
271271
})
272272
);
@@ -283,7 +283,7 @@ mod tests {
283283
assert_eq!(
284284
config.backend(),
285285
Backend::RuntimeOnly(RuntimeOnly {
286-
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
286+
runtime: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
287287
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
288288
})
289289
);
@@ -292,14 +292,14 @@ mod tests {
292292
#[test]
293293
fn config_works_runtime_only_with_custom_backend() {
294294
let input = quote! {
295-
backend(runtime_only(sandbox = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
295+
backend(runtime_only(runtime = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
296296
};
297297
let config = parse_config(input);
298298

299299
assert_eq!(
300300
config.backend(),
301301
Backend::RuntimeOnly(RuntimeOnly {
302-
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
302+
runtime: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
303303
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
304304
})
305305
);
@@ -313,7 +313,7 @@ mod tests {
313313
assert_eq!(
314314
config.backend(),
315315
Backend::RuntimeOnly(RuntimeOnly {
316-
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
316+
runtime: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
317317
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
318318
})
319319
);
@@ -327,7 +327,7 @@ mod tests {
327327
assert_eq!(
328328
config.backend(),
329329
Backend::RuntimeOnly(RuntimeOnly {
330-
sandbox: syn::parse_quote! { crate::CustomRuntime },
330+
runtime: syn::parse_quote! { crate::CustomRuntime },
331331
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
332332
})
333333
);

crates/runtime/src/api/assets_api.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use frame_support::{
2323
type AssetIdOf<T, I> = <T as pallet_assets::Config<I>>::AssetId;
2424
type AssetBalanceOf<T, I> = <T as pallet_assets::Config<I>>::Balance;
2525

26-
/// Assets API for the sandbox.
26+
/// Assets API for the runtime.
2727
///
2828
/// Provides methods to create, mint, and manage assets in `pallet-assets`.
2929
pub trait AssetsAPI<T, I = pallet_assets::Instance1>
@@ -327,52 +327,52 @@ mod tests {
327327

328328
#[test]
329329
fn create_works() {
330-
let mut sandbox = DefaultRuntime::default();
330+
let mut runtime = DefaultRuntime::default();
331331
let admin = DefaultRuntime::default_actor();
332332
let asset_id = 1u32;
333333
let min_balance = 1u128;
334334

335-
let result = sandbox.create(&asset_id, &admin, min_balance);
335+
let result = runtime.create(&asset_id, &admin, min_balance);
336336

337337
assert!(result.is_ok());
338-
assert!(sandbox.asset_exists(&asset_id));
338+
assert!(runtime.asset_exists(&asset_id));
339339
}
340340

341341
#[test]
342342
fn set_metadata_works() {
343-
let mut sandbox = DefaultRuntime::default();
343+
let mut runtime = DefaultRuntime::default();
344344
let admin = DefaultRuntime::default_actor();
345345
let asset_id = 1u32;
346346

347-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
347+
runtime.create(&asset_id, &admin, 1u128).unwrap();
348348

349349
let name = b"Test Token".to_vec();
350350
let symbol = b"TEST".to_vec();
351351
let decimals = 18u8;
352352

353-
let result = sandbox.set_metadata(&asset_id, &admin, name, symbol, decimals);
353+
let result = runtime.set_metadata(&asset_id, &admin, name, symbol, decimals);
354354

355355
assert!(result.is_ok());
356356
}
357357

358358
#[test]
359359
fn metadata_works() {
360-
let mut sandbox = DefaultRuntime::default();
360+
let mut runtime = DefaultRuntime::default();
361361
let admin = DefaultRuntime::default_actor();
362362
let asset_id = 1u32;
363363

364-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
364+
runtime.create(&asset_id, &admin, 1u128).unwrap();
365365

366366
let name = b"Test Token".to_vec();
367367
let symbol = b"TEST".to_vec();
368368
let decimals = 18u8;
369369

370-
sandbox
370+
runtime
371371
.set_metadata(&asset_id, &admin, name.clone(), symbol.clone(), decimals)
372372
.unwrap();
373373

374374
let (retrieved_name, retrieved_symbol, retrieved_decimals) =
375-
sandbox.metadata(&asset_id);
375+
runtime.metadata(&asset_id);
376376

377377
assert_eq!(retrieved_name, name);
378378
assert_eq!(retrieved_symbol, symbol);
@@ -381,133 +381,133 @@ mod tests {
381381

382382
#[test]
383383
fn approve_works() {
384-
let mut sandbox = DefaultRuntime::default();
384+
let mut runtime = DefaultRuntime::default();
385385
let admin = DefaultRuntime::default_actor();
386386
let spender = ink_e2e::bob().into_account_id();
387387
let asset_id = 1u32;
388388

389-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
390-
sandbox.mint_into(&asset_id, &admin, 1000u128).unwrap();
389+
runtime.create(&asset_id, &admin, 1u128).unwrap();
390+
runtime.mint_into(&asset_id, &admin, 1000u128).unwrap();
391391

392-
let allowance_before = sandbox.allowance(&asset_id, &admin, &spender);
392+
let allowance_before = runtime.allowance(&asset_id, &admin, &spender);
393393
assert_eq!(allowance_before, 0);
394394

395-
let result = sandbox.approve(&asset_id, &admin, &spender, 500u128);
395+
let result = runtime.approve(&asset_id, &admin, &spender, 500u128);
396396

397397
assert!(result.is_ok());
398398

399-
let allowance_after = sandbox.allowance(&asset_id, &admin, &spender);
399+
let allowance_after = runtime.allowance(&asset_id, &admin, &spender);
400400
assert_eq!(allowance_after, 500);
401401
}
402402

403403
#[test]
404404
fn mint_into_works() {
405-
let mut sandbox = DefaultRuntime::default();
405+
let mut runtime = DefaultRuntime::default();
406406
let admin = DefaultRuntime::default_actor();
407407
let asset_id = 1u32;
408408

409-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
409+
runtime.create(&asset_id, &admin, 1u128).unwrap();
410410

411-
let balance_before = sandbox.balance_of(&asset_id, &admin);
411+
let balance_before = runtime.balance_of(&asset_id, &admin);
412412
assert_eq!(balance_before, 0);
413413

414-
sandbox.mint_into(&asset_id, &admin, 100u128).unwrap();
414+
runtime.mint_into(&asset_id, &admin, 100u128).unwrap();
415415

416-
let balance_after = sandbox.balance_of(&asset_id, &admin);
416+
let balance_after = runtime.balance_of(&asset_id, &admin);
417417
assert_eq!(balance_after, 100);
418418
}
419419

420420
#[test]
421421
fn transfer_works() {
422-
let mut sandbox = DefaultRuntime::default();
422+
let mut runtime = DefaultRuntime::default();
423423
let admin = DefaultRuntime::default_actor();
424424
let recipient = ink_e2e::bob().into_account_id();
425425
let asset_id = 1u32;
426426

427-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
428-
sandbox.mint_into(&asset_id, &admin, 1000u128).unwrap();
427+
runtime.create(&asset_id, &admin, 1u128).unwrap();
428+
runtime.mint_into(&asset_id, &admin, 1000u128).unwrap();
429429

430-
let admin_balance_before = sandbox.balance_of(&asset_id, &admin);
431-
let recipient_balance_before = sandbox.balance_of(&asset_id, &recipient);
430+
let admin_balance_before = runtime.balance_of(&asset_id, &admin);
431+
let recipient_balance_before = runtime.balance_of(&asset_id, &recipient);
432432

433433
assert_eq!(admin_balance_before, 1000);
434434
assert_eq!(recipient_balance_before, 0);
435435

436-
let result = sandbox.transfer(&asset_id, &admin, &recipient, 300u128);
436+
let result = runtime.transfer(&asset_id, &admin, &recipient, 300u128);
437437

438438
assert!(result.is_ok());
439439

440-
let admin_balance_after = sandbox.balance_of(&asset_id, &admin);
441-
let recipient_balance_after = sandbox.balance_of(&asset_id, &recipient);
440+
let admin_balance_after = runtime.balance_of(&asset_id, &admin);
441+
let recipient_balance_after = runtime.balance_of(&asset_id, &recipient);
442442

443443
assert_eq!(admin_balance_after, 700);
444444
assert_eq!(recipient_balance_after, 300);
445445
}
446446

447447
#[test]
448448
fn balance_of_works() {
449-
let mut sandbox = DefaultRuntime::default();
449+
let mut runtime = DefaultRuntime::default();
450450
let admin = DefaultRuntime::default_actor();
451451
let asset_id = 1u32;
452452

453-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
453+
runtime.create(&asset_id, &admin, 1u128).unwrap();
454454

455-
let balance = sandbox.balance_of(&asset_id, &admin);
455+
let balance = runtime.balance_of(&asset_id, &admin);
456456
assert_eq!(balance, 0);
457457

458-
sandbox.mint_into(&asset_id, &admin, 500u128).unwrap();
458+
runtime.mint_into(&asset_id, &admin, 500u128).unwrap();
459459

460-
let balance = sandbox.balance_of(&asset_id, &admin);
460+
let balance = runtime.balance_of(&asset_id, &admin);
461461
assert_eq!(balance, 500);
462462
}
463463

464464
#[test]
465465
fn total_supply_works() {
466-
let mut sandbox = DefaultRuntime::default();
466+
let mut runtime = DefaultRuntime::default();
467467
let admin = DefaultRuntime::default_actor();
468468
let asset_id = 1u32;
469469

470-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
470+
runtime.create(&asset_id, &admin, 1u128).unwrap();
471471

472-
let supply_before = sandbox.total_supply(&asset_id);
472+
let supply_before = runtime.total_supply(&asset_id);
473473
assert_eq!(supply_before, 0);
474474

475-
sandbox.mint_into(&asset_id, &admin, 1000u128).unwrap();
475+
runtime.mint_into(&asset_id, &admin, 1000u128).unwrap();
476476

477-
let supply_after = sandbox.total_supply(&asset_id);
477+
let supply_after = runtime.total_supply(&asset_id);
478478
assert_eq!(supply_after, 1000);
479479
}
480480

481481
#[test]
482482
fn allowance_works() {
483-
let mut sandbox = DefaultRuntime::default();
483+
let mut runtime = DefaultRuntime::default();
484484
let admin = DefaultRuntime::default_actor();
485485
let spender = ink_e2e::bob().into_account_id();
486486
let asset_id = 1u32;
487487

488-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
488+
runtime.create(&asset_id, &admin, 1u128).unwrap();
489489

490-
let allowance = sandbox.allowance(&asset_id, &admin, &spender);
490+
let allowance = runtime.allowance(&asset_id, &admin, &spender);
491491
assert_eq!(allowance, 0);
492492

493-
sandbox
493+
runtime
494494
.approve(&asset_id, &admin, &spender, 250u128)
495495
.unwrap();
496496

497-
let allowance = sandbox.allowance(&asset_id, &admin, &spender);
497+
let allowance = runtime.allowance(&asset_id, &admin, &spender);
498498
assert_eq!(allowance, 250);
499499
}
500500

501501
#[test]
502502
fn asset_exists_works() {
503-
let mut sandbox = DefaultRuntime::default();
503+
let mut runtime = DefaultRuntime::default();
504504
let admin = DefaultRuntime::default_actor();
505505
let asset_id = 1u32;
506506

507-
assert!(!sandbox.asset_exists(&asset_id));
507+
assert!(!runtime.asset_exists(&asset_id));
508508

509-
sandbox.create(&asset_id, &admin, 1u128).unwrap();
509+
runtime.create(&asset_id, &admin, 1u128).unwrap();
510510

511-
assert!(sandbox.asset_exists(&asset_id));
511+
assert!(runtime.asset_exists(&asset_id));
512512
}
513513
}

0 commit comments

Comments
 (0)