Skip to content

Commit 694b4ee

Browse files
authored
fix: ensure migrations are context aware (#297)
<!-- 🚨 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 upgrading to the most recent version of devkit, I want any addresses that are updated in my context to be updated according to which network the context represents. **Modifications:** <!-- Describe the modifications you've done from a high level. What are the key technical decisions and why were they made? --> - All `mainnet` and `sepolia` addresses are recorded as constants and are selected according to the networks `chainId` **Result:** <!-- *After your change, what will change. --> - `mainnet` contexts are correctly updated with `mainnet` values **Testing:** <!-- *List testing procedures taken and useful artifacts. --> - Tested in all environments **Open questions:** <!-- (optional) Any open questions or feedback on design desired? --> - Could zeus be extended to pull middleware addresses removing the need for this context aware upgrade?
1 parent ce968e2 commit 694b4ee

File tree

6 files changed

+189
-51
lines changed

6 files changed

+189
-51
lines changed

config/contexts/migrations/v0.0.8-v0.0.9.go

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package contextMigrations
22

33
import (
4+
"github.com/Layr-Labs/devkit-cli/pkg/common"
45
"github.com/Layr-Labs/devkit-cli/pkg/migration"
56

67
"gopkg.in/yaml.v3"
@@ -28,76 +29,116 @@ func Migration_0_0_8_to_0_0_9(user, old, new *yaml.Node) (*yaml.Node, error) {
2829
return &yaml.Node{Kind: yaml.ScalarNode, Value: "28820370"}
2930
},
3031
},
32+
// Update L1 AllocationManager address
33+
{
34+
Path: []string{"context", "eigenlayer", "l1", "allocation_manager"},
35+
Condition: migration.Always{},
36+
Transform: func(_ *yaml.Node) *yaml.Node {
37+
return GetAddressByChainIdFromCtx(user, common.MAINNET_ALLOCATION_MANAGER_ADDRESS, common.SEPOLIA_ALLOCATION_MANAGER_ADDRESS)
38+
},
39+
},
40+
// Update L1 DelegationManager address
41+
{
42+
Path: []string{"context", "eigenlayer", "l1", "delegation_manager"},
43+
Condition: migration.Always{},
44+
Transform: func(_ *yaml.Node) *yaml.Node {
45+
return GetAddressByChainIdFromCtx(user, common.MAINNET_DELEGATION_MANAGER_ADDRESS, common.SEPOLIA_DELEGATION_MANAGER_ADDRESS)
46+
},
47+
},
48+
// Update L1 StrategyManager address
49+
{
50+
Path: []string{"context", "eigenlayer", "l1", "strategy_manager"},
51+
Condition: migration.Always{},
52+
Transform: func(_ *yaml.Node) *yaml.Node {
53+
return GetAddressByChainIdFromCtx(user, common.MAINNET_STRATEGY_MANAGER_ADDRESS, common.SEPOLIA_STRATEGY_MANAGER_ADDRESS)
54+
},
55+
},
56+
// Update L1 ReleaseManager address
57+
{
58+
Path: []string{"context", "eigenlayer", "l1", "release_manager"},
59+
Condition: migration.Always{},
60+
Transform: func(_ *yaml.Node) *yaml.Node {
61+
return GetAddressByChainIdFromCtx(user, common.MAINNET_RELEASE_MANAGER_ADDRESS, common.SEPOLIA_RELEASE_MANAGER_ADDRESS)
62+
},
63+
},
3164
// Update L1 CrossChainRegistry address
3265
{
3366
Path: []string{"context", "eigenlayer", "l1", "cross_chain_registry"},
3467
Condition: migration.Always{},
3568
Transform: func(_ *yaml.Node) *yaml.Node {
36-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0x287381B1570d9048c4B4C7EC94d21dDb8Aa1352a"}
69+
return GetAddressByChainIdFromCtx(user, common.MAINNET_CROSS_CHAIN_REGISTRY_ADDRESS, common.SEPOLIA_CROSS_CHAIN_REGISTRY_ADDRESS)
3770
},
3871
},
3972
// Update L1 OperatorTableUpdater address
4073
{
4174
Path: []string{"context", "eigenlayer", "l1", "operator_table_updater"},
4275
Condition: migration.Always{},
4376
Transform: func(_ *yaml.Node) *yaml.Node {
44-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xB02A15c6Bd0882b35e9936A9579f35FB26E11476"}
77+
return GetAddressByChainIdFromCtx(user, common.MAINNET_L1_OPERATOR_TABLE_UPDATER_ADDRESS, common.SEPOLIA_L1_OPERATOR_TABLE_UPDATER_ADDRESS)
4578
},
4679
},
4780
// Update L1 KeyRegistrar address
4881
{
4982
Path: []string{"context", "eigenlayer", "l1", "key_registrar"},
5083
Condition: migration.Always{},
5184
Transform: func(_ *yaml.Node) *yaml.Node {
52-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xA4dB30D08d8bbcA00D40600bee9F029984dB162a"}
85+
return GetAddressByChainIdFromCtx(user, common.MAINNET_KEY_REGISTRAR_ADDRESS, common.SEPOLIA_KEY_REGISTRAR_ADDRESS)
86+
},
87+
},
88+
// Update L1 TaskMailbox address
89+
{
90+
Path: []string{"context", "eigenlayer", "l1", "task_mailbox"},
91+
Condition: migration.Always{},
92+
Transform: func(_ *yaml.Node) *yaml.Node {
93+
return GetAddressByChainIdFromCtx(user, common.MAINNET_L1_TASK_MAILBOX_ADDRESS, common.SEPOLIA_L1_TASK_MAILBOX_ADDRESS)
5394
},
5495
},
5596
// Update L2 TaskMailbox address
5697
{
5798
Path: []string{"context", "eigenlayer", "l2", "task_mailbox"},
5899
Condition: migration.Always{},
59100
Transform: func(_ *yaml.Node) *yaml.Node {
60-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xB99CC53e8db7018f557606C2a5B066527bF96b26"}
101+
return GetAddressByChainIdFromCtx(user, common.MAINNET_L2_TASK_MAILBOX_ADDRESS, common.SEPOLIA_L2_TASK_MAILBOX_ADDRESS)
61102
},
62103
},
63104
// Update L2 OperatorTableUpdater address
64105
{
65106
Path: []string{"context", "eigenlayer", "l2", "operator_table_updater"},
66107
Condition: migration.Always{},
67108
Transform: func(_ *yaml.Node) *yaml.Node {
68-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xB02A15c6Bd0882b35e9936A9579f35FB26E11476"}
109+
return GetAddressByChainIdFromCtx(user, common.MAINNET_L2_OPERATOR_TABLE_UPDATER_ADDRESS, common.SEPOLIA_L2_OPERATOR_TABLE_UPDATER_ADDRESS)
69110
},
70111
},
71112
// Update L2 BN254CertificateVerifier address
72113
{
73114
Path: []string{"context", "eigenlayer", "l2", "bn254_certificate_verifier"},
74115
Condition: migration.Always{},
75116
Transform: func(_ *yaml.Node) *yaml.Node {
76-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xff58A373c18268F483C1F5cA03Cf885c0C43373a"}
117+
return GetAddressByChainIdFromCtx(user, common.MAINNET_BN254_CERTIFICATE_VERIFIER_ADDRESS, common.SEPOLIA_BN254_CERTIFICATE_VERIFIER_ADDRESS)
77118
},
78119
},
79120
// Update L2 ECDSACertificateVerifier address
80121
{
81122
Path: []string{"context", "eigenlayer", "l2", "ecdsa_certificate_verifier"},
82123
Condition: migration.Always{},
83124
Transform: func(_ *yaml.Node) *yaml.Node {
84-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xb3Cd1A457dEa9A9A6F6406c6419B1c326670A96F"}
125+
return GetAddressByChainIdFromCtx(user, common.MAINNET_ECDSA_CERTIFICATE_VERIFIER_ADDRESS, common.SEPOLIA_ECDSA_CERTIFICATE_VERIFIER_ADDRESS)
85126
},
86127
},
87-
// Update L1 BN254TableCalculator address
128+
// Update L1 BN254TableCalculator address (env aware - this will not be updated by zeus)
88129
{
89130
Path: []string{"context", "eigenlayer", "l1", "bn254_table_calculator"},
90131
Condition: migration.Always{},
91132
Transform: func(_ *yaml.Node) *yaml.Node {
92-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xa19E3B00cf4aC46B5e6dc0Bbb0Fb0c86D0D65603"}
133+
return GetAddressByChainIdFromCtx(user, common.MAINNET_BN254_TABLE_CALCULATOR_ADDRESS, common.SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS)
93134
},
94135
},
95-
// Update L1 ECDSATableCalculator address
136+
// Update L1 ECDSATableCalculator middleware address (env aware - this will not be updated by zeus)
96137
{
97138
Path: []string{"context", "eigenlayer", "l1", "ecdsa_table_calculator"},
98139
Condition: migration.Always{},
99140
Transform: func(_ *yaml.Node) *yaml.Node {
100-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0xaCB5DE6aa94a1908E6FA577C2ade65065333B450"}
141+
return GetAddressByChainIdFromCtx(user, common.MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS, common.SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS)
101142
},
102143
},
103144
},
@@ -114,3 +155,14 @@ func Migration_0_0_8_to_0_0_9(user, old, new *yaml.Node) (*yaml.Node, error) {
114155

115156
return user, nil
116157
}
158+
159+
func GetAddressByChainIdFromCtx(ctx *yaml.Node, mainnetAddress, sepoliaAddress string) *yaml.Node {
160+
// check l1 chainId - if == 1 then use MAINNET address
161+
chainId := migration.ResolveNode(ctx, []string{"context", "chains", "l1", "chain_id"})
162+
address := sepoliaAddress
163+
if chainId != nil && chainId.Value == "1" {
164+
address = mainnetAddress
165+
}
166+
167+
return &yaml.Node{Kind: yaml.ScalarNode, Value: address}
168+
}

config/contexts/migrations/v0.0.9-v0.1.0.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/Layr-Labs/devkit-cli/pkg/common"
78
"github.com/Layr-Labs/devkit-cli/pkg/migration"
89

910
"gopkg.in/yaml.v3"
@@ -12,10 +13,18 @@ import (
1213
func Migration_0_0_9_to_0_1_0(user, old, new *yaml.Node) (*yaml.Node, error) {
1314
// Add missing strategy upgrade to move stETH from holesky to sepolia
1415
const (
15-
oldStrat = "0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3"
16-
newStrat = "0x8b29d91e67b013e855EaFe0ad704aC4Ab086a574"
16+
oldStrat = "0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3"
17+
newSepoliaStrat = "0x8b29d91e67b013e855EaFe0ad704aC4Ab086a574"
18+
newMainnetStrat = "0x93c4b944d05dfe6df7645a86cd2206016c51564d"
1719
)
1820

21+
// check l1 chainId - if == 1 then use MAINNET address
22+
chainId := migration.ResolveNode(user, []string{"context", "chains", "l1", "chain_id"})
23+
newStrat := newSepoliaStrat
24+
if chainId != nil && chainId.Value == "1" {
25+
newStrat = newMainnetStrat
26+
}
27+
1928
// Patch all changes in context
2029
engine := migration.PatchEngine{
2130
Old: old,
@@ -175,7 +184,7 @@ func Migration_0_0_9_to_0_1_0(user, old, new *yaml.Node) (*yaml.Node, error) {
175184
Path: []string{"context", "eigenlayer", "l1", "permission_controller"},
176185
Condition: migration.Always{},
177186
Transform: func(_ *yaml.Node) *yaml.Node {
178-
return &yaml.Node{Kind: yaml.ScalarNode, Value: "0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37"}
187+
return GetAddressByChainIdFromCtx(user, common.MAINNET_PERMISSION_CONTROLLER_ADDRESS, common.SEPOLIA_PERMISSION_CONTROLLER_ADDRESS)
179188
},
180189
},
181190
// Update L1 fork block

pkg/common/constants.go

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,47 @@ const (
3838
CURVE_TYPE_KEY_REGISTRAR_ECDSA = 1
3939
CURVE_TYPE_KEY_REGISTRAR_BN254 = 2
4040

41-
// 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-
MULTICHAIN_PROXY_ADMIN = "0xC5dc0d145a21FDAD791Df8eDC7EbCB5330A3FdB5"
48-
EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
49-
RELEASE_MANAGER_ADDRESS = "0xd9Cb89F1993292dEC2F973934bC63B0f2A702776"
41+
// These are fallback EigenLayer deployment addresses when not specified in context (seploia)
42+
SEPOLIA_ALLOCATION_MANAGER_ADDRESS = "0x42583067658071247ec8CE0A516A58f682002d07"
43+
SEPOLIA_DELEGATION_MANAGER_ADDRESS = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
44+
SEPOLIA_STRATEGY_MANAGER_ADDRESS = "0x2E3D6c0744b10eb0A4e6F679F71554a39Ec47a5D"
45+
SEPOLIA_KEY_REGISTRAR_ADDRESS = "0xA4dB30D08d8bbcA00D40600bee9F029984dB162a"
46+
SEPOLIA_CROSS_CHAIN_REGISTRY_ADDRESS = "0x287381B1570d9048c4B4C7EC94d21dDb8Aa1352a"
47+
SEPOLIA_EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
48+
SEPOLIA_RELEASE_MANAGER_ADDRESS = "0xd9Cb89F1993292dEC2F973934bC63B0f2A702776"
49+
SEPOLIA_L1_TASK_MAILBOX_ADDRESS = "0xB99CC53e8db7018f557606C2a5B066527bF96b26"
50+
SEPOLIA_L1_OPERATOR_TABLE_UPDATER_ADDRESS = "0xB02A15c6Bd0882b35e9936A9579f35FB26E11476"
51+
SEPOLIA_PERMISSION_CONTROLLER_ADDRESS = "0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37"
5052

5153
// These are fallback EigenLayer Middleware deployment addresses when not specified in context
5254
SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS = "0xa19E3B00cf4aC46B5e6dc0Bbb0Fb0c86D0D65603"
5355
SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS = "0xaCB5DE6aa94a1908E6FA577C2ade65065333B450"
5456

57+
// These are L2 fallback addresses
58+
SEPOLIA_L2_TASK_MAILBOX_ADDRESS = "0xB99CC53e8db7018f557606C2a5B066527bF96b26"
59+
SEPOLIA_L2_OPERATOR_TABLE_UPDATER_ADDRESS = "0xB02A15c6Bd0882b35e9936A9579f35FB26E11476"
60+
SEPOLIA_BN254_CERTIFICATE_VERIFIER_ADDRESS = "0xff58A373c18268F483C1F5cA03Cf885c0C43373a"
61+
SEPOLIA_ECDSA_CERTIFICATE_VERIFIER_ADDRESS = "0xb3Cd1A457dEa9A9A6F6406c6419B1c326670A96F"
62+
63+
// These are fallback EigenLayer deployment addresses when not specified in context (mainnet)
64+
MAINNET_ALLOCATION_MANAGER_ADDRESS = "0x948a420b8CC1d6BFd0B6087C2E7c344a2CD0bc39"
65+
MAINNET_DELEGATION_MANAGER_ADDRESS = "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A"
66+
MAINNET_STRATEGY_MANAGER_ADDRESS = "0x858646372CC42E1A627fcE94aa7A7033e7CF075A"
67+
MAINNET_KEY_REGISTRAR_ADDRESS = "0x54f4bC6bDEbe479173a2bbDc31dD7178408A57A4"
68+
MAINNET_CROSS_CHAIN_REGISTRY_ADDRESS = "0x9376A5863F2193cdE13e1aB7c678F22554E2Ea2b"
69+
MAINNET_EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
70+
MAINNET_RELEASE_MANAGER_ADDRESS = "0xeDA3CAd031c0cf367cF3f517Ee0DC98F9bA80C8F"
71+
MAINNET_L1_OPERATOR_TABLE_UPDATER_ADDRESS = "0x5557E1fE3068A1e823cE5Dcd052c6C352E2617B5"
72+
MAINNET_L1_TASK_MAILBOX_ADDRESS = "0x132b466d9d5723531F68797519DfED701aC2C749"
73+
MAINNET_PERMISSION_CONTROLLER_ADDRESS = "0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5"
74+
75+
// These are fallback EigenLayer Middleware deployment addresses when not specified in context
5576
MAINNET_BN254_TABLE_CALCULATOR_ADDRESS = "0x55F4b21681977F412B318eCB204cB933bD1dF57c"
5677
MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS = "0xA933CB4cbD0C4C208305917f56e0C3f51ad713Fa"
78+
79+
// These are L2 fallback addresses
80+
MAINNET_L2_TASK_MAILBOX_ADDRESS = "0x132b466d9d5723531F68797519DfED701aC2C749"
81+
MAINNET_L2_OPERATOR_TABLE_UPDATER_ADDRESS = "0x5557E1fE3068A1e823cE5Dcd052c6C352E2617B5"
82+
MAINNET_BN254_CERTIFICATE_VERIFIER_ADDRESS = "0x3F55654b2b2b86bB11bE2f72657f9C33bf88120A"
83+
MAINNET_ECDSA_CERTIFICATE_VERIFIER_ADDRESS = "0xd0930ee96D07de4F9d493c259232222e46B6EC25"
5784
)

pkg/common/devnet/constants.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@ const CURVE_TYPE_KEY_REGISTRAR_UNKNOWN = 0
1818
const CURVE_TYPE_KEY_REGISTRAR_ECDSA = 1
1919
const CURVE_TYPE_KEY_REGISTRAR_BN254 = 2
2020

21-
// These are fallback EigenLayer deployment addresses when not specified in context
22-
const ALLOCATION_MANAGER_ADDRESS = "0x42583067658071247ec8CE0A516A58f682002d07"
23-
const DELEGATION_MANAGER_ADDRESS = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
24-
const STRATEGY_MANAGER_ADDRESS = "0x2E3D6c0744b10eb0A4e6F679F71554a39Ec47a5D"
25-
const KEY_REGISTRAR_ADDRESS = "0x78De554Ac8DfF368e3CAa73B3Df8AccCfD92928A"
26-
const CROSS_CHAIN_REGISTRY_ADDRESS = "0xe850D8A178777b483D37fD492a476e3E6004C816"
27-
const BN254_TABLE_CALCULATOR_ADDRESS = "0xc2c0bc13571aC5115709C332dc7AE666606b08E8"
28-
const MULTICHAIN_PROXY_ADMIN = "0xC5dc0d145a21FDAD791Df8eDC7EbCB5330A3FdB5"
2921
const EIGEN_CONTRACT_ADDRESS = "0x3B78576F7D6837500bA3De27A60c7f594934027E"
30-
const RELEASE_MANAGER_ADDRESS = "0xd9Cb89F1993292dEC2F973934bC63B0f2A702776"
3122

3223
const ST_ETH_TOKEN_ADDRESS = "0x00c71b0fCadE911B2feeE9912DE4Fe19eB04ca56"
3324
const B_EIGEN_TOKEN_ADDRESS = "0x275cCf9Be51f4a6C94aBa6114cdf2a4c45B9cb27"

pkg/common/getters.go

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,22 @@ 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
35+
// Default addresses according to context to return incase of bad context
36+
ALLOCATION_MANAGER_ADDRESS := SEPOLIA_ALLOCATION_MANAGER_ADDRESS
37+
DELEGATION_MANAGER_ADDRESS := SEPOLIA_DELEGATION_MANAGER_ADDRESS
38+
STRATEGY_MANAGER_ADDRESS := SEPOLIA_STRATEGY_MANAGER_ADDRESS
39+
KEY_REGISTRAR_ADDRESS := SEPOLIA_KEY_REGISTRAR_ADDRESS
40+
CROSS_CHAIN_REGISTRY_ADDRESS := SEPOLIA_CROSS_CHAIN_REGISTRY_ADDRESS
41+
RELEASE_MANAGER_ADDRESS := SEPOLIA_RELEASE_MANAGER_ADDRESS
42+
BN254_TABLE_CALCULATOR_ADDRESS := SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS
43+
ECDSA_TABLE_CALCULATOR_ADDRESS := SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS
3844
if contextName == "mainnet" {
45+
ALLOCATION_MANAGER_ADDRESS = MAINNET_ALLOCATION_MANAGER_ADDRESS
46+
DELEGATION_MANAGER_ADDRESS = MAINNET_DELEGATION_MANAGER_ADDRESS
47+
STRATEGY_MANAGER_ADDRESS = MAINNET_STRATEGY_MANAGER_ADDRESS
48+
KEY_REGISTRAR_ADDRESS = MAINNET_KEY_REGISTRAR_ADDRESS
49+
CROSS_CHAIN_REGISTRY_ADDRESS = MAINNET_CROSS_CHAIN_REGISTRY_ADDRESS
50+
RELEASE_MANAGER_ADDRESS = MAINNET_RELEASE_MANAGER_ADDRESS
3951
BN254_TABLE_CALCULATOR_ADDRESS = MAINNET_BN254_TABLE_CALCULATOR_ADDRESS
4052
ECDSA_TABLE_CALCULATOR_ADDRESS = MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS
4153
}
@@ -51,44 +63,56 @@ func GetEigenLayerAddresses(contextName string, cfg *ConfigWithContextConfig) (a
5163
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
5264
}
5365

66+
// Switch based on contexts chainId
67+
chainId := cfg.Context[contextName].Chains["l1"].ChainID
68+
5469
// Default each address to constant if missing from discovered context
5570
allocationManager = ctx.EigenLayer.L1.AllocationManager
5671
if allocationManager == "" {
57-
allocationManager = ALLOCATION_MANAGER_ADDRESS
72+
allocationManager = GetAddressByChainId(chainId, MAINNET_ALLOCATION_MANAGER_ADDRESS, SEPOLIA_ALLOCATION_MANAGER_ADDRESS)
5873
}
5974

6075
delegationManager = ctx.EigenLayer.L1.DelegationManager
6176
if delegationManager == "" {
62-
delegationManager = DELEGATION_MANAGER_ADDRESS
77+
delegationManager = GetAddressByChainId(chainId, MAINNET_DELEGATION_MANAGER_ADDRESS, SEPOLIA_DELEGATION_MANAGER_ADDRESS)
6378
}
79+
6480
strategyManager = ctx.EigenLayer.L1.StrategyManager
6581
if strategyManager == "" {
66-
strategyManager = STRATEGY_MANAGER_ADDRESS
82+
strategyManager = GetAddressByChainId(chainId, MAINNET_STRATEGY_MANAGER_ADDRESS, SEPOLIA_STRATEGY_MANAGER_ADDRESS)
6783
}
84+
6885
keyRegistrar = ctx.EigenLayer.L1.KeyRegistrar
6986
if keyRegistrar == "" {
70-
keyRegistrar = KEY_REGISTRAR_ADDRESS
87+
keyRegistrar = GetAddressByChainId(chainId, MAINNET_KEY_REGISTRAR_ADDRESS, SEPOLIA_KEY_REGISTRAR_ADDRESS)
7188
}
7289

7390
crossChainRegistry = ctx.EigenLayer.L1.CrossChainRegistry
7491
if crossChainRegistry == "" {
75-
crossChainRegistry = CROSS_CHAIN_REGISTRY_ADDRESS
92+
crossChainRegistry = GetAddressByChainId(chainId, MAINNET_CROSS_CHAIN_REGISTRY_ADDRESS, SEPOLIA_CROSS_CHAIN_REGISTRY_ADDRESS)
7693
}
7794

7895
bn254TableCalculator = ctx.EigenLayer.L1.BN254TableCalculator
7996
if bn254TableCalculator == "" {
80-
bn254TableCalculator = BN254_TABLE_CALCULATOR_ADDRESS
97+
bn254TableCalculator = GetAddressByChainId(chainId, MAINNET_BN254_TABLE_CALCULATOR_ADDRESS, SEPOLIA_BN254_TABLE_CALCULATOR_ADDRESS)
8198
}
8299

83100
ecdsaTableCalculator = ctx.EigenLayer.L1.ECDSATableCalculator
84101
if ecdsaTableCalculator == "" {
85-
ecdsaTableCalculator = ECDSA_TABLE_CALCULATOR_ADDRESS
102+
ecdsaTableCalculator = GetAddressByChainId(chainId, MAINNET_ECDSA_TABLE_CALCULATOR_ADDRESS, SEPOLIA_ECDSA_TABLE_CALCULATOR_ADDRESS)
86103
}
87104

88105
releaseManager = ctx.EigenLayer.L1.ReleaseManager
89106
if releaseManager == "" {
90-
releaseManager = RELEASE_MANAGER_ADDRESS
107+
releaseManager = GetAddressByChainId(chainId, MAINNET_RELEASE_MANAGER_ADDRESS, SEPOLIA_RELEASE_MANAGER_ADDRESS)
91108
}
92109

93110
return allocationManager, delegationManager, strategyManager, keyRegistrar, crossChainRegistry, bn254TableCalculator, ecdsaTableCalculator, releaseManager
94111
}
112+
113+
func GetAddressByChainId(chainId int, mainnetAddress, sepoliaAddress string) string {
114+
if chainId == 1 {
115+
return mainnetAddress
116+
}
117+
return sepoliaAddress
118+
}

0 commit comments

Comments
 (0)