Skip to content

Commit

Permalink
Revert "EXPERIMENT: Re-query ERC-20 balance of user for every interac…
Browse files Browse the repository at this point in the history
…tion with contract"

This reverts commit 3ead7da2d7741ffa4582ac831bf0739ec09fc517.
  • Loading branch information
mitjat committed Dec 7, 2023
1 parent 913b3a9 commit 49c10d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 2 additions & 9 deletions analyzer/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,8 @@ var (
RuntimeEVMTokenBalanceAnalysisMutateRoundUpsert = `
INSERT INTO analysis.evm_token_balances
(runtime, token_address, account_address, last_mutate_round)
(
SELECT $1, $2, $3, $4
-- Insert the row only if $2 is a valid token. The runtime analyzer enqueues for balance re-querying
-- every (contract, account) pair that interacts, regardless of whether the contract is a token,
-- because the analyzer doesn't have access to that info.
WHERE EXISTS (SELECT 1 FROM chain.evm_tokens WHERE runtime = $1::runtime AND token_address = $2::oasis_addr)
)
VALUES
($1, $2, $3, $4)
ON CONFLICT (runtime, token_address, account_address) DO UPDATE
SET
last_mutate_round = excluded.last_mutate_round`
Expand All @@ -583,8 +578,6 @@ var (
SELECT runtime, token_address, account_address, MAX(last_mutate_round)
FROM todo_updates.evm_token_balances
WHERE runtime = $1
-- TODO: Filter out rows where "token_address" is not a token?
-- But we don't know yet which contracts are tokens since fast-sync just concluded.
GROUP BY runtime, token_address, account_address
)
ON CONFLICT (runtime, token_address, account_address) DO UPDATE
Expand Down
2 changes: 0 additions & 2 deletions analyzer/runtime/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.Runtime
registerTokenIncrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, to, reckonedAmount)
for _, signer := range blockTransactionData.SignerData {
registerTokenDecrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, signer.Address, reckonedAmount)
// In case the contract is an ERC-20, the sender's ERC-20 balance might change as a result of the call. Schedule for re-querying.
registerTokenDecrease(blockData.TokenBalanceChanges, to, signer.Address, big.NewInt(0))
}
}

Expand Down

0 comments on commit 49c10d2

Please sign in to comment.