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

* Refactored v1/v010 contracts to be in the same path #1126

Merged
merged 7 commits into from
Sep 11, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 12 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: contract.wasm
path: ./x/compute/internal/keeper/testdata/test-contract/contract.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract/contract.wasm
- uses: actions/upload-artifact@v2
with:
name: v1-contract.wasm
path: ./x/compute/internal/keeper/testdata/v1-sanity-contract/v1-contract.wasm
path: cosmwasm/contracts/v1/compute-tests/test-compute-contract/v1-contract.wasm
- uses: actions/upload-artifact@v2
with:
name: ibc.wasm
path: ./x/compute/internal/keeper/testdata/ibc/ibc.wasm
path: cosmwasm/contracts/v1/compute-tests/ibc-test-contract/ibc.wasm
- uses: actions/upload-artifact@v2
with:
name: enclave
Expand All @@ -153,15 +153,15 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: contract_with_floats.wasm
path: ./x/compute/internal/keeper/testdata/test-contract/contract_with_floats.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract/contract_with_floats.wasm
- uses: actions/upload-artifact@v2
with:
name: too-high-initial-memory.wasm
path: ./x/compute/internal/keeper/testdata/test-contract/too-high-initial-memory.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract/too-high-initial-memory.wasm
- uses: actions/upload-artifact@v2
with:
name: static-too-high-initial-memory.wasm
path: ./x/compute/internal/keeper/testdata/test-contract/static-too-high-initial-memory.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract/static-too-high-initial-memory.wasm

Go-Tests:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -191,11 +191,11 @@ jobs:
- uses: actions/download-artifact@v2
with:
name: v1-contract.wasm
path: ./x/compute/internal/keeper/testdata/v1-sanity-contract
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v2
with:
name: ibc.wasm
path: ./x/compute/internal/keeper/testdata/ibc
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v2
with:
name: contract_with_floats.wasm
Expand All @@ -210,10 +210,10 @@ jobs:
find "$(pwd)" -name \*.wasm
cp libgo_cosmwasm.so ./go-cosmwasm/api/libgo_cosmwasm.so
cp librust_cosmwasm_enclave.signed.so ./go-cosmwasm/librust_cosmwasm_enclave.signed.so
cp contract.wasm ./x/compute/internal/keeper/testdata/test-contract/contract.wasm
cp too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/test-contract/too-high-initial-memory.wasm
cp contract_with_floats.wasm ./x/compute/internal/keeper/testdata/test-contract/contract_with_floats.wasm
cp static-too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/test-contract/static-too-high-initial-memory.wasm
cp contract.wasm ./x/compute/internal/keeper/testdata/contract.wasm
cp too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/too-high-initial-memory.wasm
cp contract_with_floats.wasm ./x/compute/internal/keeper/testdata/contract_with_floats.wasm
cp static-too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/static-too-high-initial-memory.wasm
find "$(pwd)" -name \*.wasm
- name: Test x/registration
run: |
Expand Down
98 changes: 51 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ BRANCH ?= develop
DEBUG ?= 0
DOCKER_TAG ?= latest

CW_CONTRACTS_V010_PATH = ./cosmwasm/contracts/v010/
CW_CONTRACTS_V1_PATH = ./cosmwasm/contracts/v1/

TEST_CONTRACT_V010_PATH = ./cosmwasm/contracts/v010/compute-tests
TEST_CONTRACT_V1_PATH = ./cosmwasm/contracts/v1/compute-tests

TEST_COMPUTE_MODULE_PATH = ./x/compute/internal/keeper/testdata/

ENCLAVE_PATH = cosmwasm/enclaves/
EXECUTE_ENCLAVE_PATH = $(ENCLAVE_PATH)/execute/
QUERY_ENCLAVE_PATH = $(ENCLAVE_PATH)/query/

ifeq ($(SGX_MODE), HW)
ext := hw
else ifeq ($(SGX_MODE), SW)
Expand Down Expand Up @@ -110,8 +122,6 @@ ifeq ($(DB_BACKEND),rocksdb)
ldflags += -extldflags "-lrocksdb -llz4"
endif



ldflags += -s -w
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
Expand Down Expand Up @@ -139,6 +149,8 @@ build_local_no_rust: bin-data-$(IAS_BUILD)
cp go-cosmwasm/target/$(BUILD_PROFILE)/libgo_cosmwasm.so go-cosmwasm/api
go build -mod=readonly -tags "$(GO_TAGS)" -ldflags '$(LD_FLAGS)' ./cmd/secretd

build-secret: build-linux

build-linux: _build-linux build_local_no_rust build_cli
_build-linux: vendor
BUILD_PROFILE=$(BUILD_PROFILE) FEATURES=$(FEATURES) FEATURES_U=$(FEATURES_U) $(MAKE) -C go-cosmwasm build-rust
Expand Down Expand Up @@ -234,7 +246,7 @@ build-custom-dev-image:
docker build --build-arg SGX_MODE=SW --build-arg SECRET_NODE_TYPE=BOOTSTRAP -f deployment/dockerfiles/custom-node.Dockerfile -t enigmampc/secret-network-sw-dev-custom-bootstrap:${DOCKER_TAG} .
docker build --build-arg SGX_MODE=SW --build-arg SECRET_NODE_TYPE=NODE -f deployment/dockerfiles/custom-node.Dockerfile -t enigmampc/secret-network-sw-dev-custom-node:${DOCKER_TAG} .
# delete the copies created above
rm go-cosmwasm/api/libgo_cosmwasm.so.x cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so.x
rm go-cosmwasm/api/libgo_cosmwasm.so.x $(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so.x

build-testnet: docker_base
@mkdir build 2>&3 || true
Expand Down Expand Up @@ -293,14 +305,6 @@ docker_base_go:

docker_base: docker_base_rust docker_base_go

#ifeq ($(DB_BACKEND),rocksdb)
#docker_base: docker_base_rocksdb
#else
#docker_base: docker_base_goleveldb
#endif



docker_bootstrap: docker_base
docker build --build-arg SGX_MODE=${SGX_MODE} --build-arg SECRET_NODE_TYPE=BOOTSTRAP -f deployment/dockerfiles/local-node.Dockerfile -t enigmampc/secret-network-bootstrap-${ext}:${DOCKER_TAG} .

Expand All @@ -316,60 +320,63 @@ docker_enclave_test:

# while developing:
build-enclave: vendor
$(MAKE) -C cosmwasm/enclaves/execute enclave
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) enclave

# while developing:
check-enclave:
$(MAKE) -C cosmwasm/enclaves/execute check
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) check

# while developing:
clippy-enclave:
$(MAKE) -C cosmwasm/enclaves/execute clippy
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clippy

# while developing:
clean-enclave:
$(MAKE) -C cosmwasm/enclaves/execute clean
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clean

sanity-test:
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so .
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/testing/sanity-test.sh

sanity-test-hw:
$(MAKE) build-linux
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so .
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
./cosmwasm/testing/sanity-test.sh

callback-sanity-test:
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so .
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/testing/callback-test.sh

build-test-contract:
# echo "" | sudo add-apt-repository ppa:hnakamur/binaryen
# sudo apt update
# sudo apt install -y binaryen
$(MAKE) -C ./x/compute/internal/keeper/testdata/test-contract
$(MAKE) -C ./x/compute/internal/keeper/testdata/v1-sanity-contract
$(MAKE) -C ./x/compute/internal/keeper/testdata/ibc
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/ibc-test-contract
cp $(TEST_CONTRACT_V1_PATH)/ibc-test-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/

prep-go-tests: build-test-contract
# empty BUILD_PROFILE means debug mode which compiles faster
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper

go-tests: build-test-contract
SGX_MODE=SW $(MAKE) build-linux-with-query
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./cosmwasm/enclaves/query/librust_cosmwasm_query_enclave.signed.so ./x/compute/internal/keeper
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./$(QUERY_ENCLAVE_PATH)/librust_cosmwasm_query_enclave.signed.so ./x/compute/internal/keeper
rm -rf ./x/compute/internal/keeper/.sgx_secrets
mkdir -p ./x/compute/internal/keeper/.sgx_secrets
GOMAXPROCS=8 SGX_MODE=SW SCRT_SGX_STORAGE='./' go test -failfast -timeout 90m -v ./x/compute/internal/... $(GO_TEST_ARGS)

go-tests-hw: build-test-contract
# empty BUILD_PROFILE means debug mode which compiles faster
SGX_MODE=HW $(MAKE) build-linux
cp ./cosmwasm/enclaves/execute/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
rm -rf ./x/compute/internal/keeper/.sgx_secrets
mkdir -p ./x/compute/internal/keeper/.sgx_secrets
GOMAXPROCS=8 SGX_MODE=HW go test -v ./x/compute/internal/... $(GO_TEST_ARGS)
Expand All @@ -382,37 +389,34 @@ enclave-tests:
$(MAKE) -C cosmwasm/enclaves/test run

build-all-test-contracts: build-test-contract
# echo "" | sudo add-apt-repository ppa:hnakamur/binaryen
# sudo apt update
# sudo apt install -y binaryen
cd ./cosmwasm/v010-contracts/gov && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/gov/target/wasm32-unknown-unknown/release/gov.wasm -o ./x/compute/internal/keeper/testdata/gov.wasm
cd $(CW_CONTRACTS_V010_PATH)/gov && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os $(CW_CONTRACTS_V010_PATH)/gov/target/wasm32-unknown-unknown/release/gov.wasm -o $(TEST_CONTRACT_PATH)/gov.wasm

cd ./cosmwasm/v010-contracts/dist && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/dist/target/wasm32-unknown-unknown/release/dist.wasm -o ./x/compute/internal/keeper/testdata/dist.wasm
cd $(CW_CONTRACTS_V010_PATH)/dist && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os $(CW_CONTRACTS_V010_PATH)/dist/target/wasm32-unknown-unknown/release/dist.wasm -o $(TEST_CONTRACT_PATH)/dist.wasm

cd ./cosmwasm/v010-contracts/mint && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/mint/target/wasm32-unknown-unknown/release/mint.wasm -o ./x/compute/internal/keeper/testdata/mint.wasm
cd .$(CW_CONTRACTS_V010_PATH)/mint && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/mint/target/wasm32-unknown-unknown/release/mint.wasm -o $(TEST_CONTRACT_PATH)/mint.wasm

cd ./cosmwasm/v010-contracts/staking && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/staking/target/wasm32-unknown-unknown/release/staking.wasm -o ./x/compute/internal/keeper/testdata/staking.wasm
cd .$(CW_CONTRACTS_V010_PATH)/staking && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/staking/target/wasm32-unknown-unknown/release/staking.wasm -o $(TEST_CONTRACT_PATH)/staking.wasm

cd ./cosmwasm/v010-contracts/reflect && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/reflect/target/wasm32-unknown-unknown/release/reflect.wasm -o ./x/compute/internal/keeper/testdata/reflect.wasm
cd .$(CW_CONTRACTS_V010_PATH)/reflect && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/reflect/target/wasm32-unknown-unknown/release/reflect.wasm -o $(TEST_CONTRACT_PATH)/reflect.wasm

cd ./cosmwasm/v010-contracts/burner && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/burner/target/wasm32-unknown-unknown/release/burner.wasm -o ./x/compute/internal/keeper/testdata/burner.wasm
cd .$(CW_CONTRACTS_V010_PATH)/burner && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/burner/target/wasm32-unknown-unknown/release/burner.wasm -o $(TEST_CONTRACT_PATH)/burner.wasm

cd ./cosmwasm/v010-contracts/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o ./x/compute/internal/keeper/testdata/erc20.wasm
cd .$(CW_CONTRACTS_V010_PATH)/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o $(TEST_CONTRACT_PATH)/erc20.wasm

cd ./cosmwasm/v010-contracts/hackatom && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/hackatom/target/wasm32-unknown-unknown/release/hackatom.wasm -o ./x/compute/internal/keeper/testdata/contract.wasm
cat ./x/compute/internal/keeper/testdata/contract.wasm | gzip > ./x/compute/internal/keeper/testdata/contract.wasm.gzip
cd .$(CW_CONTRACTS_V010_PATH)/hackatom && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/hackatom/target/wasm32-unknown-unknown/release/hackatom.wasm -o $(TEST_CONTRACT_PATH)/contract.wasm
cat $(TEST_CONTRACT_PATH)/contract.wasm | gzip > $(TEST_CONTRACT_PATH)/contract.wasm.gzip

build-erc20-contract: build-test-contract
cd ./cosmwasm/v010-contracts/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/v010-contracts/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o ./erc20.wasm
cd .$(CW_CONTRACTS_V010_PATH)/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o ./erc20.wasm

bin-data: bin-data-sw bin-data-develop bin-data-production

Expand Down
57 changes: 4 additions & 53 deletions cosmwasm/Cargo.lock

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

2 changes: 1 addition & 1 deletion cosmwasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["packages/*"]
exclude = ["packages/enclave-test", "enclaves", "v010-contracts/*"]
exclude = ["enclaves", "contracts/v010", "contracts/v1"]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }

[dev-dependencies]
cosmwasm-vm = { path = "../../packages/sgx-vm", package = "cosmwasm-sgx-vm", default-features = false, features = [
cosmwasm-vm = { path = "../../../packages/sgx-vm", package = "cosmwasm-sgx-vm", default-features = false, features = [
"iterator"
] }
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-schema = "0.10.0"

[workspace]
members = []
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build results
/target
/x/compute/internal/keeper/testdata/test-contract/target
*.wasm

# Text file backups
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading