Fixes altered accounts - #7956
Conversation
There was a problem hiding this comment.
Pull request overview
Improves altered-accounts detection in the outport pipeline by ensuring newly deployed smart contract addresses are marked as altered based on SCDeploy log events, not just transaction sender/receiver analysis.
Changes:
- Scan transaction logs for
SCDeployevents and mark the deployed contract address as balance-changed. - Add unit tests covering log-based extraction behavior (including missing topics and invalid addresses).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| outport/process/alteredaccounts/alteredAccountsProvider.go | Adds log scanning for SCDeploy events to detect newly deployed smart contracts as altered accounts. |
| outport/process/alteredaccounts/alteredAccountsProvider_test.go | Adds tests for extractAddressesFromLogs covering core success/skip cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func (aap *alteredAccountsProvider) extractAddressesFromLogs( | ||
| logs []*transaction.LogData, | ||
| markedAlteredAccounts map[string]*markedAlteredAccount) { | ||
| for _, logEvent := range logs { | ||
| if logEvent.Log == nil { | ||
| continue | ||
| } | ||
| for _, event := range logEvent.Log.Events { | ||
| if string(event.Identifier) != core.SCDeployIdentifier { | ||
| continue | ||
| } | ||
| if len(event.Topics) < 1 { | ||
| continue | ||
| } | ||
|
|
||
| scAddress := event.Topics[0] | ||
| aap.addAddressWithBalanceChangeInMap(scAddress, markedAlteredAccounts, false) | ||
| } | ||
| } | ||
| } |
…es-altered-accounts
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/recon-by-meta #7956 +/- ##
===================================================
Coverage 77.71% 77.71%
===================================================
Files 892 892
Lines 129025 129043 +18
===================================================
+ Hits 100267 100281 +14
- Misses 22209 22211 +2
- Partials 6549 6551 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| continue | ||
| } | ||
|
|
||
| scAddress := event.Topics[0] |
There was a problem hiding this comment.
A WASM contract can expose an endpoint named SCDeploy, this name is not reserved and writeLog uses the current endpoint name as the event identifier while allowing the contract to choose the topics. Such a contract can therefore place any same-length account in Topics[0], causing that unrelated account to be marked and exported as balance-changed. Protocol-generated deployment events set event.Address equal to Topics[0]; reject events where these differ and reject addresses outside the current shard before adding them.
Reasoning behind the pull request
SCDeployevents and marks the deployed contract address (first topic) as altered with balance change. Previously, newly deployed SCs were missed since they don't appear in tx senders/receivers.Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?