merge master

pull/2376/head
saneery 5 years ago
commit 2c39d4b4ed
  1. 4
      CHANGELOG.md
  2. 2
      PULL_REQUEST_TEMPLATE.md
  3. 4
      apps/block_scout_web/assets/__tests__/lib/async_listing_load.js
  4. 21
      apps/block_scout_web/assets/js/lib/async_listing_load.js
  5. 7
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination_container.html.eex
  6. 6
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_tile-loader.html.eex
  7. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  8. 4
      apps/block_scout_web/priv/gettext/default.pot
  9. 4
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  10. 28
      apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex
  11. 24
      apps/explorer/test/explorer/chain/import/runner/internal_transactions_test.exs

@ -7,9 +7,13 @@
- [#2456](https://github.com/poanetwork/blockscout/pull/2456) - fetch pending transactions for geth
### Fixes
- [#2520](https://github.com/poanetwork/blockscout/pull/2520) - Hide loading message when fetching is failed
- [#2523](https://github.com/poanetwork/blockscout/pull/2523) - Avoid importing internal_transactions of pending transactions
- [#2519](https://github.com/poanetwork/blockscout/pull/2519) - enable `First` page button in pagination
- [#2515](https://github.com/poanetwork/blockscout/pull/2515) - do not aggregate NFT token transfers
- [#2512](https://github.com/poanetwork/blockscout/pull/2512) - alert link fix
- [#2508](https://github.com/poanetwork/blockscout/pull/2508) - logs view columns fix
- [#2506](https://github.com/poanetwork/blockscout/pull/2506) - fix two active tab in the top menu
- [#2503](https://github.com/poanetwork/blockscout/pull/2503) - Mitigate autocompletion library influence to page loading performance
- [#2502](https://github.com/poanetwork/blockscout/pull/2502) - increase reward task timeout
- [#2463](https://github.com/poanetwork/blockscout/pull/2463) - dark theme fixes

@ -35,5 +35,5 @@
- [ ] If I added new functionality, I added tests covering it.
- [ ] If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
- [ ] I checked whether I should update the docs and did so if necessary
- [ ] If I added/changed/removed ENV var, I should update the list of env vars in https://github.com/poanetwork/blockscout/blob/master/docs/env-variables.md to reflect changes in the table here https://poanetwork.github.io/blockscout/#/env-variables?id=blockscout-env-variables
- [ ] If I added/changed/removed ENV var, I should update the list of env vars in https://github.com/poanetwork/blockscout/blob/master/docs/env-variables.md to reflect changes in the table here https://poanetwork.github.io/blockscout/#/env-variables?id=blockscout-env-variables. I've set `master` in the `Version` column.
- [ ] If I add new indices into DB, I checked, that they don't redundant with PGHero or other tools

@ -46,14 +46,12 @@ describe('REQUEST_ERROR', () => {
describe('FINISH_REQUEST', () => {
test('sets loading status to false', () => {
const state = Object.assign({}, asyncInitialState, {
loading: true,
loadingFirstPage: true
loading: true
})
const action = { type: 'FINISH_REQUEST' }
const output = asyncReducer(state, action)
expect(output.loading).toEqual(false)
expect(output.loadingFirstPage).toEqual(false)
})
})

@ -51,8 +51,6 @@ export const asyncInitialState = {
requestError: false,
/* if response has no items */
emptyResponse: false,
/* if it is loading the first page */
loadingFirstPage: true,
/* link to the next page */
nextPagePath: null,
/* link to the previous page */
@ -80,8 +78,7 @@ export function asyncReducer (state = asyncInitialState, action) {
}
case 'FINISH_REQUEST': {
return Object.assign({}, state, {
loading: false,
loadingFirstPage: false
loading: false
})
}
case 'ITEMS_FETCHED': {
@ -134,7 +131,7 @@ export const elements = {
},
'[data-async-listing] [data-loading-message]': {
render ($el, state) {
if (state.loadingFirstPage) return $el.show()
if (state.loading) return $el.show()
$el.hide()
}
@ -143,7 +140,7 @@ export const elements = {
render ($el, state) {
if (
!state.requestError &&
(!state.loading || !state.loadingFirstPage) &&
(!state.loading) &&
state.items.length === 0
) {
return $el.show()
@ -201,6 +198,16 @@ export const elements = {
$el.attr('href', state.prevPagePath)
}
},
'[data-async-listing] [data-first-page-button]': {
render ($el, state) {
if (state.pagesStack.length === 0) {
return $el.hide()
}
$el.show()
$el.attr('disabled', false)
$el.attr('href', window.location.href.split('?')[0])
}
},
'[data-async-listing] [data-page-number]': {
render ($el, state) {
if (state.emptyResponse) {
@ -216,7 +223,7 @@ export const elements = {
},
'[data-async-listing] [data-loading-button]': {
render ($el, state) {
if (!state.loadingFirstPage && state.loading) return $el.show()
if (state.loading) return $el.show()
$el.hide()
}

@ -14,15 +14,14 @@
<!-- Pagination -->
<ul class="pagination">
<!-- First -->
<%= if assigns[:first_page_path] do %>
<li class="page-item">
<a
<%= if !assigns[:first_page_path] do %>disabled<% end %>
disabled
class="page-link"
href='<%= "#{assigns[:first_page_path]}" %>'
href
data-first-page-button
>First</a>
</li>
<% end %>
<!-- Previous -->
<li class="page-item">
<a

@ -1,4 +1,4 @@
<div data-selector="loading-message" class="tile tile-type-loading">
<div data-loading-message data-selector="loading-message" class="tile tile-type-loading">
<div class="row tile-body">
<div class="tile-transaction-type-block col-md-2 d-flex flex-row flex-md-column">
<span class="tile-label">
@ -22,7 +22,7 @@
</div>
</div>
</div>
<div data-selector="loading-message" class="tile tile-type-loading">
<div data-loading-message data-selector="loading-message" class="tile tile-type-loading">
<div class="row tile-body">
<div class="tile-transaction-type-block col-md-2 d-flex flex-row flex-md-column">
<span class="tile-label">
@ -46,7 +46,7 @@
</div>
</div>
</div>
<div data-selector="loading-message" class="tile tile-type-loading">
<div data-loading-message data-selector="loading-message" class="tile tile-type-loading">
<div class="row tile-body">
<div class="tile-transaction-type-block col-md-2 d-flex flex-row flex-md-column">
<span class="tile-label">

@ -93,7 +93,7 @@
) %>
<%= link(
gettext("Eth RPC"),
class: "dropdown-item #{tab_status("api_docs", @conn.request_path)}",
class: "dropdown-item #{tab_status("eth_rpc_api_docs", @conn.request_path)}",
to: api_url() <> api_docs_path(@conn, :eth_rpc)
) %>
</div>

@ -1510,7 +1510,7 @@ msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:40
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:39
msgid "Page"
msgstr ""
@ -1528,7 +1528,7 @@ msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:40
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:39
msgid "of"
msgstr ""

@ -1511,7 +1511,7 @@ msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:40
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:39
msgid "Page"
msgstr ""
@ -1529,7 +1529,7 @@ msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:40
#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:39
msgid "of"
msgstr ""

@ -73,10 +73,12 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
# order so that row ShareLocks are grabbed in a consistent order
ordered_changes_list = Enum.sort_by(changes_list, &{&1.transaction_hash, &1.index})
final_changes_list = reject_pending_transactions(ordered_changes_list, repo)
{:ok, internal_transactions} =
Import.insert_changes_list(
repo,
ordered_changes_list,
final_changes_list,
conflict_target: [:transaction_hash, :index],
for: InternalTransaction,
on_conflict: on_conflict,
@ -156,6 +158,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
from(
t in Transaction,
where: t.hash in ^ordered_transaction_hashes,
where: not is_nil(t.block_hash),
update: [
set: [
internal_transactions_indexed_at: ^timestamps.updated_at,
@ -180,10 +183,8 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
]
)
transaction_count = Enum.count(ordered_transaction_hashes)
try do
{^transaction_count, result} = repo.update_all(query, [], timeout: timeout)
{_transaction_count, result} = repo.update_all(query, [], timeout: timeout)
{:ok, result}
rescue
@ -191,4 +192,23 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
{:error, %{exception: postgrex_error, transaction_hashes: ordered_transaction_hashes}}
end
end
defp reject_pending_transactions(ordered_changes_list, repo) do
transaction_hashes =
ordered_changes_list
|> Enum.map(& &1.transaction_hash)
|> Enum.dedup()
query =
from(t in Transaction,
where: t.hash in ^transaction_hashes,
where: is_nil(t.block_hash),
select: t.hash
)
pending_transactions = repo.all(query)
ordered_changes_list
|> Enum.reject(fn %{transaction_hash: hash} -> Enum.member?(pending_transactions, hash) end)
end
end

@ -2,7 +2,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsTest do
use Explorer.DataCase
alias Ecto.Multi
alias Explorer.Chain.{Data, Wei, Transaction}
alias Explorer.Chain.{Data, Wei, Transaction, InternalTransaction}
alias Explorer.Chain.Import.Runner.InternalTransactions
describe "run/1" do
@ -20,6 +20,28 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsTest do
assert :error == Repo.get(Transaction, transaction.hash).status
end
test "pending transactions don't get updated not its internal_transactions inserted" do
transaction = insert(:transaction) |> with_block(status: :ok)
pending = insert(:transaction)
assert :ok == transaction.status
assert is_nil(pending.block_hash)
index = 0
transaction_changes = make_internal_transaction_changes(transaction.hash, index, nil)
pending_changes = make_internal_transaction_changes(pending.hash, index, nil)
assert {:ok, _} = run_internal_transactions([transaction_changes, pending_changes])
assert %InternalTransaction{} =
Repo.one(from(i in InternalTransaction, where: i.transaction_hash == ^transaction.hash))
assert from(i in InternalTransaction, where: i.transaction_hash == ^pending.hash) |> Repo.one() |> is_nil()
assert is_nil(Repo.get(Transaction, pending.hash).block_hash)
end
end
defp run_internal_transactions(changes_list) when is_list(changes_list) do

Loading…
Cancel
Save