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

feat: implement signer service #119

Merged
merged 20 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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: 12 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- uses: ory/build-buf-action@v0
- uses: bufbuild/buf-setup-action@v1.14.0
with:
bufVersion: v1.11.0
protocPlugins:
go@v1.28.0 go-grpc@v1.2.0
bufArgs:
generate
version: 1.14.0
buf_user: "${{ secrets.BUF_REGISTRY_USER }}"
buf_api_token: "${{ secrets.BUF_REGISTRY_SECRET }}"

- name: Install Protoc
uses: arduino/setup-protoc@v1

- run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
buf generate

- name: Test Build
run: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/code-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- uses: ory/build-buf-action@v0
- uses: bufbuild/buf-setup-action@v1.14.0
with:
bufVersion: v1.11.0
protocPlugins:
go@v1.28.0 go-grpc@v1.2.0
bufArgs:
generate
version: 1.14.0
buf_user: "${{ secrets.BUF_REGISTRY_USER }}"
buf_api_token: "${{ secrets.BUF_REGISTRY_SECRET }}"

- name: Install Protoc
uses: arduino/setup-protoc@v1

- run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
buf generate

- uses: technote-space/get-diff-action@v6
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/proto-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: bufbuild/buf-setup-action@v1.11.0
- uses: bufbuild/buf-setup-action@v1.14.0
with:
version: 1.14.0
buf_user: "${{ secrets.BUF_REGISTRY_USER }}"
buf_api_token: "${{ secrets.BUF_REGISTRY_SECRET }}"

- uses: bufbuild/buf-lint-action@v1
with:
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- main
- develop

env:
CGO_CFLAGS: "-O -D__BLST_PORTABLE__"
CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__"

jobs:
unit-test:
strategy:
Expand Down Expand Up @@ -46,13 +50,19 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- uses: ory/build-buf-action@v0
- uses: bufbuild/buf-setup-action@v1.14.0
with:
bufVersion: v1.11.0
protocPlugins:
go@v1.28.0 go-grpc@v1.2.0
bufArgs:
generate
version: 1.14.0
buf_user: "${{ secrets.BUF_REGISTRY_USER }}"
buf_api_token: "${{ secrets.BUF_REGISTRY_SECRET }}"

- name: Install Protoc
uses: arduino/setup-protoc@v1

- run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
buf generate

- name: Setup GitHub Token
run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
Expand Down
9 changes: 9 additions & 0 deletions cmd/storage_provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/bnb-chain/greenfield-storage-provider/service/challenge"
"github.com/bnb-chain/greenfield-storage-provider/service/downloader"
"github.com/bnb-chain/greenfield-storage-provider/service/gateway"
"github.com/bnb-chain/greenfield-storage-provider/service/signer"
"github.com/bnb-chain/greenfield-storage-provider/service/stonehub"
"github.com/bnb-chain/greenfield-storage-provider/service/stonenode"
"github.com/bnb-chain/greenfield-storage-provider/service/syncer"
Expand Down Expand Up @@ -84,6 +85,14 @@ func initService(serviceName string, cfg *config.StorageProviderConfig) (server
if err != nil {
return nil, err
}
case model.SignerService:
if cfg.SignerCfg == nil {
cfg.SignerCfg = config.DefaultStorageProviderConfig.SignerCfg
}
server, err = signer.NewSignerServer(cfg.SignerCfg)
if err != nil {
return nil, err
}
default:
log.Errorw("unknown service", "service", serviceName)
return nil, fmt.Errorf("unknow service: %s", serviceName)
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/bnb-chain/greenfield-storage-provider/service/challenge"
"github.com/bnb-chain/greenfield-storage-provider/service/downloader"
"github.com/bnb-chain/greenfield-storage-provider/service/gateway"
"github.com/bnb-chain/greenfield-storage-provider/service/signer"
"github.com/bnb-chain/greenfield-storage-provider/service/stonehub"
"github.com/bnb-chain/greenfield-storage-provider/service/stonenode"
"github.com/bnb-chain/greenfield-storage-provider/service/syncer"
Expand All @@ -25,6 +26,7 @@ type StorageProviderConfig struct {
StoneHubCfg *stonehub.StoneHubConfig
StoneNodeCfg *stonenode.StoneNodeConfig
SyncerCfg *syncer.SyncerConfig
SignerCfg *signer.SignerConfig
}

var DefaultStorageProviderConfig = &StorageProviderConfig{
Expand All @@ -35,6 +37,7 @@ var DefaultStorageProviderConfig = &StorageProviderConfig{
StoneHubCfg: stonehub.DefaultStoneHubConfig,
StoneNodeCfg: stonenode.DefaultStoneNodeConfig,
SyncerCfg: syncer.DefaultSyncerConfig,
SignerCfg: signer.DefaultSignerChainConfig,
}

// LoadConfig loads the config file
Expand Down
16 changes: 15 additions & 1 deletion config/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Service = [
"Gateway", "Uploader", "Downloader", "StoneHub", "StoneNode", "Syncer",
"Gateway", "Uploader", "Downloader", "StoneHub", "StoneNode", "Syncer", "Signer",
]

[GatewayCfg]
Expand Down Expand Up @@ -79,3 +79,17 @@ Service = [
Cache = 4096
FileHandles = 1000
ReadOnly = false

[SignerCfg]
Address = "127.0.0.1:9633"
WhitelistCIDR = ["127.0.0.1/32","10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"]
APIKey = ""
[SignerCfg.GreenfieldChainConfig]
GRPCAddr = "localhost:9090"
ChainID = "greenfield_9000-121"
GasLimit = 210000
OperatorPrivateKey = ""
FundingPrivateKey = ""
SealPrivateKey = ""
ApprovalPrivateKey = ""

47 changes: 40 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ module github.com/bnb-chain/greenfield-storage-provider
go 1.19

replace (
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/gnfd-cosmos-sdk v0.0.5
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/gnfd-cosmos-sdk v0.0.6
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/bnb-chain/gnfd-tendermint v0.0.1
)

require (
github.com/GeertJohan/go.linenoise v0.0.0-20141120151038-1918ff89d613
github.com/aws/aws-sdk-go v1.44.159
github.com/bnb-chain/greenfield v0.0.5
github.com/bnb-chain/greenfield-go-sdk v0.0.3
github.com/bnb-chain/greenfield-sdk-go v0.0.0-20230208161205-03ff5beb1419
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
github.com/cloudflare/cfssl v1.6.3
github.com/cosmos/cosmos-proto v1.0.0-beta.1
github.com/cosmos/cosmos-sdk v0.46.4
github.com/ethereum/go-ethereum v1.10.19
github.com/evmos/ethermint v0.6.1-0.20220919141022-34226aa7b1fa
github.com/golang/mock v1.6.0
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/json-iterator/go v1.1.12
github.com/klauspost/reedsolomon v1.11.3
github.com/klauspost/reedsolomon v1.11.6
github.com/looplab/fsm v1.0.0
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/oleiade/lane v1.0.1
Expand All @@ -30,7 +36,7 @@ require (
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230111222715-75897c7a292a
google.golang.org/grpc v1.51.0
google.golang.org/grpc v1.52.0
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
gorm.io/driver/mysql v1.4.4
gorm.io/gorm v1.24.2
Expand All @@ -40,38 +46,53 @@ require (
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/math v1.0.0-beta.3 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.3 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect
github.com/evmos/ethermint v0.6.1-0.20220919141022-34226aa7b1fa // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
Expand All @@ -86,13 +107,15 @@ require (
github.com/kr/fs v0.1.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
Expand All @@ -105,6 +128,9 @@ require (
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prysmaticlabs/eth2-types v0.0.0-20210303084904-c9735a06829d // indirect
github.com/prysmaticlabs/prysm v0.0.0-20220124113610-e26cde5e091b // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
Expand All @@ -116,18 +142,25 @@ require (
github.com/spf13/viper v1.13.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tendermint v0.34.22 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.3.0 // indirect
github.com/wealdtech/go-bytesutil v1.1.1 // indirect
github.com/wealdtech/go-eth2-types/v2 v2.5.2 // indirect
github.com/wealdtech/go-eth2-util v1.6.3 // indirect
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.3.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading