Skip to content

Commit

Permalink
Merge pull request #884 from scrtlabs/0.44.6-rocksdb
Browse files Browse the repository at this point in the history
Bumping sdk version and rocksdb support
  • Loading branch information
Cashmaney authored Feb 24, 2022
2 parents 613c815 + 4bb630b commit abbc914
Show file tree
Hide file tree
Showing 14 changed files with 756 additions and 527 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.15" # The Go version to download (if necessary) and use.
go-version: "^1.17" # The Go version to download (if necessary) and use.
- name: Install Intel's SGX SDK
run: |
mkdir -p "$HOME/.sgxsdk"
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ endif

build_tags += $(IAS_BUILD)

ifeq ($(WITH_ROCKSDB),yes)
build_tags += gcc
endif
ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
Expand All @@ -97,6 +100,15 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=SecretNetwork \
ifeq ($(WITH_CLEVELDB),yes)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq ($(WITH_ROCKSDB),yes)
CGO_ENABLED=1
build_tags += rocksdb
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
ldflags += -extldflags "-lrocksdb -lz -lm -lstdc++"
endif



ldflags += -s -w
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
Expand Down Expand Up @@ -237,7 +249,7 @@ build-testnet: docker_base
@mkdir build 2>&3 || true
docker build --build-arg BUILD_VERSION=${VERSION} --build-arg SGX_MODE=HW --build-arg SECRET_NODE_TYPE=BOOTSTRAP -f deployment/dockerfiles/release.Dockerfile -t enigmampc/secret-network-bootstrap:v$(VERSION)-testnet .
docker build --build-arg BUILD_VERSION=${VERSION} --build-arg SGX_MODE=HW --build-arg SECRET_NODE_TYPE=NODE -f deployment/dockerfiles/release.Dockerfile -t enigmampc/secret-network-node:v$(VERSION)-testnet .
docker build --build-arg BUILD_VERSION=${VERSION} --build-arg SGX_MODE=HW -f deployment/dockerfiles/build-deb.Dockerfile -t deb_build .
docker build --build-arg SGX_MODE=HW -f deployment/dockerfiles/build-deb.Dockerfile -t deb_build .
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build

build-mainnet:
Expand All @@ -250,8 +262,10 @@ build-mainnet:

docker_base:
docker build \
--build-arg WITH_ROCKSDB=${WITH_ROCKSDB} \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg FEATURES=${FEATURES} \
--build-arg FEATURES_U=query-node,${FEATURES_U} \
--build-arg FEATURES_U=${FEATURES_U} \
--build-arg SGX_MODE=${SGX_MODE} \
-f deployment/dockerfiles/base.Dockerfile \
-t rust-go-base-image \
Expand Down
9 changes: 3 additions & 6 deletions cosmwasm-js/packages/sdk/src/restclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,11 @@ export class RestClient {
const encoded = Encoding.toBase64(encrypted).replace(/\+/g, "-").replace(/\//g, "_");

// @ts-ignore
const params = new URLSearchParams(addedParams);
params.append('query_data', encoded);
const paramString = params.toString();
const paramString = new URLSearchParams(addedParams).toString();

// Check to make sure that the address is a valid bech32 address
const _ = Bech32.decode(contractAddress);
const encodedContractAddress = Encoding.toBase64(Bech32.decode(contractAddress).data);

const path = `/compute/v1beta1/contract/${contractAddress}/smart?${paramString}`;
const path = `/compute/v1beta1/contract/${encodedContractAddress}/smart?query_data=${encoded}&${paramString}`;

let responseData;
try {
Expand Down
35 changes: 30 additions & 5 deletions deployment/dockerfiles/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ENV GOROOT=/usr/local/go
ENV GOPATH=/go/
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

RUN curl -O https://dl.google.com/go/go1.15.15.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.15.15.linux-amd64.tar.gz
ADD https://go.dev/dl/go1.17.7.linux-amd64.tar.gz go1.17.7.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz
RUN go get -u github.com/jteeuwen/go-bindata/...

RUN wget -q https://github.com/WebAssembly/wabt/releases/download/1.0.20/wabt-1.0.20-ubuntu.tar.gz && \
Expand All @@ -19,20 +19,45 @@ RUN wget -q https://github.com/WebAssembly/wabt/releases/download/1.0.20/wabt-1.
chmod +x /bin/wat2wasm /bin/wasm2wat && \
rm -f wabt-1.0.20-ubuntu.tar.gz

### Install rocksdb

RUN apt-get update && \
apt-get install -y \
# apt-get install -y --no-install-recommends \
# libgflags-dev \
# libsnappy-dev \
zlib1g-dev
# libbz2-dev \
# liblz4-dev \
# libzstd-dev

RUN git clone https://github.com/facebook/rocksdb.git

WORKDIR rocksdb

RUN git checkout v6.24.2
RUN export CXXFLAGS='-Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=class-memaccess -lstdc++ -lm -lz -lbz2 -lzstd -llz4'
RUN DEBUG_LEVEL=0 make static_lib -j 24
RUN make install-static INSTALL_PATH=/usr
# rm -rf /tmp/rocksdb
# Set working directory for the build
WORKDIR /go/src/github.com/enigmampc/SecretNetwork/

ARG BUILD_VERSION="v0.0.0"
ARG SGX_MODE=SW
ARG FEATURES
ARG FEATURES_U
ARG WITH_ROCKSDB

ENV WITH_ROCKSDB=${WITH_ROCKSDB}
ENV VERSION=${BUILD_VERSION}
ENV SGX_MODE=${SGX_MODE}
ENV FEATURES=${FEATURES}
ENV FEATURES_U=${FEATURES_U}
ENV MITIGATION_CVE_2020_0551=LOAD



COPY third_party/build third_party/build

# Add source files
Expand Down Expand Up @@ -84,9 +109,9 @@ COPY Makefile .
RUN true
COPY client client
# COPY /go/src/github.com/enigmampc/SecretNetwork/go-cosmwasm/libgo_cosmwasm.so go-cosmwasm/api

RUN . /opt/sgxsdk/environment && env && MITIGATION_CVE_2020_0551=LOAD VERSION=${VERSION} FEATURES=${FEATURES} SGX_MODE=${SGX_MODE} make build_local_no_rust
RUN . /opt/sgxsdk/environment && env && MITIGATION_CVE_2020_0551=LOAD VERSION=${VERSION} FEATURES=${FEATURES} SGX_MODE=${SGX_MODE} make build_cli
RUN export CGO_LDFLAGS="-L/usr/local/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lzstd -llz4"
RUN . /opt/sgxsdk/environment && env && CGO_LDFLAGS="-L/usr/local/lib -lrocksdb -lstdc++ -lm -lz" MITIGATION_CVE_2020_0551=LOAD VERSION=${VERSION} FEATURES=${FEATURES} SGX_MODE=${SGX_MODE} make build_local_no_rust
RUN . /opt/sgxsdk/environment && env && CGO_LDFLAGS="-L/usr/local/lib -lrocksdb -lstdc++ -lm -lz" MITIGATION_CVE_2020_0551=LOAD VERSION=${VERSION} FEATURES=${FEATURES} SGX_MODE=${SGX_MODE} make build_cli

RUN rustup target add wasm32-unknown-unknown && make build-test-contract

Expand Down
21 changes: 21 additions & 0 deletions deployment/dockerfiles/db-compile.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM baiduxlab/sgx-rust:2004-1.1.3

### Install rocksdb

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgflags-dev \
libsnappy-dev \
zlib1g-dev \
libbz2-dev \
liblz4-dev \
libzstd-dev

RUN git clone https://github.com/facebook/rocksdb.git

WORKDIR rocksdb

RUN git checkout v6.24.2
RUN export CXXFLAGS='-Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=class-memaccess'
RUN make shared_lib -j 24
RUN make install-shared INSTALL_PATH=/usr
3 changes: 3 additions & 0 deletions deployment/dockerfiles/release.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN apt-get update && \
openssl \
curl \
wget \
libsnappy-dev \
libgflags-dev \
bash-completion && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -42,6 +44,7 @@ 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/go-cosmwasm/librust_cosmwasm_enclave.signed.so /usr/lib/
COPY --from=build-env-rust-go /go/src/github.com/enigmampc/SecretNetwork/go-cosmwasm/librust_cosmwasm_query_enclave.signed.so /usr/lib/
COPY --from=build-env-rust-go /go/src/github.com/enigmampc/SecretNetwork/secretd /usr/bin/secretd
# COPY --from=build-env-rust-go /usr/local/lib/librocksdb.so.6.24 /usr/lib/

COPY deployment/docker/bootstrap/bootstrap_init.sh .
COPY deployment/docker/node/node_init.sh .
Expand Down
24 changes: 20 additions & 4 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@
- [QueryContractAddressByLabelResponse](#secret.compute.v1beta1.QueryContractAddressByLabelResponse)
- [QueryContractHashRequest](#secret.compute.v1beta1.QueryContractHashRequest)
- [QueryContractHashResponse](#secret.compute.v1beta1.QueryContractHashResponse)
- [QueryContractHistoryRequest](#secret.compute.v1beta1.QueryContractHistoryRequest)
- [QueryContractInfoRequest](#secret.compute.v1beta1.QueryContractInfoRequest)
- [QueryContractInfoResponse](#secret.compute.v1beta1.QueryContractInfoResponse)
- [QueryContractKeyRequest](#secret.compute.v1beta1.QueryContractKeyRequest)
Expand Down Expand Up @@ -11969,7 +11970,7 @@ DecryptedAnswer is a struct that represents a decrypted tx-query

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the contract |
| `address` | [bytes](#bytes) | | address is the address of the contract |



Expand All @@ -11991,6 +11992,21 @@ DecryptedAnswer is a struct that represents a decrypted tx-query



<a name="secret.compute.v1beta1.QueryContractHistoryRequest"></a>

### QueryContractHistoryRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [bytes](#bytes) | | address is the address of the contract to query |






<a name="secret.compute.v1beta1.QueryContractInfoRequest"></a>

### QueryContractInfoRequest
Expand All @@ -11999,7 +12015,7 @@ QueryContractInfoRequest is the request type for the Query/ContractInfo RPC meth

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the contract to query |
| `address` | [bytes](#bytes) | | address is the address of the contract to query |



Expand Down Expand Up @@ -12030,7 +12046,7 @@ QueryContractInfoResponse is the response type for the Query/ContractInfo RPC me

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the contract |
| `address` | [bytes](#bytes) | | address is the address of the contract |



Expand Down Expand Up @@ -12090,7 +12106,7 @@ QueryContractInfoResponse is the response type for the Query/ContractInfo RPC me

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | address is the address of the contract |
| `address` | [bytes](#bytes) | | address is the address of the contract string address = 1; |
| `query_data` | [bytes](#bytes) | | |


Expand Down
Loading

0 comments on commit abbc914

Please sign in to comment.