Skip to content

Commit

Permalink
Merge pull request #60 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare release for v0.0.3
  • Loading branch information
unclezoro authored Jul 31, 2023
2 parents 8aba141 + 8569f7e commit 452aab0
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 189 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.0.3
This release includes 1 feature and 2 bugfixes.

Features:
* [#58](https://github.com/bnb-chain/greenfield-challenger/pull/58) feat: pass in chainid when calculating event hash

Bugfixes:
* [#56](https://github.com/bnb-chain/greenfield-challenger/pull/56) fix: fix issue with hash verifier skipping challenges
* [#54](https://github.com/bnb-chain/greenfield-challenger/pull/54) fix: remove bucketdeleted status

Documentation
* [#57](https://github.com/bnb-chain/greenfield-challenger/pull/57) docs: update README.md

## v0.0.2
This is a maintenance release that updates the service to adapt to it's updated dependencies and code refactoring.
* [#47](https://github.com/bnb-chain/greenfield-challenger/pull/47) feat: adapt to new go-sdk and greenfield version
Expand Down
134 changes: 69 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Greenfield ensures data integrity by routinely issuing storage providers challen
notification and not ready for production use. The code and security audit have not been fully completed and not ready
for any bug bounty. We advise you to be careful and experiment on the network at your own risk. Stay safe out there.**


## Main Components
This off-chain application comprises 7 main goroutines: Monitor, Verifier, Vote Collector, Vote Broadcaster, Vote Collator, Tx Submitter and Attest Monitor.

Expand All @@ -33,67 +32,72 @@ This off-chain application comprises 7 main goroutines: Monitor, Verifier, Vote
## Deployment

### Config
1. Set your private key import method (via file or aws secret), deployment environment and gas limit.
```
"greenfield_config": {
"key_type": "local_private_key" or "aws_private_key" depending on whether you are storing the keys on aws or locally in this json file
"aws_region": set this if you chose "aws_private_key"
"aws_secret_name": set this if you chose "aws_private_key"
"aws_bls_secret_name": set this if you chose "aws_private_key"
"private_key": set this if you chose "local_private_key"
"bls_private_key": set this if you chose "local_private_key"
"rpc_addrs": [
"http://0.0.0.0:26750"
],
"chain_id_string": chain id of the network, e.g., "greenfield_9000-121"
"gas_limit": transaction gas limit, e.g., 1000,
"fee_amount": transaction fees, e.g., "5000000000000",
"fee_denom": transaction fees denom, e.g., "BNB",
"no_simulate": simulate transaction, e.g., true
"deduplication_interval": skip events that were recently processed, e.g., 100
}
```

2. Set your log and backup preferences.
```
"log_config": {
"level": "DEBUG",
"filename": "log.txt",
"max_file_size_in_mb": 100 (file size threshold)
"max_backups_of_log_files": 2 (backup count threshold)
"max_age_to_retain_log_files_in_days": 10 (backup age threshold)
"use_console_logger": true,
"use_file_logger": false,
"compress": false
}
```
See [config.json](https://github.com/bnb-chain/bnb-chain-charts/blob/main/gnfd-challenger-testnet-values/values.yaml#L8). Reference for a complete testnet config file.

4. Config your database settings.
```
"db_config": {
"dialect": "mysql",
"db_path": "your_db_path"
"key_type": "local_private_key" or "aws_private_key" depending on whether you are storing the keys on aws or locally in this json file
"aws_region": set this if you chose "aws_private_key"
"aws_secret_name": set this if you chose "aws_private_key"
"username": set this if you chose "local_private_key"
"password": set this if you chose "local_private_key"
"max_idle_conns": 20, (set according to your db performance)
"max_open_conns": 40, (set according to your db performance)
"debug_mode": false
}
```
1. Set your private key import method (via file or aws secret), deployment environment and gas limit.

5. Set alert config to send a telegram message when the application exceeds the max retries for certain operations.
```
"greenfield_config": {
"key_type": "local_private_key" or "aws_private_key" depending on whether you are storing the keys on aws or locally in this json file
"aws_region": set this if you chose "aws_private_key"
"aws_secret_name": set this if you chose "aws_private_key"
"aws_bls_secret_name": set this if you chose "aws_private_key"
"private_key": set this if you chose "local_private_key"
"bls_private_key": set this if you chose "local_private_key"
"rpc_addrs": [
"http://0.0.0.0:26750"
],
"chain_id_string": chain id of the network, e.g., "greenfield_9000-121"
"gas_limit": transaction gas limit, e.g., 1000,
"fee_amount": transaction fees, e.g., "5000000000000",
"fee_denom": transaction fees denom, e.g., "BNB",
"no_simulate": simulate transaction, e.g., true
"deduplication_interval": skip events that were recently processed, e.g., 100
}
```
```
"alert_config": {
"identity": your_bot_identity
"telegram_bot_id": your_bot_id
"telegram_chat_id": your_chat_id
}
```
2. Set your log and backup preferences.
```
"log_config": {
"level": "DEBUG",
"filename": "log.txt",
"max_file_size_in_mb": 100 (file size threshold)
"max_backups_of_log_files": 2 (backup count threshold)
"max_age_to_retain_log_files_in_days": 10 (backup age threshold)
"use_console_logger": true,
"use_file_logger": false,
"compress": false
}
```
3. Config your database settings.
```
"db_config": {
"dialect": "mysql",
"db_path": "your_db_path"
"key_type": "local_private_key" or "aws_private_key" depending on whether you are storing the keys on aws or locally in this json file
"aws_region": set this if you chose "aws_private_key"
"aws_secret_name": set this if you chose "aws_private_key"
"username": set this if you chose "local_private_key"
"password": set this if you chose "local_private_key"
"max_idle_conns": 20, (set according to your db performance)
"max_open_conns": 40, (set according to your db performance)
"debug_mode": false
}
```
4. Set alert config to send a telegram message when the application exceeds the max retries for certain operations.
```
"alert_config": {
"identity": your_bot_identity
"telegram_bot_id": your_bot_id
"telegram_chat_id": your_chat_id
}
```
## Run Locally
Expand Down Expand Up @@ -123,14 +127,14 @@ bash ./deployment/localup/localup.sh all 1 7

You can use the following approach if you do not know how.

Run following codes in Greenfield e2e tests to get validator and challenger private keys
```go
// please refer to greenfield repo for more information
// challenger key
fmt.Println(common.Bytes2Hex(s.Challenger.GetPrivKey().Bytes()))
```shell
$ ./build/bin/gnfd keys export ${BLS_KEY_NAME} --unsafe --unarmored-hex --home=${CLIENT_KEYRING_DIR} --keyring-backend=test
$ WARNING: The private key will be exported as an unarmored hexadecimal string. USE AT YOUR OWN RISK. Continue? [y/N]: y
```

// bls key
fmt.Println(common.Bytes2Hex(s.Validator.GetBlsPrivKey().Bytes()))
```shell
$ ./build/bin/gnfd keys export ${CHALLENGER_NAME} --unsafe --unarmored-hex --home=${CLIENT_KEYRING_DIR} --keyring-backend=test
$ WARNING: The private key will be exported as an unarmored hexadecimal string. USE AT YOUR OWN RISK. Continue? [y/N]: y
```

### Update config.json for keys, and MySQL
Expand Down Expand Up @@ -163,4 +167,4 @@ Please make sure your contributions adhere to our coding guidelines:
## License
The repo is licensed under the
[GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.en.html), also
included in our repository in the `COPYING` file.
included in our repository in the `COPYING` file.
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ func NewApp(cfg *config.Config) *App {
dbPath := fmt.Sprintf("%s:%s@%s", username, password, cfg.DBConfig.DBPath)

db, err := gorm.Open(mysql.Open(dbPath), &gorm.Config{})
// db = db.Debug() only for debug purpose

//only for debug purpose
db = db.Debug()

if err != nil {
panic(fmt.Sprintf("open db error, err=%+v", err.Error()))
}
Expand Down
1 change: 0 additions & 1 deletion attest/attest_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (a *AttestMonitor) UpdateAttestedChallengeIdLoop() {
logging.Logger.Errorf("update latest attested challenge error, err=%+v", err)
continue
}
logging.Logger.Infof("latest attested challenge ids: %+v", challengeIds)
a.mtx.Lock()
a.updateAttestedCacheAndEventStatus(a.attestedChallengeIds, challengeIds)
for _, id := range challengeIds {
Expand Down
4 changes: 2 additions & 2 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

var (
RtyAttemNum = uint(5)
RtyAttemNum = uint(2)
RtyAttem = retry.Attempts(RtyAttemNum)
RtyDelay = retry.Delay(time.Millisecond * 400)
RtyDelay = retry.Delay(time.Millisecond * 500)
RtyErr = retry.LastErrorOnly(true)
RetryInterval = 1 * time.Second
CacheClearIterations = 100
Expand Down
1 change: 0 additions & 1 deletion db/model/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ const (
Unknown VerifyResult = iota // Event not been verified
HashMatched // The challenge failed, hashes are matched
HashMismatched // The challenge succeed, hashed are not matched
BucketDeleted
)
4 changes: 2 additions & 2 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (e *Executor) AttestChallenge(submitterAddress, challengerAddress, spOperat
res, err := client.AttestChallenge(context.Background(), submitterAddress, challengerAddress, spOperatorAddress, challengeId, objectId, voteResult, voteValidatorSet, VoteAggSignature, txOption)
if err != nil {
if res == nil {
logging.Logger.Infof("attest failed for challengeId: %d, res is nil", challengeId)
logging.Logger.Infof("attest failed for challengeId: %d, res is nil, err=%s", challengeId, err.Error())
} else {
logging.Logger.Infof("challengeId: %d attest failed, code=%d, log=%s, txhash=%s, timestamp: %s, err=%s", challengeId, res.Code, res.RawLog, res.TxHash, time.Now().Format("15:04:05.000000"), err.Error())
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (e *Executor) GetObjectInfoChecksums(objectId string) ([][]byte, error) {
logging.Logger.Errorf("executor failed to query storage client for objectId %s, err=%+v", objectId, err.Error())
return nil, err
}
return res.GetChecksums(), nil
return res.ObjectInfo.GetChecksums(), nil
}

func (e *Executor) GetChallengeResultFromSp(objectId, endpoint string, segmentIndex, redundancyIndex int) (*types.ChallengeResult, error) {
Expand Down
50 changes: 27 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/bnb-chain/greenfield-challenger
go 1.20

require (
cosmossdk.io/math v1.0.0
cosmossdk.io/math v1.0.1
github.com/avast/retry-go/v4 v4.3.1
github.com/aws/aws-sdk-go v1.40.45
github.com/bnb-chain/greenfield v0.2.2
github.com/bnb-chain/greenfield-common/go v0.0.0-20230512062756-5d7790d0ccbf
github.com/bnb-chain/greenfield-go-sdk v0.2.2
github.com/bnb-chain/greenfield v0.2.3
github.com/bnb-chain/greenfield-common/go v0.0.0-20230720022901-7e7158fd397d
github.com/bnb-chain/greenfield-go-sdk v0.2.3
github.com/cometbft/cometbft v0.37.1
github.com/cosmos/cosmos-sdk v0.47.0-rc2.0.20230220103612-f094a0c33410
github.com/cosmos/cosmos-sdk v0.47.3
github.com/ethereum/go-ethereum v1.10.26
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
Expand All @@ -20,8 +20,9 @@ require (
github.com/prysmaticlabs/prysm v0.0.0-20220124113610-e26cde5e091b
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
github.com/willf/bitset v1.1.11
golang.org/x/sync v0.2.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gorm.io/driver/mysql v1.4.5
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11
Expand Down Expand Up @@ -51,11 +52,12 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cometbft/cometbft-db v0.7.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/consensys/gnark-crypto v0.7.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.8 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/iavl v0.20.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand All @@ -77,7 +79,7 @@ require (
github.com/go-sql-driver/mysql v1.7.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/glog v1.1.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
Expand All @@ -101,8 +103,9 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/reedsolomon v1.11.7 // indirect
github.com/klauspost/reedsolomon v1.11.8 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.7.16 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
Expand All @@ -124,18 +127,17 @@ require (
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prysmaticlabs/eth2-types v0.0.0-20210303084904-c9735a06829d // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/rs/zerolog v1.29.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
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
github.com/tidwall/btree v1.6.0 // indirect
Expand All @@ -147,16 +149,16 @@ require (
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 // indirect
google.golang.org/grpc v1.54.0 // indirect
golang.org/x/tools v0.9.3 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -169,9 +171,11 @@ replace (
cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9
cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.1
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/ferranbt/fastssz => github.com/prysmaticlabs/fastssz v0.0.0-20220110145812-fafb696cae88
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20210702154020-550e1cd83ec1
Expand Down
Loading

0 comments on commit 452aab0

Please sign in to comment.