Skip to content
Merged
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
16 changes: 15 additions & 1 deletion aggregator/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aggregator

import (
"fmt"
"strconv"
"time"

"github.com/AvaProtocol/EigenLayer-AVS/core/auth"
Expand Down Expand Up @@ -44,11 +45,24 @@ func CreateAdminKey(configPath string, opt CreateApiKeyOption) error {
roles[i] = auth.ApiRole(v)
}

// The verifier (aggregator/auth.go::verifyAuth) requires the JWT to have an
// `aud` claim containing the smart wallet chain ID. r.chainID in the
// verifier is sourced from the smart wallet RPC (see rpc_server.go), not
// the EigenLayer RPC, so we must use SmartWallet.ChainID here too — using
// the EigenLayer chain ID would silently break cross-chain configs (e.g.
// EigenLayer on Ethereum + SmartWallet on Base). config.NewConfig already
// populated SmartWallet.ChainID at startup, so no extra RPC dial is needed.
if nodeConfig.SmartWallet == nil || nodeConfig.SmartWallet.ChainID == 0 {
return fmt.Errorf("smart wallet chain ID not populated in config; cannot build audience claim")
}
Comment on lines +48 to +57
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces an extra RPC dial + ChainID call during create-api-key, but config.NewConfig already dials RPCs and stores the chain ID on nodeConfig.SmartWallet.ChainID. Avoiding the additional network round-trip (and dependency on EthHttpRpcUrl reachability) will make key generation faster and less failure-prone.

Copilot uses AI. Check for mistakes.
audienceChainID := strconv.FormatInt(nodeConfig.SmartWallet.ChainID, 10)

claims := &auth.APIClaim{
RegisteredClaims: &jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 365 * 10)),
Issuer: "AvaProtocol",
Issuer: auth.Issuer,
Subject: opt.Subject,
Audience: jwt.ClaimStrings{audienceChainID},
},
Roles: roles,
}
Expand Down
Loading