Skip to content

Commit

Permalink
move to v3 dir (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust authored Dec 25, 2023
1 parent e6e3eda commit a97bbd7
Show file tree
Hide file tree
Showing 154 changed files with 1,311 additions and 1,102 deletions.
6 changes: 3 additions & 3 deletions .ci/ethPrecompiled/bn256.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .ci/ethPrecompiled/bn256_gm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .ci/generate_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

GOPATH_BIN=$(go env GOPATH)/bin

c_sdk_version="v3.4.0"
c_sdk_version="v3.5.0"

LOG_ERROR() {
content=${1}
Expand Down Expand Up @@ -32,6 +32,7 @@ get_csdk_lib()
}

calculate_coverage() {
cd ./v3
# start blockchain demo
# latest_version=$(curl -sS https://gitee.com/api/v5/repos/FISCO-BCOS/FISCO-BCOS/tags | grep -oe "\"name\":\"v[3-9]*\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
# latest_version=$(curl --insecure -s https://api.github.com/repos/FISCO-BCOS/FISCO-BCOS/releases | grep "tag_name" | grep "\"v3\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
Expand Down
6 changes: 3 additions & 3 deletions .ci/hello/HelloWorld.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions .ci/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ compile_and_ut()
{
export GO111MODULE="on"
# execute_cmd "go get github.com/sirupsen/[email protected]"
execute_cmd "go build cmd/console.go"
execute_cmd "go build ./cmd/console.go"
pwd
execute_cmd "go build -o abigen ./cmd/abigen/main.go"

execute_cmd "go test -v ./smcrypto"
}

Expand Down Expand Up @@ -331,7 +331,7 @@ precompiled_test(){
integration_std()
{
LOG_INFO "integration_std testing..."
execute_cmd "bash tools/download_solc.sh -v 0.8.11"
execute_cmd "bash ../tools/download_solc.sh -v 0.8.11"

head build_chain.sh
bash build_chain.sh -l 127.0.0.1:2 -o nodes -a 0x83309d045a19c44dc3722d15a6abd472f95866ac
Expand All @@ -342,11 +342,11 @@ integration_std()
cp nodes/127.0.0.1/sdk/* ./client/

# abigen std
execute_cmd "./solc-0.8.11 --bin --abi --optimize -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin .ci/hello/HelloWorld.bin --abi .ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello.go"
execute_cmd "./solc-0.8.11 --bin --abi --optimize -o ../.ci/hello ../.ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin ../.ci/hello/HelloWorld.bin --abi ../.ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello.go"
generate_hello Hello hello.go
execute_cmd "go build ${ldflags} -o hello hello.go"
execute_cmd "go build ${ldflags} -o bn256 .ci/ethPrecompiled/bn256.go"
execute_cmd "go build ${ldflags} -o bn256 ../.ci/ethPrecompiled/bn256.go"
LOG_INFO "generate hello.go and build hello done."

precompiled_test
Expand All @@ -357,8 +357,8 @@ integration_std()
if [ ! -z "$(cat hello.out | grep failed)" ];then LOG_ERROR "call hello failed." && cat hello.out && exit 1;fi
# if [ ! -z "$(./bn256 | grep failed)" ];then ./bn256 && LOG_ERROR "call bn256 failed." && exit 1;fi

execute_cmd "./solc-0.8.11 --bin --abi --optimize -o .ci/counter .ci/counter/Counter.sol"
execute_cmd "./abigen --bin .ci/counter/Counter.bin --abi .ci/counter/Counter.abi --type Counter --pkg main --out=counter.go"
execute_cmd "./solc-0.8.11 --bin --abi --optimize -o ../.ci/counter ../.ci/counter/Counter.sol"
execute_cmd "./abigen --bin ../.ci/counter/Counter.bin --abi ../.ci/counter/Counter.abi --type Counter --pkg main --out=counter.go"
generate_counter Counter counter.go
execute_cmd "go build ${ldflags} -o counter counter.go"
if [ -z "$(./counter | grep address)" ];then LOG_ERROR "std deploy contract failed." && exit 1;fi
Expand All @@ -374,7 +374,7 @@ integration_std()
integration_gm()
{
LOG_INFO "integration_gm testing..."
execute_cmd "bash tools/download_solc.sh -v 0.8.11 -g"
execute_cmd "bash ../tools/download_solc.sh -v 0.8.11 -g"

bash build_chain.sh -l 127.0.0.1:2 -s -o nodes_gm -a 0x791a0073e6dfd9dc5e5061aebc43ab4f7aa4ae8b
cp -r nodes_gm/127.0.0.1/sdk/* ./conf/
Expand All @@ -385,11 +385,11 @@ integration_gm()
cp nodes/127.0.0.1/sdk/* ./client/

# abigen gm
execute_cmd "./solc-0.8.11-gm --bin --abi --overwrite -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin .ci/hello/HelloWorld.bin --abi .ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello_gm.go --smcrypto=true"
execute_cmd "./solc-0.8.11-gm --bin --abi --overwrite -o ../.ci/hello ../.ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin ../.ci/hello/HelloWorld.bin --abi ../.ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello_gm.go --smcrypto=true"
generate_hello_gm Hello hello_gm.go
execute_cmd "go build ${ldflags} -o hello_gm hello_gm.go"
execute_cmd "go build ${ldflags} -o bn256_gm .ci/ethPrecompiled/bn256_gm.go"
execute_cmd "go build ${ldflags} -o bn256_gm ../.ci/ethPrecompiled/bn256_gm.go"
LOG_INFO "generate hello_gm.go and build hello_gm done."

if [ -z "$(./hello_gm | grep address)" ];then LOG_ERROR "gm deploy contract failed." && exit 1;fi
Expand Down Expand Up @@ -439,6 +439,7 @@ parse_params()

main()
{
cd ./v3
check_env
get_csdk_lib
get_build_chain
Expand Down
6 changes: 3 additions & 3 deletions .ci/store/Store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- name: upload code coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
file: ./v3/coverage.txt
name: go-sdk code coverage
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.so
*.dylib
log/*
clog.ini

# Test binary, built with `go test -c`
*.test
Expand All @@ -20,6 +21,7 @@ log/*

# Go workspace file
go.work
go.work.sum

# cmd
main
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FISCO BCOS Go语言版本的SDK,主要实现的功能有:

master分支的go-sdk对应FISCO-BCOS v3版本,如果使用的是FISCO-BCOS v2版本,请切换到[FISCO-BCOS v2分支](https://github.com/FISCO-BCOS/go-sdk/tree/master-FISCO-BCOS-v2)[对应文档](https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/go_sdk/index.html)

- [Golang](https://golang.org/), 版本需不低于`1.17`,本项目采用`go module`进行包管理。具体可查阅[Using Go Modules](https://blog.golang.org/using-go-modules)
- [Golang](https://golang.org/), 版本需不低于`1.21`,本项目采用`go module`进行包管理。具体可查阅[Using Go Modules](https://blog.golang.org/using-go-modules)
- [FISCO BCOS 3.2.0+](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/index.html), 可参考[安装搭建](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/quick_start/air_installation.html)
- Solidity编译器,默认0.8.11版本

Expand Down Expand Up @@ -56,13 +56,13 @@ type Config struct {
- GroupID:账本的`GroupID`
- Host:节点IP
- Port:节点RPC端口
- DisableSsl:使用TLS加密时为`false`,不使用TLS加密时为`true`
- DisableSsl:使用TLS加密时为`false`,不使用TLS加密时为`true`,此配置项需与节点config.ini中的`rpc.disable_ssl`保持一致

## 控制台使用

1. 搭建FISCO BCOS 3.2以上版本节点,请[参考这里](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/quick_start/air_installation.html)
1. 请拷贝对应的SDK证书到conf文件夹,证书名为`ca.crt/sdk.key/sdk.crt`,国密时证书名为`sm_ca.crt/sm_sdk.key/sm_sdk.crt/sm_ensdk.key/sm_ensdk.crt`
1. go-sdk需要依赖csdk的动态库,[下载地址](https://github.com/FISCO-BCOS/bcos-c-sdk/releases/tag/v3.4.0),将动态库放在`/usr/local/lib`目录下。在其他机器使用时也需要通过`export LD_LIBRARY_PATH=${PWD}/lib`设置动态库的搜索路径,其中`${PWD}/lib`需替换为bcos-c-sdk的动态库所在文件夹。如果编译后在其他机器运行,也可以在编译时使用`-ldflags`指定动态库搜索路径,如`go build -ldflags="-r ${PWD}/lib"`
1. go-sdk需要依赖csdk的动态库,[下载地址](https://github.com/FISCO-BCOS/bcos-c-sdk/releases/tag/v3.5.0),将动态库放在`/usr/local/lib`目录下。在其他机器使用时也需要通过`export LD_LIBRARY_PATH=${PWD}/lib`设置动态库的搜索路径,其中`${PWD}/lib`需替换为bcos-c-sdk的动态库所在文件夹。如果编译后在其他机器运行,也可以在编译时使用`-ldflags`指定动态库搜索路径,如`go build -ldflags="-r ${PWD}/lib"`

```bash
# 下面的脚本帮助用户下载bcos-c-sdk的动态库到/usr/local/lib目录下
Expand All @@ -76,7 +76,8 @@ type Config struct {
git clone https://github.com/FISCO-BCOS/go-sdk.git
cd go-sdk
go mod tidy
go build -ldflags="-r /usr/local/lib" -o console cmd/console.go
cd v3
go build -ldflags="-r /usr/local/lib" -o console ./cmd/console.go
./console help
```

Expand All @@ -85,7 +86,7 @@ go build -ldflags="-r /usr/local/lib" -o console cmd/console.go
以下的示例是通过`import`的方式来使用`go-sdk`,如引入RPC控制台库:

```go
import "github.com/FISCO-BCOS/go-sdk/client"
import "github.com/FISCO-BCOS/go-sdk/v3/client"
```

### Solidity合约编译为Go文件
Expand Down Expand Up @@ -141,6 +142,7 @@ bash tools/download_solc.sh -v 0.8.11

```bash
# 下面指令在go-sdk目录下操作,编译生成abigen工具
cd v3
go build ./cmd/abigen
```

Expand Down Expand Up @@ -196,8 +198,8 @@ import (
"fmt"
"log"

"github.com/FISCO-BCOS/go-sdk/client"
"github.com/FISCO-BCOS/go-sdk/core/types"
"github.com/FISCO-BCOS/go-sdk/v3/client"
"github.com/FISCO-BCOS/go-sdk/v3/types"
"github.com/FISCO-BCOS/go-sdk/hello"
)

Expand Down
9 changes: 0 additions & 9 deletions examples/conf/clog.ini

This file was deleted.

26 changes: 0 additions & 26 deletions examples/conf/config_sample.ini

This file was deleted.

28 changes: 0 additions & 28 deletions examples/conf/sm_config_sample.ini

This file was deleted.

66 changes: 1 addition & 65 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,13 @@ replace (
)

require (
github.com/FISCO-BCOS/bcos-c-sdk v0.0.0-20231221132830-c0cfb1d98eec
github.com/FISCO-BCOS/crypto v0.0.0-20200202032121-bd8ab0b5d4f1
github.com/ethereum/go-ethereum v1.10.21
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v1.0.0
github.com/urfave/cli/v2 v2.10.2
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
)

require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/deepmap/oapi-codegen v1.8.2 // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/influxdb v1.8.3 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit a97bbd7

Please sign in to comment.