Skip to content

Commit c609f73

Browse files
authored
Merge branch 'master' into kent-3/patch-1
2 parents a6f20e0 + 35315f0 commit c609f73

File tree

8 files changed

+162
-115
lines changed

8 files changed

+162
-115
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919
chmod +x "$SDK_BIN"
2020
echo yes | ./"$SDK_BIN"
2121
- name: Cache cargo registry
22-
uses: actions/cache@v3
22+
uses: actions/cache@v4
2323
with:
2424
path: ~/.cargo/registry
2525
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
2626
- name: Cache xargo sysroot
27-
uses: actions/cache@v3
27+
uses: actions/cache@v4
2828
with:
2929
path: ~/.xargo
3030
key: ${{ runner.os }}-xargo-sysroot
3131
- name: Cache build artifacts
32-
uses: actions/cache@v3
32+
uses: actions/cache@v4
3333
with:
3434
path: ~/.cache/sccache
3535
key: ${{ runner.os }}-sccache
@@ -193,17 +193,17 @@ jobs:
193193
chmod +x "$SDK_BIN"
194194
echo yes | ./"$SDK_BIN"
195195
- name: Cache cargo registry
196-
uses: actions/cache@v3
196+
uses: actions/cache@v4
197197
with:
198198
path: ~/.cargo/registry
199199
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
200200
- name: Cache xargo sysroot
201-
uses: actions/cache@v3
201+
uses: actions/cache@v4
202202
with:
203203
path: ~/.xargo
204204
key: ${{ runner.os }}-xargo-sysroot
205205
- name: Cache build artifacts
206-
uses: actions/cache@v3
206+
uses: actions/cache@v4
207207
with:
208208
path: ~/.cache/sccache
209209
key: ${{ runner.os }}-sccache

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
3232
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
3333
- name: Cache build artifacts
34-
uses: actions/cache@v3
34+
uses: actions/cache@v4
3535
with:
3636
path: ~/.cache/sccache
3737
key: ${{ runner.os }}-sccache

Makefile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
PACKAGES=$(shell go list ./... | grep -v '/simulation')
21
VERSION ?= $(shell echo $(shell git describe --tags) | sed 's/^v//')
32
COMMIT := $(shell git log -1 --format='%H')
43
DOCKER := $(shell which docker)
54
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
65

6+
# SPID and API_KEY are used for Intel SGX attestation
77
SPID ?= 00000000000000000000000000000000
88
API_KEY ?= FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
99

10+
# Environment variables and build tags setup
1011
LEDGER_ENABLED ?= true
1112
BINDIR ?= $(GOPATH)/bin
1213
BUILD_PROFILE ?= release
@@ -22,24 +23,23 @@ DOCKER_TAG ?= latest
2223

2324
TM_SGX ?= true
2425

26+
# Paths for contracts and modules
2527
CW_CONTRACTS_V010_PATH = ./cosmwasm/contracts/v010/
2628
CW_CONTRACTS_V1_PATH = ./cosmwasm/contracts/v1/
27-
2829
TEST_CONTRACT_V010_PATH = ./cosmwasm/contracts/v010/compute-tests
2930
TEST_CONTRACT_V1_PATH = ./cosmwasm/contracts/v1/compute-tests
30-
3131
TEST_COMPUTE_MODULE_PATH = ./x/compute/internal/keeper/testdata/
32-
3332
ENCLAVE_PATH = cosmwasm/enclaves/
3433
EXECUTE_ENCLAVE_PATH = $(ENCLAVE_PATH)/execute/
35-
DOCKER_BUILD_ARGS ?=
3634

35+
# Determine if Docker Buildx is available for multi-platform builds
36+
DOCKER_BUILD_ARGS ?=
3737
DOCKER_BUILDX_CHECK = $(@shell docker build --load test)
38-
3938
ifeq (Building,$(findstring Building,$(DOCKER_BUILDX_CHECK)))
4039
DOCKER_BUILD_ARGS += "--load"
4140
endif
4241

42+
# Check and set the SGX_MODE to either HW or SW, error if not set
4343
ifeq ($(SGX_MODE), HW)
4444
ext := hw
4545
else ifeq ($(SGX_MODE), SW)
@@ -48,6 +48,7 @@ else
4848
$(error SGX_MODE must be either HW or SW)
4949
endif
5050

51+
# Set CGO flags based on the selected database backend (unused - currently only cleveldb is supported)
5152
ifeq ($(DB_BACKEND), rocksdb)
5253
DB_BACKEND = rocksdb
5354
DOCKER_CGO_LDFLAGS = "-L/usr/lib/x86_64-linux-gnu/ -lrocksdb -lstdc++ -llz4 -lm -lz -lbz2 -lsnappy"
@@ -63,6 +64,7 @@ endif
6364

6465
CUR_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
6566

67+
# Build tags setup for various configurations like ledger, database, etc.
6668
build_tags = netgo
6769
ifeq ($(LEDGER_ENABLED),true)
6870
ifeq ($(OS),Windows_NT)
@@ -120,6 +122,7 @@ whitespace += $(whitespace)
120122
comma := ,
121123
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
122124

125+
# Linker flags to embed version information and other metadata into the binaries
123126
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=SecretNetwork \
124127
-X github.com/cosmos/cosmos-sdk/version.AppName=secretd \
125128
-X github.com/scrtlabs/SecretNetwork/cmd/secretcli/version.ClientName=secretcli \
@@ -151,6 +154,7 @@ go.sum: go.mod
151154
@echo "--> Ensure dependencies have not been modified"
152155
GO111MODULE=on go mod verify
153156

157+
# Build the CLI tool
154158
build_cli:
155159
go build -o secretcli -mod=readonly -tags "$(filter-out sgx, $(GO_TAGS)) secretcli" -ldflags '$(LD_FLAGS)' ./cmd/secretd
156160

@@ -173,6 +177,7 @@ build-tm-secret-enclave:
173177
rustup component add rust-src
174178
SGX_MODE=$(SGX_MODE) $(MAKE) -C /tmp/tm-secret-enclave build
175179

180+
# Targets for building the cli on various platforms like Windows, macOS, Linux
176181
build_windows_cli:
177182
$(MAKE) xgo_build_secretcli XGO_TARGET=windows/amd64
178183
sudo mv github.com/scrtlabs/SecretNetwork-windows-* secretcli-windows-amd64.exe
@@ -195,6 +200,7 @@ build_linux_arm64_cli:
195200

196201
build_all: build-linux build_windows_cli build_macos_cli build_linux_arm64_cli
197202

203+
# Build Debian package
198204
deb: build-linux deb-no-compile
199205

200206
deb-no-compile:
@@ -226,6 +232,7 @@ deb-no-compile:
226232
dpkg-deb --build /tmp/SecretNetwork/deb/ .
227233
-rm -rf /tmp/SecretNetwork
228234

235+
# Clean up generated files and reset the environment
229236
clean:
230237
-rm -rf /tmp/SecretNetwork
231238
-rm -f ./secretcli*
@@ -247,6 +254,11 @@ clean:
247254
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract clean
248255
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2 clean
249256

257+
###############################################################################
258+
### Dockerized Build Targets ###
259+
###############################################################################
260+
261+
# Build localsecret - dockerized local chain for development and testing. In this version SGX is ran in software/simulation mode
250262
localsecret:
251263
DOCKER_BUILDKIT=1 docker build \
252264
--build-arg FEATURES="${FEATURES},debug-print,random,light-client-validation" \
@@ -309,6 +321,7 @@ build-testnet:
309321
--target build-deb .
310322
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
311323

324+
# special targets for building a deb package that compiles a new secretd but takes the enclaves from the latest package - used for upgrades when we don't want to replace the enclave
312325
build-mainnet-upgrade:
313326
@mkdir build 2>&3 || true
314327
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production, ${FEATURES}" \
@@ -336,6 +349,8 @@ build-mainnet-upgrade:
336349
-t deb_build \
337350
--target build-deb-mainnet .
338351
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
352+
353+
# full mainnet build - will end up with a .deb package in the ./build folder
339354
build-mainnet:
340355
@mkdir build 2>&3 || true
341356
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production,random, ${FEATURES}" \
@@ -367,6 +382,7 @@ build-mainnet:
367382
--target build-deb .
368383
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
369384

385+
# Build the hardware compatability checker - this is a binary that just runs attestation and provides details on the result
370386
build-check-hw-tool:
371387
@mkdir build 2>&3 || true
372388
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="${FEATURES}" \
@@ -383,23 +399,22 @@ build-check-hw-tool:
383399
-t compile-check-hw-tool \
384400
--target compile-check-hw-tool .
385401

386-
# while developing:
402+
###############################################################################
403+
### Local Build Targets ###
404+
###############################################################################
405+
387406
build-enclave:
388407
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) enclave
389408

390-
# while developing:
391409
check-enclave:
392410
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) check
393411

394-
# while developing:
395412
clippy-enclave:
396413
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clippy
397414

398-
# while developing:
399415
clean-enclave:
400416
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clean
401417

402-
# while developing:
403418
clippy: clippy-enclave
404419
$(MAKE) -C check-hw clippy
405420

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<div align="center">
44

5-
[![version](https://img.shields.io/badge/version-1.3.1-blue)](https://github.com/scrtlabs/SecretNetwork/releases/tag/v1.3.1)
6-
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
5+
[![version](https://img.shields.io/badge/version-1.12.1-blue)](https://github.com/scrtlabs/SecretNetwork/releases/tag/v1.12.1)
6+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
77
<a href="https://twitter.com/intent/follow?screen_name=SecretNetwork">
88
<img src="https://img.shields.io/twitter/follow/SecretNetwork?style=social&logo=twitter"
99
alt="Follow"></a>
@@ -42,7 +42,16 @@ Click the button below to start a new development environment:
4242
### Install prerequisite packages
4343

4444
```
45-
apt-get install -y --no-install-recommends g++ libtool autoconf clang
45+
apt-get install -y --no-install-recommends g++ libtool automake autoconf clang
46+
```
47+
48+
#### Ubuntu 22+
49+
50+
The build depends on libssl1.1. Install using:
51+
52+
```bash
53+
wget https://debian.mirror.ac.za/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0%2Bdeb11u1_amd64.deb
54+
dpkg -i libssl1.1_1.1.1w-0%2Bdeb11u1_amd64.deb
4655
```
4756

4857
### Clone Repo
@@ -111,15 +120,11 @@ Use `make build-linux` to build the entire codebase. This will build both the Ru
111120

112121
To build just the rust code, you can use `make build-linux`, while to build just the Go code, there is the aptly named `make build_local_no_rust`.
113122

114-
115123
Tip:
116-
```text
117124
For a production build the enclave must be copied from the most recent release.
118-
119125
This is due to non-reproducible builds, and the fact that enclaves must be signed with a specific key to be accepted on mainnet.
120-
121126
Still, the non-enclave code can be modified and ran on mainnet as long as there are no consensus-breaking changes
122-
```
127+
123128

124129
# Running Something
125130

@@ -145,7 +150,3 @@ For the latest documentation, check out [https://docs.scrt.network](https://docs
145150
- Twitter: [https://twitter.com/SecretNetwork](https://twitter.com/SecretNetwork)
146151
- Community Telegram Channel: [https://t.me/SCRTnetwork](https://t.me/SCRTnetwork)
147152
- Community Secret Nodes Telegram: [https://t.me/secretnodes](https://t.me/secretnodes)
148-
149-
# License
150-
151-
SecretNetwork is free software: you can redistribute it and/or modify it under the terms of the [GNU Affero General Public License](LICENSE) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The GNU Affero General Public License is based on the GNU GPL, but has an additional term to allow users who interact with the licensed software over a network to receive the source for that program.

cosmwasm/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmwasm/packages/sgx-vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ enclave-ffi-types = { path = "../../enclaves/ffi-types", features = [
6161
sgx_types = { path = "../../../third_party/incubator-teaclave-sgx-sdk/sgx_types" }
6262
sgx_urts = { path = "../../../third_party/incubator-teaclave-sgx-sdk/sgx_urts" }
6363
log = "0.4.20"
64-
base64 = "0.21.5"
64+
base64 = "0.21.6"
6565
parking_lot = "0.11"
6666
num_cpus = "1.16.0"
6767

deployment/dockerfiles/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
The build process for SN is a bit complex, and can include some unexpected parts for those that have not been baptised in the waters of TEEs.
2+
3+
### Build Targets Overview
4+
1. **`release-image`**: Creates a full node Docker image.
5+
2. **`build-deb`**: Generates a Debian (.deb) package
6+
3. **`build-deb-mainnet`**: Similar to `build-deb`, but specifically for generating a Debian package for mainnet.
7+
4. **`compile-secretd`**: Produces an image with the compiled enclave and `secretd`, a core component of the Secret Network - sometimes you don't need the whole image, just secretd.
8+
9+
### Build Process Description
10+
11+
#### 1. **Base Images and Environment Setup**
12+
- Defines two base images:
13+
* `SCRT_BASE_IMAGE_ENCLAVE` - Used as the base for building the enclave components, which are crucial for the secure execution of code in an SGX (Software Guard Extensions) environment.
14+
* `SCRT_RELEASE_BASE_IMAGE` - Serves as the base for the final release image that contains all the necessary components to run a full node.
15+
- Sets up the environment for subsequent stages, including installing dependencies like `clang-10`, setting `WORKDIR`, and other environment variables.
16+
17+
#### 2. **Compilation of Enclaves**
18+
- **`prepare-compile-enclave` & `compile-enclave`**: Prepares the environment and compiles the enclaves.
19+
- **`compile-tendermint-enclave`**: Compiles the Tendermint enclave, which is a part of the blockchain consensus mechanism.
20+
21+
#### 3. **Compilation of `secretd`**
22+
- Sets up the Go environment and downloads specific Go packages.
23+
- Copies source files and prepares the environment for building `secretd`.
24+
- Uses the compiled enclaves from previous steps.
25+
26+
#### 4. **Release Image Creation (`release-image`)**
27+
- Creates the final node image with all necessary binaries and libraries.
28+
- Installs additional dependencies like `jq`, `openssl`, and Node.js - these are used for the faucet and for debugging tools.
29+
- Sets up environment variables and links libraries.
30+
31+
#### 5. **Mainnet Upgrade (`mainnet-release`)**
32+
- Upgrades the `release-image` with specific binaries and libraries for the mainnet.
33+
34+
#### 6. **Debian Package Creation (`build-deb` and `build-deb-mainnet`)**
35+
- Prepares an environment for building Debian packages.
36+
- Copies necessary binaries and libraries from previous stages.
37+
- Executes a script to build the Debian package.
38+
39+
#### 7. **Compilation of `check-hw` Tool (`compile-check-hw-tool`)**
40+
- Compiles a hardware check tool, necessary for validating the hardware running the Secret Network nodes - this is unrelated to the release image or the network node directly.
41+
42+
#### 8. **LocalSecret Setup (`build-localsecret`)**
43+
- A specialized setup for a local version of the Secret Network, including a faucet server and a health check mechanism for local development.
44+
45+
### Summary
46+
Each target in this Dockerfile serves a distinct purpose in the build and deployment pipeline of the Secret Network. From compiling essential components like `secretd` and the Tendermint enclave, to packaging these components for deployment in various environments (development, mainnet), the Dockerfile covers a comprehensive range of tasks necessary for maintaining and deploying a blockchain network. The use of multi-stage builds optimizes the process by reusing stages and minimizing the final image size.

0 commit comments

Comments
 (0)