Skip to content

Commit 04a0235

Browse files
Address copilot comments
1 parent 2861200 commit 04a0235

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

x/action/v1/keeper/action.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,21 @@ func (k *Keeper) FinalizeAction(ctx sdk.Context, actionID string, superNodeAccou
181181
// Verify reporting superNode -
182182
// it must be in the top-10 supernodes for the (existing) action's block height
183183
// and not already in the (existing) action's SuperNodes list
184-
eligible, rejectReason, expectedFinalizerAddresses, err := k.checkFinalizerEligibility(ctx, existingAction, superNodeAccount)
184+
eligible, rejectReason, top10ValidatorAddresses, err := k.checkFinalizerEligibility(ctx, existingAction, superNodeAccount)
185185
if err != nil {
186186
return err
187187
}
188188
if !eligible {
189189
// Only Cascade finalization is in scope for evidence-based rejections at the moment.
190190
if existingAction.ActionType == actiontypes.ActionTypeCascade {
191-
k.RecordFinalizationNotInTop10(ctx, existingAction, superNodeAccount, expectedFinalizerAddresses, rejectReason)
191+
k.RecordFinalizationNotInTop10(ctx, existingAction, superNodeAccount, top10ValidatorAddresses, rejectReason)
192192
return nil
193193
}
194194
return errors.Wrap(actiontypes.ErrUnauthorizedSN, rejectReason)
195195
}
196196

197197
// Make the top-10 validator addresses available for downstream handler logic (e.g. signature failure evidence metadata).
198-
ctx = ctx.WithValue(ctxKeyTop10ValidatorAddresses{}, expectedFinalizerAddresses)
198+
ctx = ctx.WithValue(ctxKeyTop10ValidatorAddresses{}, top10ValidatorAddresses)
199199

200200
// Get the appropriate handler for this action type
201201
handler, err := k.actionRegistry.GetHandler(existingAction.ActionType)
@@ -533,8 +533,8 @@ func (k *Keeper) IterateActionsByState(ctx sdk.Context, state actiontypes.Action
533533
// checkFinalizerEligibility checks whether a supernode is authorized to finalize an action.
534534
//
535535
// It returns:
536-
// - (true, "", expectedFinalizers, nil) when eligible
537-
// - (false, reason, expectedFinalizers, nil) when rejected (non-fatal)
536+
// - (true, "", top10ValidatorAddresses, nil) when eligible
537+
// - (false, reason, top10ValidatorAddresses, nil) when rejected (non-fatal)
538538
// - (false, "", nil, err) for hard failures (e.g. duplicates)
539539
func (k *Keeper) checkFinalizerEligibility(ctx sdk.Context, action *actiontypes.Action, superNodeAccount string) (bool, string, []string, error) {
540540
// If SuperNode already in the list, return an error

x/action/v1/keeper/audit_evidence.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ func (k *Keeper) recordFinalizationEvidence(
2828
ctx sdk.Context,
2929
actionID string,
3030
subjectAddress string,
31-
attemptedFinalizerAddress string,
32-
expectedFinalizerAddresses []string,
33-
reason string,
31+
top10ValidatorAddresses []string,
3432
evidenceType audittypes.EvidenceType,
3533
) (uint64, error) {
3634
if k.auditKeeper == nil {
@@ -49,15 +47,15 @@ func (k *Keeper) recordFinalizationEvidence(
4947
switch evidenceType {
5048
case audittypes.EvidenceType_EVIDENCE_TYPE_ACTION_FINALIZATION_SIGNATURE_FAILURE:
5149
metaJSON, err := json.Marshal(audittypes.ActionFinalizationSignatureFailureEvidenceMetadata{
52-
Top_10ValidatorAddresses: expectedFinalizerAddresses,
50+
Top_10ValidatorAddresses: top10ValidatorAddresses,
5351
})
5452
if err != nil {
5553
return 0, fmt.Errorf("marshal evidence metadata: %w", err)
5654
}
5755
metadataJSON = string(metaJSON)
5856
case audittypes.EvidenceType_EVIDENCE_TYPE_ACTION_FINALIZATION_NOT_IN_TOP_10:
5957
metaJSON, err := json.Marshal(audittypes.ActionFinalizationNotInTop10EvidenceMetadata{
60-
Top_10ValidatorAddresses: expectedFinalizerAddresses,
58+
Top_10ValidatorAddresses: top10ValidatorAddresses,
6159
})
6260
if err != nil {
6361
return 0, fmt.Errorf("marshal evidence metadata: %w", err)
@@ -82,7 +80,7 @@ func (k *Keeper) recordFinalizationRejection(
8280
action *actiontypes.Action,
8381
attemptedFinalizerAddress string,
8482
reason string,
85-
expectedFinalizerAddresses []string,
83+
top10ValidatorAddresses []string,
8684
evidenceType audittypes.EvidenceType,
8785
) uint64 {
8886
if action == nil {
@@ -97,9 +95,7 @@ func (k *Keeper) recordFinalizationRejection(
9795
ctx,
9896
action.ActionID,
9997
subjectAddress,
100-
attemptedFinalizerAddress,
101-
expectedFinalizerAddresses,
102-
reason,
98+
top10ValidatorAddresses,
10399
evidenceType,
104100
); err != nil {
105101
k.Logger().Error(
@@ -151,15 +147,15 @@ func (k *Keeper) RecordFinalizationNotInTop10(
151147
ctx sdk.Context,
152148
action *actiontypes.Action,
153149
attemptedFinalizerAddress string,
154-
expectedFinalizerAddresses []string,
150+
top10ValidatorAddresses []string,
155151
reason string,
156152
) uint64 {
157153
return k.recordFinalizationRejection(
158154
ctx,
159155
action,
160156
attemptedFinalizerAddress,
161157
reason,
162-
expectedFinalizerAddresses,
158+
top10ValidatorAddresses,
163159
audittypes.EvidenceType_EVIDENCE_TYPE_ACTION_FINALIZATION_NOT_IN_TOP_10,
164160
)
165161
}

0 commit comments

Comments
 (0)