Skip to content

Commit f8c4f77

Browse files
authored
Merge pull request #1564 from CosmWasm/virus-contract
Add Virus contract
2 parents f4d5053 + af99739 commit f8c4f77

File tree

17 files changed

+2268
-2
lines changed

17 files changed

+2268
-2
lines changed

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ workflows:
6565
- contract_queue
6666
- contract_reflect
6767
- contract_staking
68+
- contract_virus
6869
- fmt
6970
- fmt_extra
7071
- clippy:
@@ -138,6 +139,9 @@ jobs:
138139
keys:
139140
- v4-arm64-contracts-rust:1.60.0-{{ checksum "contracts/crypto-verify/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }}
140141
- v4-arm64-contracts-rust:1.60.0-
142+
# Test a few contracts that do something potentially interesting in the VM
143+
# to test contract execution on ARM64.
144+
# No need to add all contracts here.
141145
- run:
142146
name: "contracts/crypto-verify: integration-test"
143147
working_directory: ~/project/contracts/crypto-verify
@@ -761,6 +765,33 @@ jobs:
761765
- target/wasm32-unknown-unknown/release/deps
762766
key: cargocache-v2-contract_staking-rust:1.60.0-{{ checksum "Cargo.lock" }}
763767

768+
contract_virus:
769+
docker:
770+
- image: rust:1.60.0
771+
environment:
772+
RUST_BACKTRACE: 1
773+
working_directory: ~/cosmwasm/contracts/virus
774+
steps:
775+
- checkout:
776+
path: ~/cosmwasm
777+
- run:
778+
name: Version information
779+
command: rustc --version; cargo --version; rustup --version
780+
- restore_cache:
781+
keys:
782+
- cargocache-v2-contract_virus-rust:1.60.0-{{ checksum "Cargo.lock" }}
783+
- check_contract
784+
- save_cache:
785+
paths:
786+
- /usr/local/cargo/registry
787+
- target/debug/.fingerprint
788+
- target/debug/build
789+
- target/debug/deps
790+
- target/wasm32-unknown-unknown/release/.fingerprint
791+
- target/wasm32-unknown-unknown/release/build
792+
- target/wasm32-unknown-unknown/release/deps
793+
key: cargocache-v2-contract_virus-rust:1.60.0-{{ checksum "Cargo.lock" }}
794+
764795
fmt:
765796
docker:
766797
- image: rust:1.60.0

contracts/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Introducing the development contracts in the order they were created.
3636
9. **cyberpunk** is an attempt to cleanup hackatom and make writing runtime
3737
tests (cosmwasm-vm/wamsmvm) easier by avoid the need for the escrow setup
3838
that hackatom has.
39+
10. **virus** is a contract that reproduces itself and does nothing useful
40+
beyond that, showing how to use instantiate2 from a contract.
3941

4042
## Optimized builds
4143

@@ -92,6 +94,11 @@ docker run --rm -v "$(pwd)":/code \
9294
--mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \
9395
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
9496
cosmwasm/rust-optimizer:0.12.9 ./contracts/staking
97+
98+
docker run --rm -v "$(pwd)":/code \
99+
--mount type=volume,source="devcontract_cache_virus",target=/code/contracts/virus/target \
100+
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
101+
cosmwasm/rust-optimizer:0.12.9 ./contracts/virus
95102
```
96103

97104
## Entry points
@@ -107,3 +114,4 @@ points in order to demonstrate and test the flexibility we have.
107114
| queue | yes | yes |
108115
| reflect | yes | no |
109116
| staking | yes | no |
117+
| virus | no | no |

contracts/virus/.cargo/config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[alias]
2+
wasm = "build --release --lib --target wasm32-unknown-unknown"
3+
wasm-debug = "build --lib --target wasm32-unknown-unknown"
4+
unit-test = "test --lib"
5+
integration-test = "test --test integration"
6+
schema = "run --bin schema"

0 commit comments

Comments
 (0)