Skip to content

Commit 24f0a1c

Browse files
committed
fix: address Claude code review feedback on PR #519
- Handle iterationFailCount > 0 with firstError == nil (fallback message) - Add nil guard for vm.smartWalletConfig on ERC20 injection path - Demote debug/trace logs from Info to Debug level - Add comment explaining slot 51 (Compound cToken contracts)
1 parent 164ed4b commit 24f0a1c

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

core/taskengine/engine.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ func (n *Engine) SimulateTask(user *model.User, trigger *avsproto.TaskTrigger, n
29892989
if shouldContinue {
29902990
// Inject simulated state overrides so downstream Tenderly simulations see
29912991
// the balance changes implied by the trigger event.
2992-
n.logger.Info("SimulateTask: state override check",
2992+
n.logger.Debug("SimulateTask: state override check",
29932993
"triggerType", triggerType,
29942994
"isEventTrigger", triggerType == avsproto.TriggerType_TRIGGER_TYPE_EVENT,
29952995
"simulationStateNil", vm.simulationState == nil)
@@ -3082,9 +3082,8 @@ func (n *Engine) injectEventTriggerStateOverrides(triggerOutput map[string]inter
30823082
return
30833083
}
30843084

3085-
n.logger.Info("injectEventTriggerStateOverrides: called",
3086-
"triggerOutputKeys", GetMapKeys(triggerOutput),
3087-
"simulationStateEmpty", vm.simulationState.IsEmpty())
3085+
n.logger.Debug("injectEventTriggerStateOverrides: called",
3086+
"triggerOutputKeys", GetMapKeys(triggerOutput))
30883087

30893088
// Only process if there is parsed event data
30903089
rawData := triggerOutput["data"]
@@ -3100,7 +3099,7 @@ func (n *Engine) injectEventTriggerStateOverrides(triggerOutput map[string]inter
31003099
}
31013100

31023101
eventName, _ := data["eventName"].(string)
3103-
n.logger.Info("injectEventTriggerStateOverrides: resolved eventName",
3102+
n.logger.Debug("injectEventTriggerStateOverrides: resolved eventName",
31043103
"eventName", eventName,
31053104
"dataKeys", GetMapKeys(data))
31063105

@@ -3166,6 +3165,11 @@ func (n *Engine) injectTransferEventState(data map[string]interface{}, vm *VM) {
31663165
}
31673166

31683167
// ERC20 transfer
3168+
if vm.smartWalletConfig == nil || vm.smartWalletConfig.EthRpcUrl == "" {
3169+
n.logger.Warn("No smart wallet config for ERC20 balance injection, skipping")
3170+
return
3171+
}
3172+
31693173
holderAddress := common.HexToAddress(walletAddr)
31703174
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
31713175
defer cancel()

core/taskengine/simulation_state.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ func erc20BalanceSlot(holder common.Address, mappingSlot int64) common.Hash {
154154
}
155155

156156
// Common ERC20 balance mapping slot indices across different implementations.
157+
// 0: standard OpenZeppelin ERC20, 1-3: various token implementations,
158+
// 9: USDC (FiatTokenV2 proxy), 51: Compound cToken-style contracts.
157159
var commonBalanceSlots = []int64{0, 1, 2, 3, 9, 51}
158160

159161
// ProbeERC20BalanceSlot discovers which storage slot a token contract uses for

core/taskengine/vm.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4904,14 +4904,19 @@ func (v *VM) executeLoopWithQueue(stepID string, taskNode *avsproto.TaskNode, no
49044904
}
49054905
}
49064906

4907-
if iterationFailCount > 0 && firstError != nil {
4907+
if iterationFailCount > 0 {
49084908
// Some or all iterations failed — mark the loop step as failed so
49094909
// AnalyzeExecutionResult can detect partial_success at the execution level.
49104910
// Pass the error via the `err` parameter (not `errorMessage`) so that
49114911
// finalizeStep uses err.Error() directly without wrapping it in
49124912
// NewInvalidRequestError which adds an "invalid request: " prefix.
4913-
innerMsg := strings.TrimPrefix(firstError.Error(), "invalid request: ")
4914-
errorMsg := fmt.Sprintf("%d of %d iterations failed: %s", iterationFailCount, len(results), innerMsg)
4913+
var errorMsg string
4914+
if firstError != nil {
4915+
innerMsg := strings.TrimPrefix(firstError.Error(), "invalid request: ")
4916+
errorMsg = fmt.Sprintf("%d of %d iterations failed: %s", iterationFailCount, len(results), innerMsg)
4917+
} else {
4918+
errorMsg = fmt.Sprintf("%d of %d iterations failed", iterationFailCount, len(results))
4919+
}
49154920
loopErr := NewStructuredError(
49164921
avsproto.ErrorCode_INVALID_REQUEST,
49174922
errorMsg,

0 commit comments

Comments
 (0)