Skip to content

[BCN] Fix ERC-20 effect materialization - #4209

Open
msalcala11 wants to merge 1 commit into
bitpay:masterfrom
msalcala11:fix-erc20-txs
Open

[BCN] Fix ERC-20 effect materialization#4209
msalcala11 wants to merge 1 commit into
bitpay:masterfrom
msalcala11:fix-erc20-txs

Conversation

@msalcala11

Copy link
Copy Markdown
Contributor

Description

Before this fix, Bitcore tried to identify ERC-20 transfers by decoding transaction input and traced contract calls. That approach describes what a contract was asked to do, but not always what actually happened on-chain. It could miss transfers made through proxies or custom contract methods, include calls that did not produce a transfer, or report the wrong sender, recipient, or token.

This fix uses the ERC-20 Transfer events produced by confirmed blocks as the source of truth. It validates each event against the block and transaction, stores the result with the transaction, and uses it for transaction history, wallet matching, and balance cache updates.

This is needed to make ERC-20 transaction data accurate and consistent while safely updating existing records.

Changelog

  • Read and validate ERC-20 Transfer events while processing EVM blocks.
  • Store versioned ERC-20 transfer results with each confirmed transaction.
  • Use the stored transfers in APIs, address history, wallet matching, and balance cache updates.
  • Keep existing non-ERC-20 effects unchanged.
  • Add settings for a controlled rollout and protection for newer stored versions.
  • Add a dry-run backfill tool for existing transactions.
  • Add rollout documentation, database indexes, and test coverage.

Testing Notes

From packages/bitcore-node, run:

  • npm run test:unit
  • npm run test:integration

For manual testing, run the backfill tool with --dry-run against a small known block range. Confirm that it finds the expected transfers without writing changes, then check transaction history for the sender and recipient addresses.


Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant