-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: index celo transactions #9713
base: master
Are you sure you want to change the base?
Conversation
@@ -614,6 +607,39 @@ defmodule Indexer.Block.FetcherTest do | |||
assert fifth_address.fetched_coin_balance_block_number == block_number | |||
|
|||
EthereumJSONRPC.Nethermind -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, the tests in this file just ignore the EthereumJSONRPC variant.
In my case, this config sets the variant geth
:
blockscout/apps/indexer/config/runtime/test.exs
Lines 1 to 11 in 509b897
import Config | |
alias EthereumJSONRPC.Variant | |
config :indexer, Indexer.Fetcher.Beacon.Blob.Supervisor, disabled?: true | |
config :indexer, Indexer.Fetcher.Beacon.Blob, start_block: 0 | |
variant = Variant.get() | |
Code.require_file("#{variant}.exs", "#{__DIR__}/../../../explorer/config/test") | |
Code.require_file("#{variant}.exs", "#{__DIR__}/../../../indexer/config/test") |
So, it loads this config, setting EthereumJSONRPC.Geth
variant:
blockscout/apps/indexer/config/test/geth.exs
Lines 1 to 8 in 509b897
import Config | |
config :indexer, | |
json_rpc_named_arguments: [ | |
transport: EthereumJSONRPC.Mox, | |
transport_options: [], | |
variant: EthereumJSONRPC.Geth | |
] |
blockscout/apps/explorer/config/test/geth.exs
Lines 1 to 13 in 509b897
import Config | |
config :explorer, | |
json_rpc_named_arguments: [ | |
transport: EthereumJSONRPC.Mox, | |
transport_options: [], | |
variant: EthereumJSONRPC.Geth | |
], | |
subscribe_named_arguments: [ | |
transport: EthereumJSONRPC.Mox, | |
transport_options: [], | |
variant: EthereumJSONRPC.Geth | |
] |
However, these json_rpc_named_arguments
settings are just ignored in the tests. Why it could be so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this, I had nothing to do, but put my celo-changes to EthereumJSONRPC.Nethermind
case branch
7c372ce
to
d16cca3
Compare
a06d98f
to
2e8a756
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think hard-coded values are fine at least for v1, because they are really not a subject to change.
For instance, on Celo mainnet, the last transaction to Registry contract was done 4 years ago. On alfajores, Registry contract was not even updated -- e.g it returns nil-address (0x000...) for the core contract names.
40f044d
to
a0e8cc3
Compare
case tokens do | ||
[token] -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to case token_transfers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, make sense. Please, check 222feba to verify if I implemented your suggestions correctly
defp to_address_token_balances(token_transfers, celo_token) do | ||
%{token_transfers: token_transfers} | ||
|> Addresses.extract_addresses() | ||
|> Enum.map(fn %{fetched_coin_balance_block_number: block_number, hash: hash} -> | ||
with {:ok, address_hash} <- Hash.Address.cast(hash), | ||
{:ok, token_contract_address_hash} <- Hash.Address.cast(celo_token.contract_address_hash) do | ||
%{ | ||
address_hash: address_hash, | ||
token_contract_address_hash: token_contract_address_hash, | ||
block_number: block_number, | ||
token_type: celo_token.type, | ||
token_id: nil | ||
} | ||
else | ||
error -> Logger.error("Failed to cast string to hash: #{inspect(error)}") | ||
end | ||
end) | ||
|> MapSet.new() | ||
end | ||
|
||
defp async_import_celo_token_balances(%{token_transfers: token_transfers, tokens: tokens}) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to define functions in order in which they are called. I.e. firstly define async_import_celo_token_balances
and then to_address_token_balances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fixed in 222feba
2a4851c
to
3b7624a
Compare
3615ae2
to
b6f833b
Compare
* master: (65 commits) fix: Add healthcheck endpoints for indexer-only setup (#10076) 6.6.0 fix: Rework revert_reason (#9212) fix: Eliminate from_address_hash == #{address_hash} clause for transactions query in case of smart-contracts (#9469) feat: Add optional retry of NFT metadata fetch in Indexer.Fetcher.Tok… (#10036) fix: Separate indexer setup (#10032) feat: Blueprint contracts support (#10058) chore: Update hackney pool size: add new fetchers accounting (#9941) fix: Disallow batched queries in GraphQL endpoint (#10050) feat: Clone with immutable arguments proxy pattern (#10039) fix: vyper contracts re-verificaiton (#10053) refactor: Refactor get_additional_sources/4 -> get_additional_sources/3 (#10046) chore: Bump credo from 1.7.5 to 1.7.6 (#10060) chore: Bump redix from 1.5.0 to 1.5.1 (#10059) chore: Bump ex_doc from 0.32.1 to 0.32.2 (#10061) fix: Fix Unknown UID bug at smart-contract verification (#9986) refactor: test database config (#9662) chore: remove `has_methods` from `/addresses` (#10051) feat: Improve retry NFT fetcher (#10027) chore: Add support of Blast-specific L1 OP withdrawal events (#10049) ...
90e5394
to
b095ec3
Compare
# In CELO network, there is a token duality feature where CELO can be used | ||
# as both a native chain currency and as an ERC-20 token. Transactions | ||
# that transfer CELO are also counted as token transfers, and the | ||
# TokenInstance fetcher is called. However, for simplicity, we disable it | ||
# in this test. | ||
Application.put_env(:indexer, Indexer.Fetcher.TokenInstance.Realtime.Supervisor, disabled?: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this workaround?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b095ec3
to
18d82d1
Compare
* master: refactor: Remove hardcoded numResults from fetch_pending_transactions_besu (#10117) feat: Add window between balance fetch retries for missing balanceOf tokens (#10142) fix: Add missing preloads to tokens endpoints (#10072) Explicit message on token balance update error (#10129) fix: missing nil case for revert reason (#10136) fix: Hotfix for Indexer.Fetcher.Optimism.WithdrawalEvent and EthereumJSONRPC.Receipt (#10130) hide chain specific fields behind Map.get (#10131) --- (#10096) feat: indexer for cross level messages on Arbitrum (#9312) chore: Bump ecto_sql from 3.11.1 to 3.11.2 Indexer/API separated images for Redstone Update CHANGELOG Improve response of address API to return multiple implementations for Diamond proxy (#10113) Fix GA pre-release && release workflows Update CHANGELOG feat: implement fetch_first_trace for Geth (#10087) Remove custom release CI for Immutable Update CHANGELOG for 6.6.0 Fix certified flag in the search API v2 endpoint (#10094) fix: Update Vyper inner compilers list to support all compilers (#10091)
cd6f72d
to
86b86f6
Compare
Motivation
This PR adds support for custom fields from Celo blockchain and implements a
custom way to index Celo transactions.
Changelog
Enhancements
Environment variables
CHAIN_TYPE
env:celo
CELO_CORE_CONTRACTS
Transactions
New fields specific to CELO network are now supported. Here is the outline how the fields coming from RPC node are mapped to fields in
transactions
table:feeCurrency
→gas_token_contract_address_hash
gatewayFeeRecipient
→gas_fee_recipient_address_hash
(this field isscheduled for deprecation as stated in CELO docs)
gatewayFee
→gateway_fee
(this field isscheduled for deprecation as stated in CELO
docs)
The token used for gas payment (
feeCurrency
) is indexed within block fetcher process.Token-duality feature
Native chain asset transfers are treated as CELO ERC-20 token transfers. These token transfers are
artificial
, meaning that there is not real TAPI updates
Native chain asset transfers are treated as CELO ERC-20
Checklist for your Pull Request (PR)
master
in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables.