Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ GNOSIS_SEND_INTERVAL="600"
NODE_URL="https://erpc.chiado.staging.shutter.network"
WAIT_TX_TIMEOUT=10
TEST_DURATION=1

#DECRYPTION MONITOR
SHUTTER_API="http://shutter-api.shutter.network/api"
API_REQUEST_INTERVAL="60"
SHUTTER_REGISTRY_CALLER_ADDRESS="0x228DefCF37Da29475F0EE2B9E4dfAeDc3b0746bc"
DEC_KEY_WAIT_INTERVAL="20"
```

- `MODE=chiado`: Sends transactions at intervals defined by `CHIADO_SEND_INTERVAL` to the Chiado URL.
Expand All @@ -41,6 +47,7 @@ TEST_DURATION=1
- waits for a timeout defined by `WAIT_TX_TIMEOUT`
- then sends the next one at nonce `n+ 1`
- test is run for the duration defined in `TEST_DURATION`
- `MODE=decryption-monitor`: Sends an HTTP request to register an identity at intervals defined by `API_REQUEST_INTERVAL` on the Shutter API, and monitors the release of relevant decryption keys by requesting them from the Shutter API at intervals defined by `DEC_KEY_WAIT_INTERVAL`.

- Multiple tests can be run at the same time by separating the different modes with a comma, i.e. `MODE="chiado,gnosis"`.

Expand Down
59 changes: 34 additions & 25 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,49 @@ import (
"os"
"strconv"
"time"

"github.com/joho/godotenv"
)

type Config struct {
Mode string
PrivateKey string
ChiadoURL string
ChiadoSendInterval time.Duration
GnosisURL string
GnosisSendInterval time.Duration
Interval time.Duration
Timeout time.Duration
TestDuration time.Duration
NodeURL string
Mode string
PrivateKey string
ChiadoURL string
ChiadoSendInterval time.Duration
GnosisURL string
GnosisSendInterval time.Duration
Interval time.Duration
Timeout time.Duration
TestDuration time.Duration
NodeURL string
ShutterAPI string
ShutterRegistryCaller string
ShutterRegistryCallerNonce string
ApiRequestInterval time.Duration
DecryptionKeyWaitInterval time.Duration
BlameFolder string
}

func LoadConfig() Config {
// Load the .env file
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file")
}
// err := godotenv.Load()
// if err != nil {
// log.Fatalf("Error loading .env file")
// }

config := Config{
Mode: os.Getenv("MODE"),
PrivateKey: os.Getenv("PRIVATE_KEY"),
ChiadoURL: os.Getenv("CHIADO_URL"),
ChiadoSendInterval: time.Duration(GetEnvAsInt("CHIADO_SEND_INTERVAL")) * time.Second,
GnosisURL: os.Getenv("GNOSIS_URL"),
GnosisSendInterval: time.Duration(GetEnvAsInt("GNOSIS_SEND_INTERVAL")) * time.Second,
Timeout: time.Duration(GetEnvAsInt("WAIT_TX_TIMEOUT")) * time.Second,
TestDuration: time.Duration(GetEnvAsInt("TEST_DURATION")) * time.Second,
NodeURL: os.Getenv("NODE_URL"),
Mode: os.Getenv("MODE"),
PrivateKey: os.Getenv("PRIVATE_KEY"),
ChiadoURL: os.Getenv("CHIADO_URL"),
ChiadoSendInterval: time.Duration(GetEnvAsInt("CHIADO_SEND_INTERVAL")) * time.Second,
GnosisURL: os.Getenv("GNOSIS_URL"),
GnosisSendInterval: time.Duration(GetEnvAsInt("GNOSIS_SEND_INTERVAL")) * time.Second,
Timeout: time.Duration(GetEnvAsInt("WAIT_TX_TIMEOUT")) * time.Second,
TestDuration: time.Duration(GetEnvAsInt("TEST_DURATION")) * time.Second,
NodeURL: os.Getenv("NODE_URL"),
ShutterAPI: os.Getenv("SHUTTER_API"),
ApiRequestInterval: time.Duration(GetEnvAsInt("API_REQUEST_INTERVAL")) * time.Second,
ShutterRegistryCaller: os.Getenv("SHUTTER_REGISTRY_CALLER_ADDRESS"),
DecryptionKeyWaitInterval: time.Duration(GetEnvAsInt("DEC_KEY_WAIT_INTERVAL")) * time.Second,
BlameFolder: os.Getenv("DECRYPTION_BLAME_FOLDER"),
}

return config
Expand Down
26 changes: 15 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ services:
volumes:
- ./logs:/app/logs
environment:
- PRIVATE_KEY=${PRIVATE_KEY}
- MODE=${MODE}
- CHIADO_URL=${CHIADO_URL}
- CHIADO_SEND_INTERVAL=${CHIADO_SEND_INTERVAL}
- GNOSIS_URL=${GNOSIS_URL}
- GNOSIS_SEND_INTERVAL=${GNOSIS_SEND_INTERVAL}
- NODE_URL=${NODE_URL}
- WAIT_TX_TIMEOUT=${WAIT_TX_TIMEOUT}
- TEST_DURATION=${TEST_DURATION}

command: ./main
PRIVATE_KEY:
MODE:
CHIADO_URL:
CHIADO_SEND_INTERVAL:
GNOSIS_URL:
GNOSIS_SEND_INTERVAL:
NODE_URL:
WAIT_TX_TIMEOUT:
TEST_DURATION:
SHUTTER_API:
SHUTTER_REGISTRY_CALLER_ADDRESS:
API_REQUEST_INTERVAL:
DEC_KEY_WAIT_INTERVAL:
DECRYPTION_BLAME_FOLDER:
# command: ./main
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sync v0.7.0
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
var modes []string
var cfg config.Config
if len(os.Args[1:]) == 0 {
cfg := config.LoadConfig()
cfg = config.LoadConfig()
log.Println(cfg.Mode)
mode := cfg.Mode

Expand Down Expand Up @@ -65,6 +65,12 @@ func main() {
runCollector()
wg.Done()
}()
case "decryption-monitor":
wg.Add(1)
go func() {
tests.RunDecryptionMonitor(cfg)
wg.Done()
}()
default:
log.Printf("Unknown mode: %s", m)
}
Expand Down
6 changes: 6 additions & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ NODE_URL="https://erpc.chiado.staging.shutter.network"
WAIT_TX_TIMEOUT=10
TEST_DURATION=1

#DECRYPTION MONITOR
SHUTTER_API="http://shutter-api.shutter.network/api"
API_REQUEST_INTERVAL="60"
SHUTTER_REGISTRY_CALLER_ADDRESS="0x228DefCF37Da29475F0EE2B9E4dfAeDc3b0746bc"
DEC_KEY_WAIT_INTERVAL="20"
DECRYPTION_BLAME_FOLDER="decryptionBlameDir"
Loading