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

Contract Upgrade #1449

Merged
merged 172 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
999eb6c
Import migrations protos from wasmd
assafmo Jan 19, 2023
d52cc7a
Store admin on init
assafmo Feb 6, 2023
14e05eb
Add MigrateContract, UpdateAdmin & ClearAdmin to MsgServer
assafmo Feb 6, 2023
e3f8dff
checkpoint
assafmo Feb 8, 2023
1233992
Things are compiling
assafmo Feb 13, 2023
977948e
Checkpoint: some progress passing admin into the enclave on init()
assafmo Feb 19, 2023
43ea6d5
Merge remote-tracking branch 'origin/master' into HEAD
Cashmaney May 22, 2023
bd2006a
Added migrate flow and admin proof for contract upgrades.
Cashmaney May 22, 2023
efe5269
Changed contract key to new format
Cashmaney May 22, 2023
9e5d930
Basic migrate works:)
Cashmaney May 23, 2023
be73d99
Tests are back online boys
Cashmaney May 23, 2023
652a3a3
forgot to commit the contracts for the migrate test
Cashmaney May 23, 2023
fbe8ccd
Deriving admin proof from contract_key
Cashmaney May 24, 2023
95b74ee
Making clippy happy
Cashmaney May 24, 2023
2e01065
Merge branch 'master' into contract-upgrade-v2
Cashmaney May 31, 2023
e86e395
Merge remote-tracking branch 'origin/master' into contract-upgrade-v2
assafmo Jun 5, 2023
4f9ae7e
Lint
assafmo Jun 5, 2023
e3ee65d
Register Msg{Update,Clear}Admin
assafmo Jun 6, 2023
9b0560f
Point CI to the appropriate secretjs branch
assafmo Jun 6, 2023
f3b09c7
Fill in some missing message implementations
assafmo Jun 6, 2023
415672e
Merge remote-tracking branch 'origin/master' into contract-upgrade-v2
assafmo Jun 11, 2023
78656e4
MsgIns:antiateContract: make admin a string
assafmo Jun 12, 2023
3a48ff6
Rebuild protobufs
assafmo Jun 12, 2023
08502da
Update enclave types for string init admin
assafmo Jun 12, 2023
614cb13
Fix Amino MsgMigrateContract inside the enclave
assafmo Jun 13, 2023
869095f
Rename Amino & Direct sturcts inside the enclave
assafmo Jun 13, 2023
d52d739
Fix protobuf stuff & rename test functions
assafmo Jun 13, 2023
0bafad5
Cont. to fix protobuf stuff & rename things
assafmo Jun 13, 2023
6e73847
Implement ContractHistory query
assafmo Jun 13, 2023
04c3391
Fix null admin
assafmo Jun 13, 2023
26acec7
Fix null admin Amino parsing inside the enclave
assafmo Jun 13, 2023
61e98ea
Fix contractHistory query from CLI
assafmo Jun 13, 2023
da0aae2
Add admin param to init tests
assafmo Jun 13, 2023
35d47b7
TestContractInfoAdmin & TestContractInfoNullAdmin
assafmo Jun 13, 2023
9b94627
Fix TestCheckGas
assafmo Jun 13, 2023
19cc11e
Fix TestConsumeExact
assafmo Jun 13, 2023
bc34a4d
lint
assafmo Jun 14, 2023
7bd852a
Rename ContractInfo to contract_info
assafmo Jun 14, 2023
18d32bd
Fix ambiguous err var segfaults after migrate
assafmo Jun 14, 2023
4c29eb4
Use migrate error code when mograte fails
assafmo Jun 14, 2023
a1ae101
lint
assafmo Jun 14, 2023
ee1bab9
TestMigrateStdError
assafmo Jun 14, 2023
9dda5ce
Verify init admin field inside the enclave
assafmo Jun 15, 2023
cbf0818
TestInputAdminMismatch
assafmo Jun 15, 2023
c08d1bf
Verify migrate admin inside the enclave
assafmo Jun 15, 2023
f608d41
Fix admin_sig on init
assafmo Jun 20, 2023
f4da131
Refactor some of the enclave validation code
assafmo Jun 20, 2023
0b7555a
Add admin_proof_secret & contract_key_proof_secret
assafmo Jun 20, 2023
f0b92f4
Implement update admin inside the enclave
assafmo Jun 26, 2023
3d79d50
Bypass weird C compiler error in ffi-types
assafmo Jun 27, 2023
585b429
Refactor contract_key validation & fix it in query
assafmo Jun 27, 2023
a499efe
Fix CI
assafmo Jun 27, 2023
bfb09df
Copy all exec tests and modify to test after migrate
assafmo Jun 28, 2023
fb02097
Fix TestRandomEnvAfterMigrate
assafmo Jun 28, 2023
c84ea98
Alias query for `secretcli q wasm smart`
assafmo Jun 28, 2023
fbccfb7
Fix updating of contract_key after a migrate & refactor contract_key …
assafmo Jun 28, 2023
0a371f7
clippy
assafmo Jun 29, 2023
a457796
Copy execute behavior to migrate in test contract
assafmo Jun 30, 2023
1f85986
Change a println!() to a trace!()
assafmo Jun 30, 2023
38231a2
Copy all exec tests and modify to test migrate
assafmo Jun 30, 2023
ff15766
Update codeID in contractInfo on migrate
assafmo Jul 2, 2023
105a9d9
Fix AminoSdkMsg deserialization of Msg{Update,Clear}Admin
assafmo Jul 2, 2023
47c1a8c
Fix verify_and_get_sdk_msg() of Msg{Update,Clear}Admin
assafmo Jul 2, 2023
d8dc1e6
Fix TestCheckGas
assafmo Jul 2, 2023
f00a813
Fix TestConsumeExact
assafmo Jul 3, 2023
ef51d8a
Copy all query tests and modify to test during and after migrate
assafmo Jul 3, 2023
3f3ce5d
Merge branch 'master' into contract-upgrade-v2
assafmo Jul 3, 2023
2e9df9a
Copy all submsg tests and modify to test during and after migrate
assafmo Jul 4, 2023
c40d891
More migrate/update admin tests
assafmo Jul 4, 2023
3171ca5
Test fake admin vlaues passed to the enclave
assafmo Jul 4, 2023
9f0cea7
enigma.co -> scrtlabs.com
assafmo Jul 5, 2023
2befcec
Add support for contracts sending Migrate/Update/Clear messages
assafmo Jul 5, 2023
d1f1d33
Fix `make build-test-contracts` sometimes not overwriting target wasm
assafmo Jul 6, 2023
eb2c0ff
Fix update admin not setting new admin & write a bunch of tests
assafmo Jul 11, 2023
dcf863f
clippy
assafmo Jul 13, 2023
1405304
Fix wasm files not in place for CI
assafmo Jul 13, 2023
7262ad6
clippy
assafmo Jul 13, 2023
52e3c83
Refactor light client
assafmo Jul 13, 2023
3f3aa6f
Fix enclave compilation
assafmo Jul 13, 2023
83764e0
Test migration of IBC contracts
assafmo Jul 16, 2023
1e9bb71
Write store migration for admin & contractKey
assafmo Jul 16, 2023
139a0eb
Make v1.2 (Supernova) migrations compile after v1.10 type changes
assafmo Jul 16, 2023
fe7457a
CHANGELOG: Add contract upgrade
assafmo Jul 17, 2023
271f063
Fix typo in changelog
assafmo Jul 17, 2023
863fd95
CI: try to fix linting for auto generated go-bindata code
assafmo Jul 17, 2023
b041426
Fix YAML syntax of go-lint.yml
assafmo Jul 17, 2023
cfcf17f
Add hardcoded contract admin check in the enclave
assafmo Jul 17, 2023
14a3b1c
Fix CI linter?
assafmo Jul 17, 2023
d515dff
typo
assafmo Jul 17, 2023
2f9260c
Fix hardcoded admin check in the enclave
assafmo Jul 17, 2023
37c0b57
Create a CW v0.10 contract with migrate()
assafmo Jul 17, 2023
a5185bf
Fix Cargo.toml, copy handle logic to migrate in v0.10 test migrate co…
assafmo Jul 17, 2023
08856c3
Make v0.10 test migrate contract compile
assafmo Jul 18, 2023
fbc872f
Fix v0.10 test migrate contract
assafmo Jul 18, 2023
cf36901
FIx a parsing issue to make v0.10 contract upgrade work!
assafmo Jul 18, 2023
941df10
Test migrating contracts between all scenarios of (v0.10,v1)
assafmo Jul 18, 2023
0366af1
Fix all v0.10 contract upgrade tests
assafmo Jul 18, 2023
0b4cd8d
Merge branch 'master' into contract-upgrade-v2
assafmo Jul 19, 2023
4a7c182
Fix CI linting?
assafmo Jul 19, 2023
4f94908
Update deps
assafmo Jul 19, 2023
9779337
LocalSecret: enable light client msgs validation
assafmo Jul 19, 2023
54cccba
Derive current_contract_key from og_contract_key as well
assafmo Jul 19, 2023
c618f9d
CI: enable light client msgs validation for LocalSecret
assafmo Jul 19, 2023
65d66b3
CI: fix setting up v0.10 test migrate contract in testdata directory
assafmo Jul 19, 2023
60e6d41
CI: fix setting up v0.10 test migrate contract for go tests
assafmo Jul 19, 2023
ba52635
Remove query-node remnants
assafmo Jul 23, 2023
770f51a
Remove query-node remnants
assafmo Jul 26, 2023
76c4331
Allow tests to skip light client validation
assafmo Jul 26, 2023
a40c8a7
Fix light client verification for ibc-hooks & admin txs
assafmo Jul 26, 2023
f29c579
Use TxBytes isnteda of SignBytes for light client verification
assafmo Jul 26, 2023
383c636
Fix IBC messages drop from the mempool
assafmo Jul 30, 2023
49e24ad
Refactor log messages
assafmo Jul 30, 2023
280ed5f
Fix `SignDoc::from_bytes()` to parse according to `type_url` instead …
assafmo Jul 30, 2023
27e05a4
Fix code review notes
assafmo Jul 30, 2023
1b71679
Fix go tests in CI?
assafmo Jul 30, 2023
0d0b32f
Fix Enclave-Unit-Tests CI?
assafmo Jul 30, 2023
d05a138
CI: Skip linter check of auto generated files
assafmo Jul 30, 2023
7c43a18
CI: Try to fix golangci-lint for the millionth time
assafmo Jul 30, 2023
3133ecc
CI: Try to fix golangci-lint for the gazillionth time
assafmo Jul 30, 2023
fa1a33a
CI: Try to fix golangci-lint for the bazillionth time
assafmo Jul 30, 2023
ffdc0e4
CI: Build-LocalSecret with the go-tests feature to skip light client …
assafmo Jul 30, 2023
754cac3
go mod tidy
assafmo Jul 30, 2023
ce56e61
CI: Try to fix golangci-lint for the bajillionth time
assafmo Jul 30, 2023
10310c0
Hmmm
assafmo Jul 30, 2023
52a4ae0
Huh?
assafmo Jul 30, 2023
42bce5c
Try to bust the CI LocalSecret cache to hopefully make ffdc0e4 work
assafmo Jul 30, 2023
71326f4
Try to fix go tests in the CI
assafmo Jul 30, 2023
0d7cea0
Fucking A
assafmo Jul 30, 2023
c8e4b59
Fix syntax error in ci.yaml
assafmo Jul 30, 2023
5c8772d
CI: disable cache fobur Build-LocalSecret (debugging why go tests fail)
assafmo Jul 31, 2023
4c41dca
CI: try setting env in a different way (debugging why go tests fail)
assafmo Jul 31, 2023
1c0f5e5
Revert "CI: disable cache fobur Build-LocalSecret (debugging why go t…
assafmo Jul 31, 2023
eb39d32
Make sure the "go-tests" feature can't be used with the "production" …
assafmo Jul 31, 2023
90b6081
CI: try setting env in a different way (debugging why go tests fail)
assafmo Jul 31, 2023
b0486de
Fix cfg compilation (or -> any)
assafmo Jul 31, 2023
047a723
CI: install xargo in Go-Tests for tm-secret-enclave
assafmo Jul 31, 2023
4230622
CI: Try to fix compiling tm-secret-enclave in Go-Tests
assafmo Jul 31, 2023
049e75e
IBC Hooks: send acks & timeouts to `sudo()` instead of `execute()`
assafmo Jul 31, 2023
678b720
Update ibc-hooks docs
assafmo Jul 31, 2023
53637cb
CI: Debug prints for Go-Tests
assafmo Jul 31, 2023
05a1446
Revert 90b608191cf4a675962abc18cd26ebcb70f73849 to see CI debug print…
assafmo Jul 31, 2023
89a31cd
Try to fix the CI for the kazillionnt time
assafmo Jul 31, 2023
0220403
Huh?
assafmo Jul 31, 2023
e4251a5
Shooting for the moon at this point
assafmo Jul 31, 2023
1c80122
🤔
assafmo Jul 31, 2023
70d9981
???
assafmo Jul 31, 2023
c6f84e7
:facepalm:
assafmo Jul 31, 2023
33889ed
Revert "🤔"
assafmo Jul 31, 2023
2f57132
Try something
assafmo Jul 31, 2023
99fda9c
Try something
assafmo Jul 31, 2023
aca987a
Try something 3
assafmo Jul 31, 2023
0b6ce5c
Try something 4
assafmo Aug 1, 2023
9baace1
Merge branch 'master' into contract-upgrade-v2
assafmo Aug 1, 2023
3a988d4
Merge pull request #1493 from scrtlabs/ibc-hooks-sudo
assafmo Aug 1, 2023
aebaf2f
callback_sig code comments
assafmo Aug 1, 2023
d7b3548
Update some Cargo.locks
assafmo Aug 1, 2023
b0e9598
Small refactor
assafmo Aug 1, 2023
9fa5c8b
Simplify cannot use 'go-tests' & 'production' features together
assafmo Aug 1, 2023
4faf6eb
Remove CI debug prints
assafmo Aug 1, 2023
a642bdb
Fix typo in error log
assafmo Aug 1, 2023
775df5d
clippy
assafmo Aug 1, 2023
d957687
Refactor go-tests features
assafmo Aug 2, 2023
c01b07b
Fix make sure the "go-tests" feature can't be used with the "producti…
assafmo Aug 2, 2023
80f80b0
Use HMAC for contract_key_proof & admin_proof
assafmo Aug 2, 2023
66d3b33
Move generate_admin_proof
assafmo Aug 2, 2023
10c4c75
Implement is_code_hash_allowed()
assafmo Aug 2, 2023
3bea166
clippy
assafmo Aug 2, 2023
72fdda8
Update Dockerfile
Cashmaney Aug 1, 2023
5d80ceb
Check max length of the block data sent into the enclave
assafmo Aug 3, 2023
e2150af
Remove old commented out code
assafmo Aug 3, 2023
29ca157
Cargo.lock \o/
assafmo Aug 3, 2023
f782cde
Check max length of the contract calls sent into the enclave
assafmo Aug 3, 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
18 changes: 13 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
./scripts/install-wasm-tools.sh
- name: Build Contracts
run: |
make build-test-contract
make build-test-contracts
cp x/compute/internal/keeper/testdata/erc20.wasm .
- uses: actions/upload-artifact@v3
with:
Expand All @@ -81,6 +81,10 @@ jobs:
with:
name: contract.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract/contract.wasm
- uses: actions/upload-artifact@v3
with:
name: contract-v2.wasm
path: cosmwasm/contracts/v010/compute-tests/test-compute-contract-v2/contract-v2.wasm
- uses: actions/upload-artifact@v3
with:
name: v1-contract.wasm
Expand Down Expand Up @@ -133,10 +137,12 @@ jobs:
docker run -v $PWD:/opt/mount --rm --entrypoint cp ghcr.io/scrtlabs/localsecret:v0.0.0 /usr/lib/librust_cosmwasm_enclave.signed.so /opt/mount/librust_cosmwasm_enclave.signed.so
docker run -v $PWD:/opt/mount --rm --entrypoint cp ghcr.io/scrtlabs/localsecret:v0.0.0 /usr/lib/librandom_api.so /opt/mount/librandom_api.so
docker run -v $PWD:/opt/mount --rm --entrypoint cp ghcr.io/scrtlabs/localsecret:v0.0.0 /usr/lib/tendermint_enclave.signed.so /opt/mount/tendermint_enclave.signed.so

- uses: actions/download-artifact@v3
with:
name: contract.wasm
- uses: actions/download-artifact@v3
with:
name: contract-v2.wasm
- uses: actions/download-artifact@v3
with:
name: v1-contract.wasm
Expand All @@ -162,6 +168,7 @@ jobs:
# cp /opt/mount/librandom_api.so /usr/lib/librandom_api.so
# cp /opt/mount/tendermint_enclave.signed.so /usr/lib/tendermint_enclave.signed.so
cp contract.wasm ./x/compute/internal/keeper/testdata/contract.wasm
cp contract-v2.wasm ./x/compute/internal/keeper/testdata/contract-v2.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
Expand All @@ -175,12 +182,13 @@ jobs:
source "$HOME/.sgxsdk/sgxsdk/environment"
export SGX_MODE=SW
cp librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
# cp tendermint_enclave.signed.so ./x/compute/internal/keeper
mkdir -p ias_keys/develop
mkdir -p /opt/secret/.sgx_secrets/
echo "not_a_key" > ias_keys/develop/spid.txt
echo "not_a_key" > ias_keys/develop/api_key.txt
LOG_LEVEL=ERROR go test -v -tags "test" ./x/compute/client/...
LOG_LEVEL=ERROR go test -p 1 -timeout 90m -v -tags "test" ./x/compute/internal/...
LOG_LEVEL=ERROR SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -p 1 -timeout 90m -v -tags "test" ./x/compute/internal/...

Clippy:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -276,7 +284,7 @@ jobs:
build-args: |
SECRET_NODE_TYPE=BOOTSTRAP
CHAIN_ID=secretdev-1
FEATURES=debug-print,random
FEATURES_U=debug-print,random,light-client-validation,go-tests
SGX_MODE=SW
target: build-localsecret
cache-from: type=gha
Expand Down Expand Up @@ -341,7 +349,7 @@ jobs:
make kill-localsecret # next step needs the localsecret ports
- name: Run secret.js tests
run: |
git clone --depth 1 --branch master https://github.com/scrtlabs/secret.js
git clone --depth 1 --branch contract-upgrade-v2 https://github.com/scrtlabs/secret.js
cd secret.js
# Use the docker images that we built just a few steps above
perl -i -pe 's/localsecret:.+?"/localsecret:v0.0.0"/' ./test/docker-compose.yml
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ jobs:
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: make bin-data-sw
run: |
go install github.com/jteeuwen/go-bindata/go-bindata@latest
make bin-data-sw
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.53.2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ secretcli*
libenclave.a
libEnclave_u.a
librust_cosmwasm_enclave.signed.so
tendermint_enclave.signed.so
*.o
/release
SHA256SUMS*
Expand Down
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
skip-files:
- x/registration/internal/types/reg_keys.go # uses auto generated code
- x/registration/internal/types/ias_bin.*?.go # auto generated

linters:
disable-all: true
Expand Down
9 changes: 8 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
"mode": "debug",
"program": "${file}",
"cwd": "${workspaceFolder}/x/compute/internal/keeper",
"env": { "SGX_MODE": "SW", "RUST_BACKTRACE": "1" },
"env": {
"SGX_MODE": "SW",
"RUST_BACKTRACE": "1",
"LOG_LEVEL": "TRACE",
"SKIP_LIGHT_CLIENT_VALIDATION": "true"
},
"args": [
"test",
"-tags",
"sgx",
"-timeout",
"1200s",
"-p",
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
"third_party/build/Cargo.toml",
"cosmwasm/enclaves/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/test-compute-contract/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/test-compute-contract-v2/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/ibc-test-contract/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/bench-contract/Cargo.toml",
"cosmwasm/contracts/v010/compute-tests/test-compute-contract/Cargo.toml",
"cosmwasm/contracts/v010/compute-tests/test-compute-contract-v2/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/migration/contract-v1/Cargo.toml",
"cosmwasm/contracts/v1/compute-tests/migration/contract-v2/Cargo.toml",
"integration-tests/contract-v1/Cargo.toml",
"integration-tests/contract-v0.10/Cargo.toml",
"go-cosmwasm/Cargo.toml",
"cosmwasm/enclaves/shared/cosmos-proto/Cargo.toml",
"cosmwasm/enclaves/shared/contract-engine/Cargo.toml"
"cosmwasm/enclaves/shared/contract-engine/Cargo.toml",
"cosmwasm/enclaves/shared/utils/Cargo.toml",
"cosmwasm/enclaves/shared/block-verifier/Cargo.toml"
],
"rust-analyzer.diagnostics.experimental.enable": true,
"rust-analyzer.rustfmt.rangeFormatting.enable": true,
Expand All @@ -31,6 +37,7 @@
"SGX_MODE": "SW",
"RUST_BACKTRACE": "1"
},
"go.buildTags": "sgx",
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint",
"go.lintOnSave": "workspace",
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
# 1.10.0 (Unreleased - WIP)

- Added ibc-hooks middleware by Osmosis.
- WASM Hooks: allows ICS-20 token transfers to initiate contract calls, serving various use cases.
- WASM hooks: allows ICS-20 token transfers to initiate contract calls, serving various use cases.
- Example: Sending tokens to Secret and immediately wrapping them as SNIP-20 token. For example, `ATOM on Hub -> ATOM on Secret -> sATOMS on Secret` (2 transactions on 2 chains) now becomes `ATOM on Hub -> sATOM on Secret` (1 transaction).
- Example: Cross-chain swaps. Using IBC Hooks, an AMM on Secret can atomically swap tokens that originated on a different chain and are headed to Secret. The AMM can also send those tokens back to the originating chain.
- [Axelar GMP](https://docs.axelar.dev/dev/general-message-passing/overview): Using IBC Hooks, a contract on Ethereum can call a contract on Secret and get a response back.
- Ack callbacks: allow non-IBC contracts that send an `IbcMsg::Transfer` to listen for the ack/timeout of the token transfer. This allows these contracts to definitively know whether the transfer was successful or not and act accordingly (refund if failed, continue if succeeded). See usage example [here](https://github.com/scrtlabs/secret.js/blob/4293219/test/ibc-hooks-contract/src/contract.rs#L47-L91).
- Added and optional `memo` field to `IbcMsg::Transfer`, to ease to use of the IBC Hooks ack callbacks feature. See usage example [here](https://github.com/scrtlabs/secret.js/blob/4293219/test/ibc-hooks-contract/src/contract.rs#L60-L63).
- Added an optional `memo` field to `IbcMsg::Transfer`, to ease to use of the IBC Hooks ack callbacks feature. See usage example [here](https://github.com/scrtlabs/secret.js/blob/4293219/test/ibc-hooks-contract/src/contract.rs#L60-L63).
- Added contract upgrade feature.
- On init, the creator can specify an admin address.
- The admin can migrate the contract to a new code ID.
- The admin can update or clear the admin address.
- The admins of contracts that were instantiated before v1.10 are hardcoded according to [proposal TODO](https://www.mintscan.io/secret/proposals/TODO).
- Hardcoded admins can only be updated/cleared with a future gov proposal.
- When the new MsgMigrateContract is invoked, the `migrate()` function is being called on the new contract code, where the new contract can optionally perform state migrations. See usage example [here](https://github.com/scrtlabs/SecretNetwork/blob/139a0eb18/cosmwasm/contracts/v1/compute-tests/migration/contract-v2/src/contract.rs#L37-L43).
- Fixed a scenario where the enclave's light client might fail a valid node registration transaction.

# 1.9.3

Expand Down
78 changes: 55 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ 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/
DOCKER_BUILD_ARGS ?=

DOCKER_BUILDX_CHECK = $(@shell docker build --load test)
Expand Down Expand Up @@ -166,11 +165,13 @@ build-secret: build-linux

build-linux: _build-linux build_local_no_rust build_cli
_build-linux:
BUILD_PROFILE=$(BUILD_PROFILE) FEATURES=$(FEATURES) FEATURES_U=$(FEATURES_U) $(MAKE) -C go-cosmwasm build-rust
BUILD_PROFILE=$(BUILD_PROFILE) FEATURES="$(FEATURES)" FEATURES_U="$(FEATURES_U) light-client-validation go-tests" $(MAKE) -C go-cosmwasm build-rust

build-linux-with-query: _build-linux-with-query build_local_no_rust build_cli
_build-linux-with-query:
BUILD_PROFILE=$(BUILD_PROFILE) FEATURES=$(FEATURES) FEATURES_U=query-node,$(FEATURES_U) $(MAKE) -C go-cosmwasm build-rust
build-tm-secret-enclave:
git clone https://github.com/scrtlabs/tm-secret-enclave.git /tmp/tm-secret-enclave || true
cd /tmp/tm-secret-enclave && git checkout v1.9.3 && git submodule init && git submodule update --remote
rustup component add rust-src
SGX_MODE=$(SGX_MODE) $(MAKE) -C /tmp/tm-secret-enclave build

build_windows_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=windows/amd64
Expand Down Expand Up @@ -244,7 +245,7 @@ clean:

localsecret:
DOCKER_BUILDKIT=1 docker build \
--build-arg FEATURES="${FEATURES},debug-print,random" \
--build-arg FEATURES="${FEATURES},debug-print,random,light-client-validation" \
--build-arg FEATURES_U=${FEATURES_U} \
--secret id=API_KEY,src=.env.local \
--secret id=SPID,src=.env.local \
Expand Down Expand Up @@ -416,39 +417,70 @@ build-bench-contract:
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/bench-contract
cp $(TEST_CONTRACT_V1_PATH)/bench-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/

build-test-contract:
build-test-contracts:
# echo "" | sudo add-apt-repository ppa:hnakamur/binaryen
# sudo apt update
# sudo apt install -y binaryen
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/

rm -f $(TEST_COMPUTE_MODULE_PATH)/contract.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/contract.wasm $(TEST_COMPUTE_MODULE_PATH)/contract.wasm

rm -f $(TEST_COMPUTE_MODULE_PATH)/contract_with_floats.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/contract_with_floats.wasm $(TEST_COMPUTE_MODULE_PATH)/contract_with_floats.wasm

rm -f $(TEST_COMPUTE_MODULE_PATH)/static-too-high-initial-memory.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/static-too-high-initial-memory.wasm $(TEST_COMPUTE_MODULE_PATH)/static-too-high-initial-memory.wasm

rm -f $(TEST_COMPUTE_MODULE_PATH)/too-high-initial-memory.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/too-high-initial-memory.wasm $(TEST_COMPUTE_MODULE_PATH)/too-high-initial-memory.wasm

$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract-v2

rm -f $(TEST_COMPUTE_MODULE_PATH)/contract-v2.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract-v2/contract-v2.wasm $(TEST_COMPUTE_MODULE_PATH)/contract-v2.wasm

$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/
rm -f $(TEST_COMPUTE_MODULE_PATH)/v1-contract.wasm
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract/v1-contract.wasm $(TEST_COMPUTE_MODULE_PATH)/v1-contract.wasm

$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2
rm -f $(TEST_COMPUTE_MODULE_PATH)/v1-contract-v2.wasm
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2/v1-contract-v2.wasm $(TEST_COMPUTE_MODULE_PATH)/v1-contract-v2.wasm

$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/ibc-test-contract
cp $(TEST_CONTRACT_V1_PATH)/ibc-test-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/
rm -f $(TEST_COMPUTE_MODULE_PATH)/ibc.wasm
cp $(TEST_CONTRACT_V1_PATH)/ibc-test-contract/ibc.wasm $(TEST_COMPUTE_MODULE_PATH)/ibc.wasm

$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/migration/contract-v1
rm -f $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v1.wasm
cp $(TEST_CONTRACT_V1_PATH)/migration/contract-v1/migrate_contract_v1.wasm $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v1.wasm

$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/migration/contract-v2
rm -f $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v2.wasm
cp $(TEST_CONTRACT_V1_PATH)/migration/contract-v2/migrate_contract_v2.wasm $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v2.wasm

prep-go-tests: build-test-contract bin-data-sw

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

go-tests: build-test-contract bin-data-sw
go-tests: build-test-contracts bin-data-sw
# SGX_MODE=SW $(MAKE) build-tm-secret-enclave
# cp /tmp/tm-secret-enclave/tendermint_enclave.signed.so ./x/compute/internal/keeper
SGX_MODE=SW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
#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 -count 1 -failfast -timeout 90m -v ./x/compute/internal/... $(GO_TEST_ARGS)
GOMAXPROCS=8 SGX_MODE=SW SCRT_SGX_STORAGE='./' SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -count 1 -failfast -timeout 90m -v ./x/compute/internal/... $(GO_TEST_ARGS)

go-tests-hw: build-test-contract bin-data
go-tests-hw: build-test-contracts bin-data
# empty BUILD_PROFILE means debug mode which compiles faster
# SGX_MODE=HW $(MAKE) build-tm-secret-enclave
# cp /tmp/tm-secret-enclave/tendermint_enclave.signed.so ./x/compute/internal/keeper
SGX_MODE=HW $(MAKE) build-linux
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)
GOMAXPROCS=8 SGX_MODE=HW SCRT_SGX_STORAGE='./' SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -v ./x/compute/internal/... $(GO_TEST_ARGS)

# When running this more than once, after the first time you'll want to remove the contents of the `ffi-types`
# rule in the Makefile in `enclaves/execute`. This is to speed up the compilation time of tests and speed up the
Expand All @@ -457,7 +489,7 @@ go-tests-hw: build-test-contract bin-data
enclave-tests:
$(MAKE) -C cosmwasm/enclaves/test run

build-all-test-contracts: build-test-contract
build-all-test-contracts: build-test-contracts
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

Expand All @@ -483,7 +515,7 @@ build-all-test-contracts: build-test-contract
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
build-erc20-contract: build-test-contracts
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

Expand Down
35 changes: 34 additions & 1 deletion client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Secret Network",
"description": "A REST interface for queries and transactions",
"version": "v1.8"
"version": "v1.10"
},
"apis": [
{
Expand Down Expand Up @@ -171,6 +171,17 @@
}
}
},
{
"url": "../../tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "../../tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.jsonParams",
"Pool": "../../tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.jsonPool",
"DelegatorValidators": "../../tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.jsonDelegatorValidators",
"UpgradedConsensusState": "../../tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.jsonUpgradedConsensusState"
}
}
},
{
"url": "../../tmp-swagger-gen/ibc/applications/interchain_accounts/controller/v1/query.swagger.json",
"operationIds": {
Expand All @@ -193,6 +204,17 @@
}
}
},
{
"url": "../../tmp-swagger-gen/ibc/applications/packetforward/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "../../tmp-swagger-gen/ibc/applications/packetforward/v1/query.swagger.jsonParams",
"Pool": "../../tmp-swagger-gen/ibc/applications/packetforward/v1/query.swagger.jsonPool",
"DelegatorValidators": "../../tmp-swagger-gen/ibc/applications/packetforward/v1/query.swagger.jsonDelegatorValidators",
"UpgradedConsensusState": "../../tmp-swagger-gen/ibc/applications/packetforward/v1/query.swagger.jsonUpgradedConsensusState"
}
}
},
{
"url": "../../tmp-swagger-gen/ibc/applications/transfer/v1/query.swagger.json",
"operationIds": {
Expand Down Expand Up @@ -248,6 +270,17 @@
}
}
},
{
"url": "../../tmp-swagger-gen/secret/emergencybutton/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "../../tmp-swagger-gen/secret/emergencybutton/v1beta1/query.swagger.jsonParams",
"Pool": "../../tmp-swagger-gen/secret/emergencybutton/v1beta1/query.swagger.jsonPool",
"DelegatorValidators": "../../tmp-swagger-gen/secret/emergencybutton/v1beta1/query.swagger.jsonDelegatorValidators",
"UpgradedConsensusState": "../../tmp-swagger-gen/secret/emergencybutton/v1beta1/query.swagger.jsonUpgradedConsensusState"
}
}
},
{
"url": "../../tmp-swagger-gen/secret/intertx/v1beta1/query.swagger.json",
"operationIds": {
Expand Down
Loading
Loading