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

Cosmwasm 0.9 #262

Merged
merged 144 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
7e97548
replaced x/compute with x/wasm from enigmampc/wasmd at commit e69b1aa
reuvenpo Jun 18, 2020
76658a9
replaced go-cosmwasm with content from enigmampc/go-cosmwasm at commi…
reuvenpo Jun 18, 2020
84f34c6
replaced cosmwasm with content from enigmampc/cosmwasm at commit 716f67b
reuvenpo Jun 18, 2020
6edf019
Merge remote-tracking branch 'origin/develop' into cosmwasm-0.9
reuvenpo Jun 18, 2020
ee4e714
adjected some paths that pointed to cosmwasm/lib, which no longer exists
reuvenpo Jun 18, 2020
56512e6
Error testing
toml01 Jun 18, 2020
5653946
Fixed Go compiliation issues
Jun 18, 2020
430b0b2
Update Dockerfile
Cashmaney Jun 18, 2020
3c62dc4
Merge remote-tracking branch 'remotes/enigmampc/develop' into cosmwas…
Jun 18, 2020
35d064f
Merge remote-tracking branch 'enigmampc/cosmwasm-0.9' into cosmwasm-0.9
Jun 18, 2020
ceccd93
migrate test-contract from cosmwasm 0.7 to 0.9
assafmo Jun 21, 2020
cae9961
Merge pull request #295 from enigmampc/migrate-test-contract-to-0.9
assafmo Jun 21, 2020
bc4f6c8
Merge branch 'cosmwasm-0.9' into go-tests
assafmo Jun 21, 2020
c7477c3
Merge branch 'cosmwasm-0.9' into go-tests
assafmo Jun 21, 2020
d5b2269
Merge pull request #296 from enigmampc/go-tests
assafmo Jun 21, 2020
ddcd1ea
some api fixes
assafmo Jun 21, 2020
43c76f9
gitignore .idea
assafmo Jun 21, 2020
2e5e17d
fix makefile for test contract
assafmo Jun 21, 2020
c8235ba
encrypt inputs in new tests from 0.9
assafmo Jun 21, 2020
0162f17
fix some log strings inside the enclave
assafmo Jun 21, 2020
bf7daab
Merge pull request #297 from enigmampc/fix-tests-to-0.9
assafmo Jun 21, 2020
338fb44
typo
toml01 Jun 21, 2020
b3395d6
Merge branch 'cosmwasm-0.9' of github.com:enigmampc/EnigmaBlockchain …
toml01 Jun 21, 2020
fb608de
updated the burner example contract to use the correct path for cosmw…
reuvenpo Jun 21, 2020
a1d0074
Fixing ABI. enclave now runs fine, errors coming from contracts
toml01 Jun 22, 2020
0c76389
migrate read_db to new ABI
assafmo Jun 22, 2020
2179bd8
migrate write_db to new ABI, create skeleton for remove_db
assafmo Jun 22, 2020
4ff4371
also fix wasm abi for human, canonical
assafmo Jun 22, 2020
c4b48c2
fix some error type conversion
assafmo Jun 22, 2020
1225441
Fixed Region compatibility
toml01 Jun 22, 2020
595f082
Added test contract cleaning to Makefile
toml01 Jun 22, 2020
f644ce1
`Ok` parsing now works
toml01 Jun 23, 2020
9a03d81
Fix all error handling for wasm imports in 0.9
assafmo Jun 23, 2020
a2fcc41
fix db_remove's signature
assafmo Jun 23, 2020
d74ed5c
implement remove_db
assafmo Jun 23, 2020
8cdbff3
fix ocall_remove_db calling params
assafmo Jun 23, 2020
c7db247
Contracts now updated
toml01 Jun 23, 2020
b1cb3ee
Merge branch 'assafmo/issue278' of github.com:enigmampc/EnigmaBlockch…
toml01 Jun 23, 2020
4ff85ec
Merge pull request #301 from enigmampc/assafmo/issue278
assafmo Jun 23, 2020
8079a16
Fixing go side
toml01 Jun 23, 2020
9c5a2cf
fix some output decryption handling, still has an error passing bytes…
assafmo Jun 23, 2020
5197641
fix buffers usage in wasm imports, update erc20 ontract to 0.9
assafmo Jun 23, 2020
c28cb76
removed dependency on wasmer from sgx-vm
reuvenpo Jun 24, 2020
b70963c
removed unused variable from ocall_remove_db
reuvenpo Jun 24, 2020
84cde0b
fixed typo in wasmi-runtime/src/lib.rs
reuvenpo Jun 24, 2020
bd3fae8
fix some more output parsing in tests
assafmo Jun 24, 2020
581e5c8
fix TestExecuteNotEncryptedInputError
assafmo Jun 24, 2020
f1fab95
faster build mode for tests & ci (also rename build_linux to build-li…
assafmo Jun 24, 2020
6e769ea
fix faster builds
assafmo Jun 24, 2020
557eeda
moved CryptoError from enclave-ffi-types to wasmi_runtime::crypto::er…
reuvenpo Jun 24, 2020
fcb6e13
also encrypt wasm error, fix some more tests
assafmo Jun 24, 2020
4c8bea7
simplified ecall_authenticate_new_node
reuvenpo Jun 24, 2020
fd7c95f
fixed issue in write_to_untrusted where failure to write would be ign…
reuvenpo Jun 24, 2020
2c7ce71
Fix callbacks for 0.9 :tada:
assafmo Jun 24, 2020
3313222
remove unnecessary code comments
assafmo Jun 24, 2020
76da5c4
refactor read_db to use write_to_memory instead of reimplementing it
assafmo Jun 24, 2020
403d06b
Merge pull request #300 from enigmampc/#282-contract-responses
assafmo Jun 24, 2020
23291fb
remove printf of encrypted data
assafmo Jun 25, 2020
2ffbf1b
make clippy happy
assafmo Jun 25, 2020
de24ef4
revert error handling from fcb6e1387d256a2cd76f67f335eb06947a32a0ce
assafmo Jun 25, 2020
da9ec23
Merge branch 'cosmwasm-0.9' into 312-fix-write-db
assafmo Jun 25, 2020
fdd14db
TestQueryInputParamError fix check
assafmo Jun 25, 2020
caa944f
compile test contracts to our version of cosmwasm
assafmo Jun 25, 2020
e5684d8
fix writing to wasm memory in humanize/canonicalize address
assafmo Jun 25, 2020
b27a3b7
Merge pull request #315 from enigmampc/312-fix-write-db
assafmo Jun 25, 2020
994aaea
fix error handling in canonicalize_address & humanize_addres
assafmo Jun 25, 2020
9004859
sanity-test.sh fix store
assafmo Jun 25, 2020
f11acd3
optimize wasm builds
assafmo Jun 25, 2020
ac34cfc
InitMsg is encrypted bytes, not Json
Cashmaney Jun 25, 2020
de0b31e
fix "q compute tx" for 0.9
assafmo Jun 25, 2020
ff8dd65
add error use case to callback bash test (doesn't test anything yet)
assafmo Jun 25, 2020
5de0642
fix decryption in js library
assafmo Jun 25, 2020
75b9f38
CI fixes
Jun 28, 2020
4757901
Merge pull request #318 from enigmampc/ci-fixes-from-311
assafmo Jun 28, 2020
f0ef4db
do not support staking yet
assafmo Jun 28, 2020
013876a
Update node_init.sh
Cashmaney Jun 28, 2020
bacb408
js decryption: fix some edge cases and error decryption
assafmo Jun 28, 2020
dd5b50d
js: fix "q tx" scenario
assafmo Jun 28, 2020
c393351
rebuld test contract
assafmo Jun 28, 2020
75fad83
Merge pull request #319 from enigmampc/#311-fix-client-decryption
assafmo Jun 28, 2020
973f920
publish SecretJS to npm
assafmo Jun 28, 2020
3d3c8ed
npm: rename @secret-network/sdk to secretjs
assafmo Jun 28, 2020
2fe5e16
skip reflect test (still no "staking" feature)
assafmo Jun 28, 2020
676470a
barebone test contract
assafmo Jun 28, 2020
af9d454
TestInitNoLogs, clean more of test contract
assafmo Jun 28, 2020
0df0cb0
import escrow sample contract, compile it to 0.9 an put in testdata dirs
assafmo Jun 28, 2020
a98abae
skip some basic tests that uses escrow.wasm
assafmo Jun 28, 2020
960028f
TestExecNoLogs
assafmo Jun 28, 2020
3bab656
implement stub for query_chain
assafmo Jun 28, 2020
a5485ee
skip staking tests
assafmo Jun 28, 2020
06307e9
Merge branch 'cosmwasm-0.9' into 321-query-chain-stub
assafmo Jun 28, 2020
9a48c3a
skip TestQueryContractState because cannot interact directly with state
assafmo Jun 28, 2020
ac9666c
Merge branch 'cosmwasm-0.9' into 321-query-chain-stub
assafmo Jun 28, 2020
62acd32
ci also test compute client util
assafmo Jun 29, 2020
363653c
Merge branch 'cosmwasm-0.9' into 321-query-chain-stub
assafmo Jun 29, 2020
793439e
Merge pull request #322 from enigmampc/321-query-chain-stub
assafmo Jun 29, 2020
8600aa6
Temp fix for azure CI (#324)
Cashmaney Jun 29, 2020
4595aed
semantics
assafmo Jun 29, 2020
4f2719b
Merge branch 'cosmwasm-0.9' of github.com:enigmampc/SecretNetwork int…
assafmo Jun 29, 2020
25b24cb
TestInitCallbackAndCallbackEvents
assafmo Jun 29, 2020
3c48635
refactored some error passing between ocalls, enclave, and the host
reuvenpo Jun 29, 2020
3b8382b
exported the cosmwasm_sgx_vm::features::features_from_csv function
reuvenpo Jun 29, 2020
daa0831
TestCallbackToInit + fix output json serialization
assafmo Jun 29, 2020
e62e43a
TestInitCallbackToInit
assafmo Jun 29, 2020
9f3f852
Merge branch 'cosmwasm-0.9' into update-enclave-error-handling
reuvenpo Jun 29, 2020
64a3748
removed unused variants of WasmEngineError
reuvenpo Jun 29, 2020
6b7c1b6
uncommented the code that checked for required features
reuvenpo Jun 29, 2020
0ce368a
try to fix binaryen in the ci
assafmo Jun 29, 2020
e580d16
ci: try again to fix binaryen
assafmo Jun 29, 2020
d50ee83
TestContractError
assafmo Jun 29, 2020
fa0f62f
compile test contracts in a different job
assafmo Jun 29, 2020
a556205
fix ci.yaml indentation
assafmo Jun 29, 2020
b1b5e13
again fix ci.yaml
assafmo Jun 29, 2020
be5992c
TestExecContractError
assafmo Jun 29, 2020
c29bd8e
TestQueryContractError
assafmo Jun 29, 2020
f30adf9
Merge pull request #327 from enigmampc/contract-error-tests
assafmo Jun 29, 2020
72165ab
Merge branch 'cosmwasm-0.9' into update-enclave-error-handling
assafmo Jun 29, 2020
8806932
reverted small change in sgx-vm/src/testing/instance.rs
reuvenpo Jun 29, 2020
3a433f2
fix confusion whether contract.wasm is escrow.wasm or hackatom.wasm …
assafmo Jun 29, 2020
a049b24
Merge branch 'cosmwasm-0.9' into update-enclave-error-handling
assafmo Jun 29, 2020
63ab3a8
reexported wasmi_runtime::crypto::errors::CryptoError under the crypt…
reuvenpo Jun 29, 2020
7e4b595
rename a local variable from encrypted to decrypted
reuvenpo Jun 29, 2020
8f734ed
fix make clean for test-contract
assafmo Jun 29, 2020
3e80159
TestInitCallbackContratError
assafmo Jun 29, 2020
83a1b6f
TestExecCallbackContratError
assafmo Jun 29, 2020
4774d66
test-contract serialize msgs with snake case instead of lower case
assafmo Jun 29, 2020
5546855
skip TestExecuteWithStorageLoop until merge of #307
assafmo Jun 29, 2020
1274326
Merge branch 'cosmwasm-0.9' into update-enclave-error-handling
assafmo Jun 29, 2020
1f16cbc
TestExecuteWithStorageLoop should now work :tada:
assafmo Jun 29, 2020
03e8c9a
I HAVE A THEORY (#328)
Cashmaney Jun 29, 2020
2c85a02
renamed EnclaveBuffer's and UntrustedVmError's method "null" to an im…
reuvenpo Jun 29, 2020
efeb408
added comment explaining what UntrustedVmError is
reuvenpo Jun 29, 2020
9361b05
Merge pull request #307 from enigmampc/update-enclave-error-handling
reuvenpo Jun 29, 2020
1f671db
refactor all tests with setupTest
assafmo Jun 29, 2020
8fbad1f
refactor more tests to use the init & exec helpers
assafmo Jun 29, 2020
306775c
TestInitCallbackBadParam + TestExecCallbackBadParam
assafmo Jun 29, 2020
9736d86
remove misleading builder string in keeper.Create
assafmo Jun 29, 2020
d781379
Cosmwasm 0.9 dev merges (#326)
Cashmaney Jun 30, 2020
cbe6a1b
Merge remote-tracking branch 'remotes/enigmampc/develop' (#335)
Cashmaney Jun 30, 2020
3996e0d
gitignore enigma binaries
assafmo Jun 30, 2020
3c03756
Merge branch 'develop' into cosmwasm-0.9
assafmo Jun 30, 2020
3e05eed
fix merge conflict in makefile
assafmo Jun 30, 2020
34cd186
fix bash tests
assafmo Jun 30, 2020
53a6588
fix key derivation path
assafmo Jun 30, 2020
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
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ third_party/vendor

cosmwasm-js

cosmwasm/lib/incubator-teaclave-sgx-sdk

README.md
.gitignore

Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: [push]

jobs:
test:
Tests:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -42,36 +42,37 @@ jobs:
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
make vendor
cd cosmwasm/lib/wasmi-runtime/
cd cosmwasm/packages/wasmi-runtime/
SGX_MODE=SW make clippy
SGX_MODE=HW make clippy
- name: Build
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
make vendor
SGX_MODE=SW RUSTC_WRAPPER="$HOME/sccache" make build_linux
SGX_MODE=SW BUILD_PROFILE="minimal" RUSTC_WRAPPER="$HOME/sccache" make build-linux
- name: Old bash+js sanity tests
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
export SGX_MODE=SW
mkdir -p ./.sgx_secrets
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/lib/sanity-test.sh
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/testing/sanity-test.sh
- name: Old bash+js sanity callbacks tests
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
export SGX_MODE=SW
mkdir -p ./.sgx_secrets
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/lib/callback-test.sh
- name: Test Registration Module
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/testing/callback-test.sh
- name: Test x/registration
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
go test -v ./x/registration/internal/...
- name: System Tests
- name: Test x/compute
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
export SGX_MODE=SW
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
mkdir -p ./x/compute/internal/keeper/.sgx_secrets
go test -v ./x/compute/client/...
go test -p 1 -v ./x/compute/internal/...
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Enclave_u.h
Enclave_u.o
/secretcli*
/secretd*
/enigmacli*
/enigmad*
incubator-teaclave-sgx-sdk
libenclave.a
libEnclave_u.a
Expand All @@ -22,4 +24,6 @@ SHA256SUMS*
spid.txt
api_key.txt
__debug_bin
id_tx_io.json
id_tx_io.json
.idea
x/compute/internal/keeper/debug.test
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ WORKDIR /go/src/github.com/enigmampc/SecretNetwork/

COPY Makefile Makefile

RUN make clean
# RUN make clean
RUN make vendor

WORKDIR /go/src/github.com/enigmampc/SecretNetwork/go-cosmwasm
Expand Down Expand Up @@ -91,6 +91,8 @@ COPY --from=build-env-rust-go /go/src/github.com/enigmampc/SecretNetwork/go-cosm
COPY --from=build-env-rust-go /go/src/github.com/enigmampc/SecretNetwork/secretd /usr/bin/secretd
COPY --from=build-env-rust-go /go/src/github.com/enigmampc/SecretNetwork/secretcli /usr/bin/secretcli

COPY ./x/compute/internal/keeper/testdata/erc20.wasm erc20.wasm

# COPY ./packaging_docker/devnet_init.sh .
COPY packaging_docker/ci/wasmi-sgx-test.sh .
COPY packaging_docker/ci/bootstrap_init.sh .
Expand All @@ -117,4 +119,4 @@ COPY spid.txt /root/
#ENV LD_LIBRARY_PATH=/opt/sgxsdk/libsgx-enclave-common/:/opt/sgxsdk/lib64/

# Run secretd by default, omit entrypoint to ease using container with secretcli
ENTRYPOINT ["/bin/bash", "startup.sh"]
ENTRYPOINT ["/bin/bash", "startup.sh"]
93 changes: 67 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
BUILD_PROFILE ?= release

SGX_MODE ?= HW
BRANCH ?= develop
DEBUG ?= 0
DOCKER_TAG ?= latest

ifeq ($(SGX_MODE), HW)
ext := hw
else ifeq ($(SGX_MODE), SW)
ext := sw
else
$(error SGX_MODE must be either HW or SW)
endif

SGX_MODE ?= HW
BRANCH ?= develop
Expand Down Expand Up @@ -89,18 +103,13 @@ build_local_no_rust:
go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretd
go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretcli

build_linux: vendor
$(MAKE) -C go-cosmwasm build-rust
cp go-cosmwasm/target/release/libgo_cosmwasm.so go-cosmwasm/api
build-linux: vendor
BUILD_PROFILE=$(BUILD_PROFILE) $(MAKE) -C go-cosmwasm build-rust
cp go-cosmwasm/target/$(BUILD_PROFILE)/libgo_cosmwasm.so go-cosmwasm/api
# this pulls out ELF symbols, 80% size reduction!
go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretd
go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretcli

#build_local_no_rust:
# this pulls out ELF symbols, 80% size reduction!
# go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretd
# go build -mod=readonly $(BUILD_FLAGS) ./cmd/secretcli

build_windows:
# CLI only
$(MAKE) xgo_build_secretcli XGO_TARGET=windows/amd64
Expand All @@ -113,9 +122,9 @@ build_arm_linux:
# CLI only
$(MAKE) xgo_build_secretcli XGO_TARGET=linux/arm64

build_all: build_linux build_windows build_macos build_arm_linux
build_all: build-linux build_windows build_macos build_arm_linux

deb: build_linux
deb: build-linux
ifneq ($(UNAME_S),Linux)
exit 1
endif
Expand Down Expand Up @@ -175,7 +184,8 @@ clean:
-rm -rf ./x/compute/internal/keeper/*.der
-rm -rf ./x/compute/internal/keeper/*.so
$(MAKE) -C go-cosmwasm clean-all
$(MAKE) -C cosmwasm/lib/wasmi-runtime clean
$(MAKE) -C cosmwasm/packages/wasmi-runtime clean
$(MAKE) -C ./x/compute/internal/keeper/testdata/test-contract clean
# docker build --build-arg SGX_MODE=HW --build-arg SECRET_NODE_TYPE=NODE -f Dockerfile.testnet -t cashmaney/secret-network-node:azuretestnet .
build-azure:
docker build -f Dockerfile.azure -t cashmaney/secret-network-node:azuretestnet .
Expand All @@ -188,34 +198,65 @@ docker_bootstrap:
docker build --build-arg SGX_MODE=${SGX_MODE} --build-arg SECRET_NODE_TYPE=BOOTSTRAP -t cashmaney/secret-network-bootstrap-${ext}:${DOCKER_TAG} .

docker_node:
docker build --build-arg SECRET_NODE_TYPE=NODE -t enigmampc/secret_node .

docker build --build-arg SGX_MODE=${SGX_MODE} --build-arg SECRET_NODE_TYPE=NODE -t cashmaney/secret-network-node-${ext}:${DOCKER_TAG} .
# while developing:
build-enclave:
$(MAKE) -C cosmwasm/lib/wasmi-runtime
$(MAKE) -C cosmwasm/packages/wasmi-runtime

# while developing:
check-enclave:
$(MAKE) -C cosmwasm/packages/wasmi-runtime check

# while developing:
clean-enclave:
$(MAKE) -C cosmwasm/lib/wasmi-runtime clean
$(MAKE) -C cosmwasm/packages/wasmi-runtime clean

sanity-test:
SGX_MODE=SW $(MAKE) build_linux
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/lib/sanity-test.sh
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/testing/sanity-test.sh

sanity-test-hw:
$(MAKE) build_linux
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/lib/sanity-test.sh
$(MAKE) build-linux
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
./cosmwasm/testing/sanity-test.sh

callback-sanity-test:
SGX_MODE=SW $(MAKE) build_linux
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/lib/callback-test.sh
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/packages/wasmi-runtime/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

go-tests: build-test-contract
SGX_MODE=SW $(MAKE) build_linux
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
SGX_MODE=SW go test -p 1 -v ./x/compute/internal/...
# empty BUILD_PROFILE means debug mode which compiles faster
SGX_MODE=SW $(MAKE) build-linux
cp ./cosmwasm/packages/wasmi-runtime/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
mkdir -p ./x/compute/internal/keeper/.sgx_secrets
SGX_MODE=SW go test -p 1 -v ./x/compute/internal/...

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

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

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

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

cd ./cosmwasm/contracts/hackatom && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os ./cosmwasm/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
7 changes: 6 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,14 @@ func NewSecretNetworkApp(
}
wasmConfig := wasmWrap.Wasm

supportedFeatures := ""
// replace with bootstrap flag when we figure out how to test properly and everything works
app.regKeeper = reg.NewKeeper(app.cdc, keys[reg.StoreKey], regRouter, reg.EnclaveApi{}, homeDir, app.bootstrap)
app.computeKeeper = compute.NewKeeper(app.cdc, keys[compute.StoreKey], app.accountKeeper, app.bankKeeper, computeRouter, computeDir, wasmConfig)
app.computeKeeper = compute.NewKeeper(
app.cdc,
keys[compute.StoreKey],
app.accountKeeper,
app.bankKeeper, app.stakingKeeper, computeRouter, computeDir, wasmConfig, supportedFeatures, nil, nil)
// register the proposal types
govRouter := gov.NewRouter()
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
Expand Down
2 changes: 1 addition & 1 deletion cmd/secretd/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func ConfigureSecret(_ *server.Context, _ *codec.Codec) *cobra.Command {
if os.IsNotExist(err) {
var file, err = os.Create(path)
if err != nil {
return fmt.Errorf("failed to open config file: %s", path)
return fmt.Errorf("failed to open config file '%s': %w", path, err)
}
_ = file.Close()
}
Expand Down
11 changes: 7 additions & 4 deletions cosmwasm-js/packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "@cosmwasm/sdk",
"version": "0.8.0-alpha.0",
"description": "CosmWasm SDK",
"name": "secretjs",
"version": "0.9.0",
"description": "CosmWasm SDK + Encryption for the Secret Network",
"author": "Ethan Frey <[email protected]>",
"contributors": [
"Enigma <[email protected]> (https://enigma.co)"
],
"license": "Apache-2.0",
"main": "build/index.js",
"types": "types/index.d.ts",
Expand All @@ -15,7 +18,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/confio/cosmwasm-js/tree/master/packages/sdk"
"url": "https://github.com/enigmampc/SecretNetwork/blob/master/cosmwasm-js/packages/sdk"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm-js/packages/sdk/src/cosmwasmclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class CosmWasmClient {
logs: result.logs ? parseLogs(result.logs) : [],
rawLog: result.raw_log || "",
transactionHash: result.txhash,
data: result.data,
data: result.data || "",
};
}

Expand Down
4 changes: 4 additions & 0 deletions cosmwasm-js/packages/sdk/src/enigmautils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export default class EnigmaUtils {
}

public async decrypt(ciphertext: Uint8Array, nonce: Uint8Array): Promise<Uint8Array> {
if (ciphertext.length === 0) {
return new Uint8Array();
}

const { privkey: txSenderPrivKey } = this.getTxSenderKeyPair();
const txEncryptionKey = await this.getTxEncryptionKey(txSenderPrivKey, nonce);

Expand Down
2 changes: 1 addition & 1 deletion cosmwasm-js/packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export {
SearchTxQuery,
SearchTxFilter,
} from "./cosmwasmclient";
export { makeCosmoshubPath, Pen, PrehashType, Secp256k1Pen } from "./pen";
export { makeSecretNetworkPath as makeCosmoshubPath, Pen, PrehashType, Secp256k1Pen } from "./pen";
export { decodeBech32Pubkey, encodeBech32Pubkey, encodeSecp256k1Pubkey } from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
Expand Down
6 changes: 3 additions & 3 deletions cosmwasm-js/packages/sdk/src/pen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array {
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
* with 0-based account index `a`.
*/
export function makeCosmoshubPath(a: number): readonly Slip10RawIndex[] {
export function makeSecretNetworkPath(a: number): readonly Slip10RawIndex[] {
return [
Slip10RawIndex.hardened(44),
Slip10RawIndex.hardened(118),
Slip10RawIndex.hardened(529),
Slip10RawIndex.hardened(0),
Slip10RawIndex.normal(0),
Slip10RawIndex.normal(a),
Expand All @@ -59,7 +59,7 @@ export function makeCosmoshubPath(a: number): readonly Slip10RawIndex[] {
export class Secp256k1Pen implements Pen {
public static async fromMnemonic(
mnemonic: string,
hdPath: readonly Slip10RawIndex[] = makeCosmoshubPath(0),
hdPath: readonly Slip10RawIndex[] = makeSecretNetworkPath(0),
): Promise<Secp256k1Pen> {
const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic));
const { privkey } = Slip10.derivePath(Slip10Curve.Secp256k1, seed, hdPath);
Expand Down
Loading