Skip to content

Commit

Permalink
Normalize config allowlist to use lowercased account keys
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Oct 28, 2024
1 parent 4b53e54 commit 14dd7db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 5 additions & 2 deletions disperser/apiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"os"
"strconv"
"strings"
"time"

"github.com/Layr-Labs/eigenda/common"
Expand Down Expand Up @@ -164,9 +165,11 @@ func ReadAllowlistFromFile(f string) (Allowlist, error) {
}

for _, entry := range allowlistEntries {
rateInfoByQuorum, ok := allowlist[entry.Account]
// normalize account/address to lowercase
account := strings.ToLower(entry.Account)
rateInfoByQuorum, ok := allowlist[account]
if !ok {
allowlist[entry.Account] = map[core.QuorumID]PerUserRateInfo{
allowlist[account] = map[core.QuorumID]PerUserRateInfo{
core.QuorumID(entry.QuorumID): {
Name: entry.Name,
Throughput: common.RateParam(entry.ByteRate),
Expand Down
13 changes: 3 additions & 10 deletions disperser/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,10 @@ func (s *DispersalServer) getAccountRate(origin, authenticatedAddress string, qu

// Check if the address is in the allowlist
if len(authenticatedAddress) > 0 {
// Normalize to non-checksummed (lowercase) address
authenticatedAddress = strings.ToLower(authenticatedAddress)

quorumRates, ok := s.rateConfig.Allowlist[authenticatedAddress]
if !ok {
// check fallback address (non-checksummed)
fallbackAuthenticatedAddress := strings.ToLower(authenticatedAddress)
quorumRates, ok = s.rateConfig.Allowlist[fallbackAuthenticatedAddress]
if ok {
s.logger.Warn("authenticated address found via fallback lookup", "authenticatedAddress", authenticatedAddress, "fallback", fallbackAuthenticatedAddress)
authenticatedAddress = fallbackAuthenticatedAddress
}
}
if ok {
rateInfo, ok := quorumRates[quorumID]
if ok {
Expand All @@ -351,7 +345,6 @@ func (s *DispersalServer) getAccountRate(origin, authenticatedAddress string, qu
} else {
s.logger.Warn("authenticated address not found in allowlist", "authenticatedAddress", authenticatedAddress)
}

}

// Check if the origin is in the allowlist
Expand Down

0 comments on commit 14dd7db

Please sign in to comment.