Skip to content

Commit

Permalink
feat(coordinator): use dotenv for whitelist (#784)
Browse files Browse the repository at this point in the history
Co-authored-by: Your Name <you@example.com>
  • Loading branch information
0xmountaintop and Your Name authored Aug 14, 2023
1 parent 55658c6 commit 251c706
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

var tag = "v4.1.39"
var tag = "v4.1.40"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
5 changes: 4 additions & 1 deletion coordinator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ require (
google.golang.org/protobuf v1.31.0 // indirect
)

require github.com/prometheus/client_golang v1.14.0
require (
github.com/joho/godotenv v1.5.1
github.com/prometheus/client_golang v1.14.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions coordinator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
Expand Down
9 changes: 9 additions & 0 deletions coordinator/internal/logic/provertask/chunk_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/scroll-tech/go-ethereum/common"
Expand Down Expand Up @@ -58,6 +59,10 @@ func NewChunkProverTask(cfg *config.Config, db *gorm.DB, reg prometheus.Register

// TODO: change to use publickey
func isChunkProverWhitelisted(proverName string) bool {
if err := godotenv.Load(); err != nil {
return false
}

whitelist := os.Getenv("WHITELISTED_CHUNK_PROVERS")
wProvers := strings.Split(whitelist, ";")
for _, wProver := range wProvers {
Expand All @@ -70,6 +75,10 @@ func isChunkProverWhitelisted(proverName string) bool {

// TODO: change to use chunk hash
func isChunkWhitelisted(index uint64) bool {
if err := godotenv.Load(); err != nil {
return false
}

whitelist := os.Getenv("WHITELISTED_INDEXES")
wIndexes := strings.Split(whitelist, ";")
for _, wIndex := range wIndexes {
Expand Down

0 comments on commit 251c706

Please sign in to comment.