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

feat: Rewards v2 batch claiming support #241

Merged
merged 25 commits into from
Dec 3, 2024
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9d65637
feat: Rewards v2 batch claiming support
gpabst Nov 13, 2024
dbe1299
fix: update parameter name to batch-claim-file
gpabst Nov 15, 2024
abd0903
fix: remove duplicated code now that its not a separate command
gpabst Nov 15, 2024
d31dcfb
fix: remove dupe error check
gpabst Nov 15, 2024
f412523
fix: context should always be first argument
gpabst Nov 15, 2024
4f87cf8
fix: more descriptive name for claim helper
gpabst Nov 15, 2024
fe217d6
fix: include earner address in claim proof logs
gpabst Nov 15, 2024
ed9e526
chore: use updated eigensdk
gpabst Nov 25, 2024
74bcf53
chore: go fmt
gpabst Nov 25, 2024
ab89bb0
feat: claim all claimable tokens if token addresses is empty
gpabst Nov 25, 2024
c244b30
refactor: create broadcastClaims
gpabst Nov 27, 2024
5bda722
refactor: calculate rootIndex and proofData once
gpabst Nov 27, 2024
5d524f0
fix: move append after error check
gpabst Nov 27, 2024
acc0c8a
fix: make this log a warning
gpabst Nov 27, 2024
fce57b5
fix: pass in logger and context
gpabst Nov 27, 2024
bcbbc9e
fix: add newline
gpabst Nov 27, 2024
c5ec192
feat: initial support for outputing batch claim data
gpabst Nov 27, 2024
53ed596
fix: len > 1 not 0
gpabst Dec 3, 2024
2c2a3bf
chore: reduce dereferences
gpabst Dec 3, 2024
50fa8c3
chore: make BatchClaim private
gpabst Dec 3, 2024
2bb9f59
refactor: remove unused params
gpabst Dec 3, 2024
4b39263
fix: newline
gpabst Dec 3, 2024
39e47b8
fix: remove error log
gpabst Dec 3, 2024
4d4c8fe
fix: len > 1
gpabst Dec 3, 2024
8d85fed
fix: handle case with 0 claims
gpabst Dec 3, 2024
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
35 changes: 17 additions & 18 deletions pkg/rewards/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ func BatchClaim(

}

err = broadcastClaims(config, ethClient, logger, p, ctx, &elClaims, &claims, &accounts)
return err
return broadcastClaims(config, ethClient, logger, p, ctx, elClaims, claims, accounts)
}

func generateClaimPayload(
Expand Down Expand Up @@ -278,9 +277,9 @@ func Claim(cCtx *cli.Context, p utils.Prompter) error {
return err
}

elClaims := &[]rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim{*elClaim}
claims := &[]contractrewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim{*claim}
accounts := &[]merkletree.MerkleTree{*account}
elClaims := []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim{*elClaim}
claims := []contractrewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim{*claim}
accounts := []merkletree.MerkleTree{*account}
err = broadcastClaims(config, ethClient, logger, p, ctx, elClaims, claims, accounts)

return err
Expand All @@ -291,9 +290,9 @@ func broadcastClaims(config *ClaimConfig,
logger logging.Logger,
p utils.Prompter,
ctx context.Context,
elClaims *[]rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
claims *[]contractrewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
accounts *[]merkletree.MerkleTree,
elClaims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
claims []contractrewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
accounts []merkletree.MerkleTree,
) error {
if config.Broadcast {
eLWriter, err := common.GetELWriter(
Expand All @@ -316,10 +315,10 @@ func broadcastClaims(config *ClaimConfig,

var receipt *types.Receipt

if len(*elClaims) > 0 {
receipt, err = eLWriter.ProcessClaims(ctx, *elClaims, config.RecipientAddress, true)
if len(elClaims) > 1 {
gpabst marked this conversation as resolved.
Show resolved Hide resolved
receipt, err = eLWriter.ProcessClaims(ctx, elClaims, config.RecipientAddress, true)
} else {
receipt, err = eLWriter.ProcessClaim(ctx, (*elClaims)[0], config.RecipientAddress, true)
receipt, err = eLWriter.ProcessClaim(ctx, elClaims[0], config.RecipientAddress, true)
}

if err != nil {
Expand Down Expand Up @@ -350,10 +349,10 @@ func broadcastClaims(config *ClaimConfig,
noSendTxOpts.GasLimit = 150_000
}
var unsignedTx *types.Transaction
if len(*elClaims) > 0 {
unsignedTx, err = contractBindings.RewardsCoordinator.ProcessClaims(noSendTxOpts, *elClaims, config.RecipientAddress)
if len(elClaims) > 0 {
unsignedTx, err = contractBindings.RewardsCoordinator.ProcessClaims(noSendTxOpts, elClaims, config.RecipientAddress)
} else {
unsignedTx, err = contractBindings.RewardsCoordinator.ProcessClaim(noSendTxOpts, (*elClaims)[0], config.RecipientAddress)
unsignedTx, err = contractBindings.RewardsCoordinator.ProcessClaim(noSendTxOpts, elClaims[0], config.RecipientAddress)
}
if err != nil {
return eigenSdkUtils.WrapError("failed to create unsigned tx", err)
Expand All @@ -372,8 +371,8 @@ func broadcastClaims(config *ClaimConfig,
fmt.Println(calldataHex)
}
} else if config.OutputType == string(common.OutputType_Json) {
for idx, claim := range *claims {
solidityClaim := claimgen.FormatProofForSolidity((*accounts)[idx].Root(), &claim)
for idx, claim := range claims {
solidityClaim := claimgen.FormatProofForSolidity(accounts[idx].Root(), &claim)
jsonData, err := json.MarshalIndent(solidityClaim, "", " ")
if err != nil {
logger.Error("Error marshaling JSON:", err)
gpabst marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -396,8 +395,8 @@ func broadcastClaims(config *ClaimConfig,
fmt.Println("output file not supported for pretty output type")
fmt.Println()
}
for idx, claim := range *claims {
solidityClaim := claimgen.FormatProofForSolidity((*accounts)[idx].Root(), &claim)
for idx, claim := range claims {
solidityClaim := claimgen.FormatProofForSolidity(accounts[idx].Root(), &claim)
if !config.IsSilent {
fmt.Println("------- Claim generated -------")
}
Expand Down
Loading