Skip to content

Commit 906bcb6

Browse files
authored
fix: add mainnet fallback addresses for middleware (#295)
<!-- 🚨 ATTENTION! 🚨 This PR template is REQUIRED. PRs not following this format will be closed without review. Requirements: - PR title must follow commit conventions: https://www.conventionalcommits.org/en/v1.0.0/ - Label your PR with the correct type (e.g., 🐛 Bug, ✨ Enhancement, 🧪 Test, etc.) - Provide clear and specific details in each section --> **Motivation:** <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. --> As a devkit user who has missing addresses in my context, I want the defaulted middleware addresses to match my context **Modifications:** <!-- Describe the modifications you've done from a high level. What are the key technical decisions and why were they made? --> - Adds `mainnet` fallback addresses for EigenLayer middleware contracts - Defaults missing addresses based on provided context name **Result:** <!-- *After your change, what will change. --> - Deployments to `mainnet` will default to the correct `TableCalculator` based on env
1 parent 8a3e173 commit 906bcb6

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

pkg/commands/context/context_create.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,32 @@ func contextCreateAction(cCtx *cli.Context) error {
196196
logger.Info("Continuing with addresses from config...")
197197
} else {
198198
logger.Info("Successfully updated context with addresses from Zeus")
199-
if err := common.WriteYAML(yamlPath, rootNode); err != nil {
200-
return fmt.Errorf("failed to save updated context: %v", err)
201-
}
202199
}
203200
}
204201

202+
// Place middleware addresses into context
203+
bn254TableCalculator := common.SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS
204+
ecdsaTableCalculator := common.SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS
205+
if int(l1ChainID.Uint64()) == 1 {
206+
bn254TableCalculator = common.MAINNET_BN254_TABLE_CALCULATOR_ADDRESS
207+
ecdsaTableCalculator = common.MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS
208+
}
209+
bn254TableCalculatorPath := "eigenlayer.l1.bn254_table_calculator"
210+
ecdsaTableCalculatorPath := "eigenlayer.l1.ecdsa_table_calculator"
211+
_, err = common.WriteToPath(contextNode, strings.Split(bn254TableCalculatorPath, "."), bn254TableCalculator)
212+
if err != nil {
213+
return fmt.Errorf("setting value %s to %s failed: %w", bn254TableCalculatorPath, bn254TableCalculator, err)
214+
}
215+
_, err = common.WriteToPath(contextNode, strings.Split(ecdsaTableCalculatorPath, "."), ecdsaTableCalculator)
216+
if err != nil {
217+
return fmt.Errorf("setting value %s to %s failed: %w", ecdsaTableCalculatorPath, ecdsaTableCalculator, err)
218+
}
219+
220+
// Save all updates to the yaml file
221+
if err := common.WriteYAML(yamlPath, rootNode); err != nil {
222+
return fmt.Errorf("failed to save updated context: %v", err)
223+
}
224+
205225
logContextCreated(logger, cntxDir, name, ctxDoc, cCtx.Bool("use"))
206226
return nil
207227
}

pkg/common/constants.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ const (
3939
CURVE_TYPE_KEY_REGISTRAR_BN254 = 2
4040

4141
// These are fallback EigenLayer deployment addresses when not specified in context (assumes seploia)
42-
ALLOCATION_MANAGER_ADDRESS = "0x42583067658071247ec8CE0A516A58f682002d07"
43-
DELEGATION_MANAGER_ADDRESS = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
44-
STRATEGY_MANAGER_ADDRESS = "0x2E3D6c0744b10eb0A4e6F679F71554a39Ec47a5D"
45-
KEY_REGISTRAR_ADDRESS = "0xA4dB30D08d8bbcA00D40600bee9F029984dB162a"
46-
CROSS_CHAIN_REGISTRY_ADDRESS = "0x287381B1570d9048c4B4C7EC94d21dDb8Aa1352a"
47-
BN254_TABLE_CALCULATOR_ADDRESS = "0xa19E3B00cf4aC46B5e6dc0Bbb0Fb0c86D0D65603"
48-
ECDSA_TABLE_CALCULATOR_ADDRESS = "0xaCB5DE6aa94a1908E6FA577C2ade65065333B450"
49-
MULTICHAIN_PROXY_ADMIN = "0xC5dc0d145a21FDAD791Df8eDC7EbCB5330A3FdB5"
50-
EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
51-
RELEASE_MANAGER_ADDRESS = "0xd9Cb89F1993292dEC2F973934bC63B0f2A702776"
42+
ALLOCATION_MANAGER_ADDRESS = "0x42583067658071247ec8CE0A516A58f682002d07"
43+
DELEGATION_MANAGER_ADDRESS = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
44+
STRATEGY_MANAGER_ADDRESS = "0x2E3D6c0744b10eb0A4e6F679F71554a39Ec47a5D"
45+
KEY_REGISTRAR_ADDRESS = "0xA4dB30D08d8bbcA00D40600bee9F029984dB162a"
46+
CROSS_CHAIN_REGISTRY_ADDRESS = "0x287381B1570d9048c4B4C7EC94d21dDb8Aa1352a"
47+
MULTICHAIN_PROXY_ADMIN = "0xC5dc0d145a21FDAD791Df8eDC7EbCB5330A3FdB5"
48+
EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
49+
RELEASE_MANAGER_ADDRESS = "0xd9Cb89F1993292dEC2F973934bC63B0f2A702776"
50+
51+
// These are fallback EigenLayer Middleware deployment addresses when not specified in context
52+
SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS = "0xa19E3B00cf4aC46B5e6dc0Bbb0Fb0c86D0D65603"
53+
SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS = "0xaCB5DE6aa94a1908E6FA577C2ade65065333B450"
54+
55+
MAINNET_BN254_TABLE_CALCULATOR_ADDRESS = "0x55F4b21681977F412B318eCB204cB933bD1dF57c"
56+
MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS = "0xA933CB4cbD0C4C208305917f56e0C3f51ad713Fa"
5257
)

pkg/common/getters.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,26 @@ func GetForkUrlDefault(contextName string, cfg *ConfigWithContextConfig, chainNa
3232
// GetEigenLayerAddresses returns EigenLayer L1 addresses from the context config
3333
// Falls back to constants if not found in context
3434
func GetEigenLayerAddresses(contextName string, cfg *ConfigWithContextConfig) (allocationManager, delegationManager, strategyManager, keyRegistrar, crossChainRegistry, bn254TableCalculator, ecdsaTableCalculator, releaseManager string) {
35+
// Default middleware addresses according to context
36+
var BN254_TABLE_CALCULATOR_ADDRESS = SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS
37+
var ECDSA_TABLE_CALCULATOR_ADDRESS = SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS
38+
if contextName == "mainnet" {
39+
BN254_TABLE_CALCULATOR_ADDRESS = MAINNET_BN254_TABLE_CALCULATOR_ADDRESS
40+
ECDSA_TABLE_CALCULATOR_ADDRESS = MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS
41+
}
42+
43+
// Return constants for undefined context
3544
if cfg == nil || cfg.Context == nil {
3645
return ALLOCATION_MANAGER_ADDRESS, DELEGATION_MANAGER_ADDRESS, STRATEGY_MANAGER_ADDRESS, KEY_REGISTRAR_ADDRESS, CROSS_CHAIN_REGISTRY_ADDRESS, BN254_TABLE_CALCULATOR_ADDRESS, ECDSA_TABLE_CALCULATOR_ADDRESS, RELEASE_MANAGER_ADDRESS
3746
}
3847

48+
// Return constants for missing context
3949
ctx, found := cfg.Context[contextName]
4050
if !found || ctx.EigenLayer == nil {
4151
return ALLOCATION_MANAGER_ADDRESS, DELEGATION_MANAGER_ADDRESS, STRATEGY_MANAGER_ADDRESS, KEY_REGISTRAR_ADDRESS, CROSS_CHAIN_REGISTRY_ADDRESS, BN254_TABLE_CALCULATOR_ADDRESS, ECDSA_TABLE_CALCULATOR_ADDRESS, RELEASE_MANAGER_ADDRESS
4252
}
4353

54+
// Default each address to constant if missing from discovered context
4455
allocationManager = ctx.EigenLayer.L1.AllocationManager
4556
if allocationManager == "" {
4657
allocationManager = ALLOCATION_MANAGER_ADDRESS

0 commit comments

Comments
 (0)