Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions analyzer/runtime/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.Runtime
// Mark sender and contract accounts as having potentially stale balances.
// EVMCreate can transfer funds from the sender to the contract.
if to != "" {
registerTokenIncrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, to, big.NewInt(0))
registerTokenIncrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, to, big.NewInt(0)) // XXX: But don't transfer events handle this?
}
for _, signer := range blockTransactionData.SignerData {
registerTokenDecrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, signer.Address, big.NewInt(0))
Expand Down Expand Up @@ -560,7 +560,6 @@ func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.Runtime
for _, signer := range blockTransactionData.SignerData {
registerTokenDecrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, signer.Address, reckonedAmount)
}

}

// Subcall precompile.
Expand Down Expand Up @@ -1513,8 +1512,8 @@ func extractEvents(blockData *BlockData, eventsRaw []nodeapi.RuntimeEvent) ([]*E
}
eventData.RelatedAddresses[ownerAddr] = struct{}{}
registerTokenIncrease(blockData.TokenBalanceChanges, wrapperAddr, ownerAddr, amount)
registerTokenIncrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, wrapperAddr, amount)
registerTokenDecrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, ownerAddr, amount)
registerTokenIncrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, wrapperAddr, amount) // TODO: but transfer event handles this?
registerTokenDecrease(blockData.TokenBalanceChanges, evm.NativeRuntimeTokenAddress, ownerAddr, amount) // TODO: but transfer event handles this?

// ^ The above includes dead-reckoning for the native token because no events are emitted for native token transfers.
//
Expand Down
3 changes: 2 additions & 1 deletion analyzer/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@
for key, change := range data.TokenBalanceChanges {
// Update (dead-reckon) the DB balance only if it's actually changed.
if change != big.NewInt(0) && m.mode != analyzer.FastSyncMode {
if key.TokenAddress == evm.NativeRuntimeTokenAddress {

Check failure on line 557 in analyzer/runtime/runtime.go

View workflow job for this annotation

GitHub Actions / lint-go

empty-block: this block is empty, you can remove it (revive)
batch.Queue(queries.RuntimeNativeBalanceUpsert, m.runtime, key.AccountAddress, nativeTokenSymbol(m.sdkPT), change.String())
// For native balance updates, just mark the balance as dirty. The actual balance update should be handled by the accounts.Transfer event.
// batch.Queue(queries.RuntimeNativeBalanceUpsert, m.runtime, key.AccountAddress, nativeTokenSymbol(m.sdkPT), change.String())
} else {
batch.Queue(queries.RuntimeEVMTokenBalanceUpdate, m.runtime, key.TokenAddress, key.AccountAddress, change.String())
}
Expand Down
Loading