-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add withdrawals support (EIP-4895) #6694
Conversation
9496ca4
to
b8d39fd
Compare
b8d39fd
to
ed4dbe6
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.
@sl1depengwyn could you please add a screenshot(s) of UI changes for support of withdrawals feature to the description of PR?
Done |
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.
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.
if reason === :normal do | ||
{:noreply, state} | ||
else | ||
Logger.metadata(fetcher: :transaction_action) |
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.
Copy paste?
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.
Yep, I'll fix it
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.
Done in 1670e8f
select: block.number, | ||
distinct: block.number, | ||
where: block.number >= ^from, | ||
where: is_nil(withdrawal.index) |
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.
consider to add here condition for block.consensus == 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.
Done in 1670e8f
896a520
to
1670e8f
Compare
Done in 1670e8f |
9cb6ee5
to
8d753cc
Compare
b60f44b
to
fa09475
Compare
f526128
to
b8c3052
Compare
apps/explorer/lib/explorer/chain.ex
Outdated
@spec check_if_withdrawals_in_block(Hash.Full.t()) :: boolean() | ||
def check_if_withdrawals_in_block(block_hash) do | ||
block_hash | ||
|> Withdrawal.block_hash_to_withdrawals_query() |
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.
This is really micro improvment but nevertheless. Let's use here version of this query without order_by?
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.
Make sense, fixed here bca0f23
apps/explorer/lib/explorer/chain.ex
Outdated
@spec check_if_withdrawals_at_address(Hash.Address.t()) :: boolean() | ||
def check_if_withdrawals_at_address(address_hash) do | ||
address_hash | ||
|> Withdrawal.address_hash_to_withdrawals_query() |
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.
The same as above
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.
Make sense, fixed here bca0f23
use BlockScoutWeb, :view | ||
|
||
# import BlockScoutWeb.AddressView, only: [balance: 1] | ||
# import BlockScoutWeb.Tokens.OverviewView, only: [total_supply_usd: 1] |
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.
Is it still needed?
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.
Nope, thanks, fixed in bca0f23
{:ok, block} <- fetch_block(type, value, @api_true) do | ||
full_options = | ||
[necessity_by_association: %{address: :optional}] | ||
|> Keyword.merge(paging_options(params)) |
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.
Needed to add api?: true
here
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.
Fixed in bca0f23
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)}, | ||
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params), | ||
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do | ||
withdrawals_plus_one = address_hash |> Chain.address_hash_to_withdrawals(paging_options(params)) |
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.
Here also api?: true
is missed
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.
Fixed in bca0f23
@@ -370,6 +370,22 @@ defmodule BlockScoutWeb.API.V2.AddressController do | |||
end | |||
end | |||
|
|||
def withdrawals(conn, %{"address_hash" => address_hash_string} = params) 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 think we need also add new field to address entity: has_beacon_chain_withdrawals
to apps/block_scout_web/lib/block_scout_web/views/api/v2/address_view.ex:110
(Don't forget about api?: 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.
The same applies to the block view, am I right?
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.
yes but only for case when renders single block
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.
Done in bca0f23
blocks | ||
end | ||
|
||
defp parse_integer(nil), do: nil |
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 we can reuse parse_integer from apps/explorer/lib/explorer/helper.ex
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.
Done in bca0f23
ca8e4f1
to
8e33fad
Compare
8e33fad
to
bca0f23
Compare
bca0f23
to
288df0b
Compare
Add withdrawals to explorer app Add withdrawals to indexer Add withdrawal tabs to address and block pages Add withdrawals test to web Add withdrawals test to eth json rpc Add withdrawals test to explorer Add withdrawal test to indexer Update CHANGELOG.md Update gettext [no ci] Update apps/indexer/config/prod.exs [no ci] Co-authored-by: nikitosing <32202610+nikitosing@users.noreply.github.com> Fix review Update CHANGELOG.md Update CHANGELOG.md Add withdrawal list page; Add withdrawal to APIv2 Add timestamp Fix nikitosing review
a81018a
to
ded0cd5
Compare
ded0cd5
to
f44172d
Compare
Closes #6455
Changelog
Add tab withdrawal to block page
![image](https://user-images.githubusercontent.com/53992153/211720356-18d64dc7-8a51-413d-a65a-cd68a641a87c.png)
Add tab withdrawal to address page
![image](https://user-images.githubusercontent.com/53992153/211720319-b06870ec-0747-4989-94b9-d8ba4cbf4140.png)
Add withdrawal fetcher (disabled by default because at the moment withdrawals is in the development, so withdrawals fetcher is not needed now at the majority of the chains)
Nodes for testing: https://github.com/ethpandaops/withdrawals-testnet/blob/master/withdrawal-devnet-3/inventory/inventory.ini (if down try to check withdrawal-devnet-n+1 or public net that going to be available soon)
Checklist for your Pull Request (PR)
CHANGELOG.md
with this PRmaster
in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables. (Add envs and update sharelock for withdrawals docs#103)