Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add caller address #262

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions pkg/internal/common/flags/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,11 @@ var (
Usage: "Optional delegation manager address. This can be used if you are testing against your own deployment of eigenlayer contracts",
EnvVars: []string{"DELEGATION_MANAGER_ADDRESS"},
}

CallerAddressFlag = cli.StringFlag{
Name: "caller-address",
Aliases: []string{"ca"},
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",
EnvVars: []string{"CALLER_ADDRESS"},
}
)
13 changes: 10 additions & 3 deletions pkg/operator/allocations/set_allocation_delay.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
return nil
}
eLWriter, err := common.GetELWriter(
config.operatorAddress,
config.callerAddress,
config.signerConfig,
ethClient,
elcontracts.Config{
Expand All @@ -83,7 +83,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
}
common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID)
} else {
noSendTxOpts := common.GetNoSendTxOpts(config.operatorAddress)
noSendTxOpts := common.GetNoSendTxOpts(config.callerAddress)
_, _, contractBindings, err := elcontracts.BuildClients(elcontracts.Config{
DelegationManagerAddress: config.delegationManagerAddress,
}, ethClient, nil, logger, nil)
Expand All @@ -94,7 +94,7 @@ func setDelayAction(cCtx *cli.Context, p utils.Prompter) error {
// since balance of contract can be 0, as it can be called by an EOA
// to claim. So we hardcode the gas limit to 150_000 so that we can
// create unsigned tx without gas limit estimation from contract bindings
if common.IsSmartContractAddress(config.operatorAddress, ethClient) {
if common.IsSmartContractAddress(config.callerAddress, ethClient) {
// address is a smart contract
noSendTxOpts.GasLimit = 150_000
}
Expand Down Expand Up @@ -142,6 +142,7 @@ func getSetAllocationDelayFlags() []cli.Flag {
&flags.VerboseFlag,
&flags.OperatorAddressFlag,
&flags.DelegationManagerAddressFlag,
&flags.CallerAddressFlag,
}
allFlags := append(baseFlags, flags.GetSignerFlags()...)
sort.Sort(cli.FlagsByName(allFlags))
Expand All @@ -168,6 +169,11 @@ func readAndValidateAllocationDelayConfig(c *cli.Context, logger logging.Logger)
broadcast := c.Bool(flags.BroadcastFlag.Name)
operatorAddress := c.String(flags.OperatorAddressFlag.Name)

callerAddress := c.String(flags.CallerAddressFlag.Name)
if common.IsEmptyString(callerAddress) {
shrimalmadhur marked this conversation as resolved.
Show resolved Hide resolved
callerAddress = operatorAddress
}

chainID := utils.NetworkNameToChainId(network)
logger.Debugf("Using chain ID: %s", chainID.String())

Expand Down Expand Up @@ -204,5 +210,6 @@ func readAndValidateAllocationDelayConfig(c *cli.Context, logger logging.Logger)
signerConfig: signerConfig,
delegationManagerAddress: gethcommon.HexToAddress(delegationManagerAddress),
allocationDelay: uint32(allocationDelayUint),
callerAddress: gethcommon.HexToAddress(callerAddress),
}, nil
}
3 changes: 2 additions & 1 deletion pkg/operator/allocations/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
slashableMagnitudeHolders := make(SlashableMagnitudeHolders, 0)
dergisteredOpsets := make(DeregsiteredOperatorSets, 0)
for strategy, allocations := range allAllocations {
logger.Debugf("Strategy: %s, Allocations: %v", strategy, allocations)
strategyShares := operatorDelegatedSharesMap[strategy]
for _, alloc := range allocations {
currentShares, currentSharesPercentage := getSharesFromMagnitude(
Expand Down Expand Up @@ -193,7 +194,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
}

for key, val := range operatorDelegatedSharesMap {
fmt.Printf("Strategy Address: %s, Shares %s\n", key, val.String())
fmt.Printf("Strategy Address: %s, Shares %s\n", key, common.FormatNumberWithUnderscores(val.String()))
}

currBlockNumber, err := ethClient.BlockNumber(ctx)
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/allocations/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type updateConfig struct {
avsAddress gethcommon.Address
strategyAddress gethcommon.Address
delegationManagerAddress gethcommon.Address
callerAddress gethcommon.Address
operatorSetId uint32
bipsToAllocate uint64
signerConfig *types.SignerConfig
Expand All @@ -119,6 +120,7 @@ type allocationDelayConfig struct {
signerConfig *types.SignerConfig
allocationDelay uint32
delegationManagerAddress gethcommon.Address
callerAddress gethcommon.Address
}

type showConfig struct {
Expand Down
19 changes: 13 additions & 6 deletions pkg/operator/allocations/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
}
logger.Info("Broadcasting magnitude allocation update...")
eLWriter, err := common.GetELWriter(
config.operatorAddress,
config.callerAddress,
config.signerConfig,
ethClient,
elcontracts.Config{
Expand All @@ -119,7 +119,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
}
common.PrintTransactionInfo(receipt.TxHash.String(), config.chainID)
} else {
noSendTxOpts := common.GetNoSendTxOpts(config.operatorAddress)
noSendTxOpts := common.GetNoSendTxOpts(config.callerAddress)
_, _, contractBindings, err := elcontracts.BuildClients(elcontracts.Config{
DelegationManagerAddress: config.delegationManagerAddress,
}, ethClient, nil, logger, nil)
Expand All @@ -130,7 +130,7 @@ func updateAllocations(cCtx *cli.Context, p utils.Prompter) error {
// since balance of contract can be 0, as it can be called by an EOA
// to claim. So we hardcode the gas limit to 150_000 so that we can
// create unsigned tx without gas limit estimation from contract bindings
if common.IsSmartContractAddress(config.operatorAddress, ethClient) {
if common.IsSmartContractAddress(config.callerAddress, ethClient) {
// address is a smart contract
noSendTxOpts.GasLimit = 150_000
}
Expand Down Expand Up @@ -189,6 +189,7 @@ func getUpdateFlags() []cli.Flag {
&flags.CSVFileFlag,
&flags.DelegationManagerAddressFlag,
&flags.SilentFlag,
&flags.CallerAddressFlag,
&BipsToAllocateFlag,
}
allFlags := append(baseFlags, flags.GetSignerFlags()...)
Expand Down Expand Up @@ -439,14 +440,19 @@ func readAndValidateUpdateFlags(cCtx *cli.Context, logger logging.Logger) (*upda
broadcast := cCtx.Bool(flags.BroadcastFlag.Name)
isSilent := cCtx.Bool(flags.SilentFlag.Name)

operatorAddress := gethcommon.HexToAddress(cCtx.String(flags.OperatorAddressFlag.Name))
operatorAddress := cCtx.String(flags.OperatorAddressFlag.Name)
callerAddress := cCtx.String(flags.CallerAddressFlag.Name)
if common.IsEmptyString(callerAddress) {
callerAddress = operatorAddress
}

avsAddress := gethcommon.HexToAddress(cCtx.String(flags.AVSAddressFlag.Name))
strategyAddress := gethcommon.HexToAddress(cCtx.String(flags.StrategyAddressFlag.Name))
operatorSetId := uint32(cCtx.Uint64(flags.OperatorSetIdFlag.Name))
bipsToAllocate := cCtx.Uint64(BipsToAllocateFlag.Name)
logger.Debugf(
"Operator address: %s, AVS address: %s, Strategy address: %s, Bips to allocate: %d",
operatorAddress.Hex(),
operatorAddress,
avsAddress.Hex(),
strategyAddress.Hex(),
bipsToAllocate,
Expand Down Expand Up @@ -478,7 +484,8 @@ func readAndValidateUpdateFlags(cCtx *cli.Context, logger logging.Logger) (*upda
output: output,
outputType: outputType,
broadcast: broadcast,
operatorAddress: operatorAddress,
operatorAddress: gethcommon.HexToAddress(operatorAddress),
callerAddress: gethcommon.HexToAddress(callerAddress),
avsAddress: avsAddress,
strategyAddress: strategyAddress,
bipsToAllocate: bipsToAllocate,
Expand Down
Loading