Skip to content

Commit cbd9132

Browse files
fix: add caller address (#262)
1 parent 181176f commit cbd9132

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

pkg/internal/common/flags/general.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,11 @@ var (
125125
Usage: "Optional delegation manager address. This can be used if you are testing against your own deployment of eigenlayer contracts",
126126
EnvVars: []string{"DELEGATION_MANAGER_ADDRESS"},
127127
}
128+
129+
CallerAddressFlag = cli.StringFlag{
130+
Name: "caller-address",
131+
Aliases: []string{"ca"},
132+
Usage: "This is the address of the caller who is calling the contract function. If it is not provided, the operator address will be used as the caller address",
133+
EnvVars: []string{"CALLER_ADDRESS"},
134+
}
128135
)

pkg/operator/allocations/set_allocation_delay.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
6262
return nil
6363
}
6464
eLWriter, err := common.GetELWriter(
65-
config.operatorAddress,
65+
config.callerAddress,
6666
config.signerConfig,
6767
ethClient,
6868
elcontracts.Config{
@@ -83,7 +83,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
8383
}
8484
common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID)
8585
} else {
86-
noSendTxOpts := common.GetNoSendTxOpts(config.operatorAddress)
86+
noSendTxOpts := common.GetNoSendTxOpts(config.callerAddress)
8787
_, _, contractBindings, err := elcontracts.BuildClients(elcontracts.Config{
8888
DelegationManagerAddress: config.delegationManagerAddress,
8989
}, ethClient, nil, logger, nil)
@@ -94,7 +94,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
9494
// since balance of contract can be 0, as it can be called by an EOA
9595
// to claim. So we hardcode the gas limit to 150_000 so that we can
9696
// create unsigned tx without gas limit estimation from contract bindings
97-
if common.IsSmartContractAddress(config.operatorAddress, ethClient) {
97+
if common.IsSmartContractAddress(config.callerAddress, ethClient) {
9898
// address is a smart contract
9999
noSendTxOpts.GasLimit = 150_000
100100
}
@@ -142,6 +142,7 @@ func getSetAllocationDelayFlags() []cli.Flag {
142142
&flags.VerboseFlag,
143143
&flags.OperatorAddressFlag,
144144
&flags.DelegationManagerAddressFlag,
145+
&flags.CallerAddressFlag,
145146
}
146147
allFlags := append(baseFlags, flags.GetSignerFlags()...)
147148
sort.Sort(cli.FlagsByName(allFlags))
@@ -168,6 +169,12 @@ func readAndValidateAllocationDelayConfig(c *cli.Context, logger logging.Logger)
168169
broadcast := c.Bool(flags.BroadcastFlag.Name)
169170
operatorAddress := c.String(flags.OperatorAddressFlag.Name)
170171

172+
callerAddress := c.String(flags.CallerAddressFlag.Name)
173+
if common.IsEmptyString(callerAddress) {
174+
logger.Infof("Caller address not provided. Using operator address (%s) as caller address", operatorAddress)
175+
callerAddress = operatorAddress
176+
}
177+
171178
chainID := utils.NetworkNameToChainId(network)
172179
logger.Debugf("Using chain ID: %s", chainID.String())
173180

@@ -204,5 +211,6 @@ func readAndValidateAllocationDelayConfig(c *cli.Context, logger logging.Logger)
204211
signerConfig: signerConfig,
205212
delegationManagerAddress: gethcommon.HexToAddress(delegationManagerAddress),
206213
allocationDelay: uint32(allocationDelayUint),
214+
callerAddress: gethcommon.HexToAddress(callerAddress),
207215
}, nil
208216
}

pkg/operator/allocations/show.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
150150
slashableMagnitudeHolders := make(SlashableMagnitudeHolders, 0)
151151
dergisteredOpsets := make(DeregsiteredOperatorSets, 0)
152152
for strategy, allocations := range allAllocations {
153+
logger.Debugf("Strategy: %s, Allocations: %v", strategy, allocations)
153154
strategyShares := operatorDelegatedSharesMap[strategy]
154155
for _, alloc := range allocations {
155156
currentShares, currentSharesPercentage := getSharesFromMagnitude(
@@ -193,7 +194,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
193194
}
194195

195196
for key, val := range operatorDelegatedSharesMap {
196-
fmt.Printf("Strategy Address: %s, Shares %s\n", key, val.String())
197+
fmt.Printf("Strategy Address: %s, Shares %s\n", key, common.FormatNumberWithUnderscores(val.String()))
197198
}
198199

199200
currBlockNumber, err := ethClient.BlockNumber(ctx)

pkg/operator/allocations/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type updateConfig struct {
9393
avsAddress gethcommon.Address
9494
strategyAddress gethcommon.Address
9595
delegationManagerAddress gethcommon.Address
96+
callerAddress gethcommon.Address
9697
operatorSetId uint32
9798
bipsToAllocate uint64
9899
signerConfig *types.SignerConfig
@@ -119,6 +120,7 @@ type allocationDelayConfig struct {
119120
signerConfig *types.SignerConfig
120121
allocationDelay uint32
121122
delegationManagerAddress gethcommon.Address
123+
callerAddress gethcommon.Address
122124
}
123125

124126
type showConfig struct {

pkg/operator/allocations/update.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
9494
}
9595
logger.Info("Broadcasting magnitude allocation update...")
9696
eLWriter, err := common.GetELWriter(
97-
config.operatorAddress,
97+
config.callerAddress,
9898
config.signerConfig,
9999
ethClient,
100100
elcontracts.Config{
@@ -119,7 +119,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
119119
}
120120
common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID)
121121
} else {
122-
noSendTxOpts := common.GetNoSendTxOpts(config.operatorAddress)
122+
noSendTxOpts := common.GetNoSendTxOpts(config.callerAddress)
123123
_, _, contractBindings, err := elcontracts.BuildClients(elcontracts.Config{
124124
DelegationManagerAddress: config.delegationManagerAddress,
125125
}, ethClient, nil, logger, nil)
@@ -130,7 +130,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
130130
// since balance of contract can be 0, as it can be called by an EOA
131131
// to claim. So we hardcode the gas limit to 150_000 so that we can
132132
// create unsigned tx without gas limit estimation from contract bindings
133-
if common.IsSmartContractAddress(config.operatorAddress, ethClient) {
133+
if common.IsSmartContractAddress(config.callerAddress, ethClient) {
134134
// address is a smart contract
135135
noSendTxOpts.GasLimit = 150_000
136136
}
@@ -189,6 +189,7 @@ func getUpdateFlags() []cli.Flag {
189189
&flags.CSVFileFlag,
190190
&flags.DelegationManagerAddressFlag,
191191
&flags.SilentFlag,
192+
&flags.CallerAddressFlag,
192193
&BipsToAllocateFlag,
193194
}
194195
allFlags := append(baseFlags, flags.GetSignerFlags()...)
@@ -439,14 +440,20 @@ func readAndValidateUpdateFlags(cCtx *cli.Context, logger logging.Logger) (*upda
439440
broadcast := cCtx.Bool(flags.BroadcastFlag.Name)
440441
isSilent := cCtx.Bool(flags.SilentFlag.Name)
441442

442-
operatorAddress := gethcommon.HexToAddress(cCtx.String(flags.OperatorAddressFlag.Name))
443+
operatorAddress := cCtx.String(flags.OperatorAddressFlag.Name)
444+
callerAddress := cCtx.String(flags.CallerAddressFlag.Name)
445+
if common.IsEmptyString(callerAddress) {
446+
logger.Infof("Caller address not provided. Using operator address (%s) as caller address", operatorAddress)
447+
callerAddress = operatorAddress
448+
}
449+
443450
avsAddress := gethcommon.HexToAddress(cCtx.String(flags.AVSAddressFlag.Name))
444451
strategyAddress := gethcommon.HexToAddress(cCtx.String(flags.StrategyAddressFlag.Name))
445452
operatorSetId := uint32(cCtx.Uint64(flags.OperatorSetIdFlag.Name))
446453
bipsToAllocate := cCtx.Uint64(BipsToAllocateFlag.Name)
447454
logger.Debugf(
448455
"Operator address: %s, AVS address: %s, Strategy address: %s, Bips to allocate: %d",
449-
operatorAddress.Hex(),
456+
operatorAddress,
450457
avsAddress.Hex(),
451458
strategyAddress.Hex(),
452459
bipsToAllocate,
@@ -478,7 +485,8 @@ func readAndValidateUpdateFlags(cCtx *cli.Context, logger logging.Logger) (*upda
478485
output: output,
479486
outputType: outputType,
480487
broadcast: broadcast,
481-
operatorAddress: operatorAddress,
488+
operatorAddress: gethcommon.HexToAddress(operatorAddress),
489+
callerAddress: gethcommon.HexToAddress(callerAddress),
482490
avsAddress: avsAddress,
483491
strategyAddress: strategyAddress,
484492
bipsToAllocate: bipsToAllocate,

0 commit comments

Comments
 (0)