Skip to content

Commit

Permalink
Allow config via environment variables, clean up config and docs (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary authored May 30, 2024
2 parents 84fd947 + c3f9d3b commit 0f8dded
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY: "public.ecr.aws/z6g0f8n7"
REPOSITORY: ${{ github.event.repository.name }}
IMAGE_TAG: ${{ github.sha }}
run: |
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ helm upgrade --install \

### `--config`

EnvVar: `EIGENLAYER_DEBUG`

Optional, path to a file based config to use

### `--debug`
Expand All @@ -109,18 +111,24 @@ Enables debug logging

### `--environment`

EnvVar: `EIGENLAYER_ENVIRONMENT`

The target environment

*Values:* `local, dev, preprod, prod`
*Values:* `preprod, testnet, mainnet`

### `--network`

EnvVar: `EIGENLAYER_NETWORK`

The Ethereum network to target

*Values:* `local, devnet, holesky, mainnet`

### `--rpc-url`

EnvVar: `EIGENLAYER_RPC_URL`

Fully qualified URL to an Ethereum RPC node.

_Example_
Expand All @@ -131,10 +139,14 @@ https://ethereum-holesky-rpc.publicnode.com

### `--private-key`

EnvVar: `EIGENLAYER_PRIVATE_KEY`

An Ethereum account private key, in hexidecimal form.

### `--rewards-coordinator-address`

EnvVar: `EIGENLAYER_REWARDS_COORDINATOR_ADDRESS`

The contract address of the target rewards coordinator contract used to post reward proofs

_Example_
Expand All @@ -145,6 +157,8 @@ _Example_

### `--proof-store-base-url`

EnvVar: `EIGENLAYER_PROOF_STORE_BASE_URL`

The base URL of where rewards data is stored.

e.g.
Expand Down
2 changes: 1 addition & 1 deletion cmd/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ var claimCmd = &cobra.Command{
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
cfg := config.NewClaimConfig()
fmt.Printf("Config: %+v\n", cfg)
logger, err := logger.NewLogger(&logger.LoggerConfig{
Debug: cfg.Debug,
})
Expand Down Expand Up @@ -162,6 +161,7 @@ func init() {
if err := viper.BindPFlag(config.KebabToSnakeCase(f.Name), f); err != nil {
fmt.Printf("Failed to bind flag '%s' - %+v\n", f.Name, err)
}
viper.BindEnv(f.Name)
})

}
2 changes: 1 addition & 1 deletion cmd/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ var distributionCmd = &cobra.Command{
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
cfg := config.NewDistributionConfig()
fmt.Printf("Config: %+v\n", cfg)
logger, err := logger.NewLogger(&logger.LoggerConfig{
Debug: cfg.Debug,
})
Expand Down Expand Up @@ -132,6 +131,7 @@ func init() {
if err := viper.BindPFlag(config.KebabToSnakeCase(f.Name), f); err != nil {
fmt.Printf("Failed to bind flag '%s' - %+v\n", f.Name, err)
}
viper.BindEnv(f.Name)
})

}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func init() {

rootCmd.PersistentFlags().VisitAll(func(f *pflag.Flag) {
viper.BindPFlag(config.KebabToSnakeCase(f.Name), f)
viper.BindEnv(f.Name)
})
initConfig(rootCmd)
}

func initConfig(cmd *cobra.Command) {
fmt.Printf("cfgFile: %s\n", cfgFile)
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
Expand Down
5 changes: 1 addition & 4 deletions cmd/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ func init() {
updaterCmd.Flags().String("network", "localnet", "Which network to use")
updaterCmd.Flags().String("rpc-url", "", "https://ethereum-holesky-rpc.publicnode.com")
updaterCmd.Flags().String("private-key", "", "An ethereum private key")
updaterCmd.Flags().String("aws-access-key-id", "", "AWS access key ID")
updaterCmd.Flags().String("aws-secret-access-key", "", "AWS secret access key")
updaterCmd.Flags().String("aws-region", "us-east-1", "us-east-1")
updaterCmd.Flags().String("s3-output-bucket", "", "s3://<bucket name and path>")
updaterCmd.Flags().String("rewards-coordinator-address", "0x56c119bD92Af45eb74443ab14D4e93B7f5C67896", "Ethereum address of the rewards coordinator contract")
updaterCmd.Flags().String("proof-store-base-url", "", "HTTP base url where data is stored")

updaterCmd.Flags().VisitAll(func(f *pflag.Flag) {
if err := viper.BindPFlag(config.KebabToSnakeCase(f.Name), f); err != nil {
fmt.Printf("Failed to bind flag '%s' - %+v\n", f.Name, err)
}
viper.BindEnv(f.Name)
})

}
5 changes: 1 addition & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ services:
- "--environment='dev'"
- "--network='devnet'"
- "--rpc-url='http://....'"
- "--proof-store-url='https://eigenpayments-dev.s3.us-east-2.amazonaws.com'"
- "--private-key='<ethereum private key>'"
- "--aws-access-key-id='<aws access key id>'"
- "--aws-secret-access-key='<aws secret key>'"
- "--aws-region='us-east-1'"
- "--s3-output-bucket='s3://<url>'"
- "--rewards-coordinator-address='<contract address>'"
6 changes: 2 additions & 4 deletions config.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ environment: ""
network: ""
rpc_url: ""
private_key: ""
aws_access_key_id: ""
aws_secret_access_key: ""
aws_region: ""
s3_output_bucket: ""
proof_store_base_url: "https://eigenpayments-dev.s3.us-east-2.amazonaws.com"
rewards_coordinator_address: ""

# claim/distribution fields
earner_address: ""
tokens: []
claim_timestamp: 'latest'
5 changes: 3 additions & 2 deletions eigenlayer-rewards-updater/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ cronJob:
namespace: default
schedule: "*/15 * * * *" # Runs every 15 minutes looking for new roots to post
image:
repository: 225727539677.dkr.ecr.us-east-1.amazonaws.com/eigenlayer-rewards-updater
repository: public.ecr.aws/z6g0f8n7/eigenlayer-rewards-updater
tag: latest
pullPolicy: Always
config: |
debug: true
environment: ""
network: ""
rpc_url: "https://eigenpayments-dev.s3.us-east-2.amazonaws.com"
rpc_url: "https://ethereum-holesky-rpc.publicnode.com"
private_key: ""
proof_store_base_url: "https://eigenpayments-dev.s3.us-east-2.amazonaws.com"
rewards_coordinator_address: ""
11 changes: 8 additions & 3 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ func NewLogger(cfg *LoggerConfig, options ...zap.Option) (*zap.Logger, error) {
}
copy(mergedOptions, options)

if cfg.Debug == true {
return zap.NewDevelopment(options...)
c := zap.NewProductionConfig()
c.EncoderConfig = zap.NewProductionEncoderConfig()

if cfg.Debug {
c.Level = zap.NewAtomicLevelAt(zap.DebugLevel)
} else {
return zap.NewProduction(options...)
c.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
}

return c.Build(mergedOptions...)
}
2 changes: 1 addition & 1 deletion pkg/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (
func StartTracer() {
ddTracer.Start(
ddTracer.WithGlobalServiceName(true),
ddTracer.WithDebugMode(true),
ddTracer.WithDebugMode(false),
)
}

0 comments on commit 0f8dded

Please sign in to comment.