Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/eshel-ibc' into cosmwasm-v1-with…
Browse files Browse the repository at this point in the history
…-every
  • Loading branch information
Lior Bondarevski committed Aug 31, 2022
2 parents 109352a + 30a4318 commit cc98d0a
Show file tree
Hide file tree
Showing 140 changed files with 11,621 additions and 3,192 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jobs:
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 ./x/compute/client/...
LOG_LEVEL=ERROR go test -p 1 -timeout 20m -v ./x/compute/internal/...
LOG_LEVEL=ERROR go test -p 1 -timeout 40m -v ./x/compute/internal/...
Clippy:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -294,15 +294,21 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build docker testnet
- name: Build LocalSecret
run: |
echo not_a_key | tee {api_key,spid}.txt
DOCKER_TAG=v0.0.0 make build-localsecret
- name: Run integration tests
run: |
cd integration-tests
yarn
docker run -d -p 9091:9091 --name localsecret ghcr.io/scrtlabs/localsecret:v0.0.0
sleep 30
docker logs localsecret
yarn test
- name: Run secret.js tests
run: |
git clone --depth 1 https://github.com/scrtlabs/secret.js
# Copy v1 contract to tests directory
cp ./target/wasm32-unknown-unknown/release/v1_sanity_contract.wasm ./secret.js/test/test_contract_v1.wasm
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/*
Expand Down
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"request": "launch",
"mode": "debug",
"program": "${file}",
"cwd": "${workspaceFolder}/x/compute/internal/keeper",
"env": { "SGX_MODE": "SW", "RUST_BACKTRACE": "1" },
"args": [
"test",
Expand Down
13 changes: 8 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"rust-analyzer.linkedProjects": [
"./cosmwasm/Cargo.toml",
"./cosmwasm/enclaves/Cargo.toml",
"./x/compute/internal/keeper/testdata/v1-sanity-contract/Cargo.toml",
"./x/compute/internal/keeper/testdata/test-contract/Cargo.toml"
"cosmwasm/Cargo.toml",
"cosmwasm/enclaves/Cargo.toml",
"x/compute/internal/keeper/testdata/v1-sanity-contract/Cargo.toml",
"x/compute/internal/keeper/testdata/test-contract/Cargo.toml",
"./x/compute/internal/keeper/testdata/ibc/Cargo.toml",
"integration-tests/contract-v1/Cargo.toml",
"integration-tests/contract-v0.10/Cargo.toml",
"go-cosmwasm/Cargo.toml"
],
"rust-analyzer.diagnostics.experimental.enable": true,
"rust-analyzer.rustfmt.rangeFormatting.enable": true,
Expand All @@ -20,7 +24,6 @@
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint",
"go.lintOnSave": "workspace",
"go.buildTags": "secretcli",
"gopls": {
"formatting.gofumpt": true
},
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ build-test-contract:
# 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


prep-go-tests: build-test-contract
Expand All @@ -361,7 +362,7 @@ go-tests: build-test-contract
cp ./cosmwasm/enclaves/execute/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=SW SCRT_SGX_STORAGE='./' go test -failfast -timeout 2400s -v ./x/compute/internal/... $(GO_TEST_ARGS)
GOMAXPROCS=8 SGX_MODE=SW SCRT_SGX_STORAGE='./' go test -failfast -timeout 40m -v ./x/compute/internal/... $(GO_TEST_ARGS)

go-tests-hw: build-test-contract
# empty BUILD_PROFILE means debug mode which compiles faster
Expand Down
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ func NewSecretNetworkApp(
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper))

// Just re-use the full router - do we want to limit this more?
computeRouter := app.Router()
regRouter := app.Router()

// Replace with bootstrap flag when we figure out how to test properly and everything works
Expand All @@ -419,7 +418,7 @@ func NewSecretNetworkApp(

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "staking"
supportedFeatures := "staking,stargate,ibc3"

app.computeKeeper = compute.NewKeeper(
appCodec,
Expand All @@ -435,7 +434,9 @@ func NewSecretNetworkApp(
app.ibcKeeper.PortKeeper,
app.transferKeeper,
app.ibcKeeper.ChannelKeeper,
computeRouter,
app.Router(),
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
computeDir,
computeConfig,
supportedFeatures,
Expand Down
20 changes: 11 additions & 9 deletions cmd/secretd/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
Expand Down Expand Up @@ -124,8 +123,7 @@ blockchain. Writes the certificate in DER format to ~/attestation_cert
Args: cobra.MaximumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
depCdc := clientCtx.Codec
cdc := depCdc.(codec.Codec)
cdc := clientCtx.Codec

serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
Expand Down Expand Up @@ -175,8 +173,8 @@ blockchain. Writes the certificate in DER format to ~/attestation_cert
return err
}

fmt.Println(fmt.Sprintf("%s", hex.EncodeToString(pubkey)))
fmt.Println(fmt.Sprintf("%s", hex.EncodeToString(masterKey)))
fmt.Printf("%s\n", hex.EncodeToString(pubkey))
fmt.Printf("%s\n", hex.EncodeToString(masterKey))

// sanity check - make sure the certificate we're using matches the generated key
if hex.EncodeToString(pubkey) != hex.EncodeToString(masterKey) {
Expand Down Expand Up @@ -239,7 +237,7 @@ func ParseCert() *cobra.Command {
return err
}

fmt.Println(fmt.Sprintf("0x%s", hex.EncodeToString(pubkey)))
fmt.Printf("0x%s\n", hex.EncodeToString(pubkey))
return nil
},
}
Expand Down Expand Up @@ -313,7 +311,7 @@ func HealthCheck() *cobra.Command {
return fmt.Errorf("failed to start enclave. Enclave returned: %s", err)
}

fmt.Println(fmt.Sprintf("SGX enclave health status: %s", res))
fmt.Printf("SGX enclave health status: %s\n", res)
return nil
},
}
Expand Down Expand Up @@ -491,7 +489,11 @@ Please report any issues with this command
"certificate": "%s"
}`, base64.StdEncoding.EncodeToString(cert)))

resp, err := http.Post(fmt.Sprintf(`%s`, regUrl), "application/json", bytes.NewBuffer(data))
resp, err := http.Post(regUrl, "application/json", bytes.NewBuffer(data))
if err != nil {
log.Fatalln(err)
}

defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
Expand All @@ -515,7 +517,7 @@ Please report any issues with this command
}

seed := details.Details.Value
log.Printf(fmt.Sprintf(`seed: %s`, seed))
log.Printf(`seed: %s\n`, seed)

if len(seed) > 2 {
seed = seed[2:]
Expand Down
6 changes: 2 additions & 4 deletions cmd/secretd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
Expand Down Expand Up @@ -42,8 +41,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
depCdc := clientCtx.Codec
cdc := depCdc.(codec.Codec)
cdc := clientCtx.Codec

serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
Expand Down Expand Up @@ -161,7 +159,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

appState[authtypes.ModuleName] = authGenStateBz

bankGenState := banktypes.GetGenesisStateFromAppState(depCdc, appState)
bankGenState := banktypes.GetGenesisStateFromAppState(cdc, appState)
bankGenState.Balances = append(bankGenState.Balances, balances)
bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances)

Expand Down
Loading

0 comments on commit cc98d0a

Please sign in to comment.