-
Notifications
You must be signed in to change notification settings - Fork 9
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
Invalid method is returned #1277
Labels
bug
Something isn't working
Comments
It's an online bug, how is it going @Naupio |
link pr #1298 |
this issue need to process history date of |
process update "0x00" transaction history data script defmodule Temp do
alias GodwokenExplorer.Repo
alias GodwokenExplorer.Transaction
alias GodwokenExplorer.Chain.Data
alias GodwokenExplorer.Chain.Import
import GodwokenRPC.Util, only: [import_timestamps: 0]
import Ecto.Query
def fix_transaction_method_id() do
{:ok, mid} = Data.cast("0x00")
q =
from(t in Transaction,
where: t.method_id == ^mid
)
need_process = q |> Repo.aggregate(:count) |> IO.inspect(label: "need process")
loop = round(need_process / 500) + 1
Enum.reduce(1..loop, 0, fn _, acc ->
params =
q
|> limit(500)
|> Repo.all()
|> Enum.map(fn p ->
Map.from_struct(p)
|> Map.delete(:__meta__)
|> Map.put(:method_id, nil)
end)
add_acc = length(params)
Import.insert_changes_list(
params,
for: Transaction,
timestamps: import_timestamps(),
on_conflict: {:replace, [:method_id]},
conflict_target: [:hash]
)
(acc + add_acc) |> IO.inspect(label: "processed")
end)
end
end |
testnet-stg history was proceed |
need fixed method name with task defmodule Temp do
import Ecto.Query
import GodwokenRPC.Util,
only: [
import_timestamps: 0
]
alias GodwokenExplorer.Chain.{Import}
alias GodwokenExplorer.{Repo, Account, Transaction, SmartContract, Polyjuice}
def do_perform() do
return1 = common_base_query() |> process_order_by_limit() |> Repo.all()
batch_update_transaction_method_id_name(return1)
# check method name if smart_contract abi update later
return2 =
check_method_name_query()
|> process_order_by_limit()
|> Repo.all()
batch_update_transaction_method_id_name(return2)
{:ok, nil}
end
def batch_update_transaction_method_id_name(return) do
IO.inspect(length(return), label: "need update transaction count ===>")
concurrency = 500
result =
return
|> Enum.chunk_every(concurrency)
|> Enum.reduce(0, fn maps, acc ->
return =
maps
|> Task.async_stream(
fn map ->
{method_id, method_name} =
with input when not is_nil(input) <- map.input,
input <- input |> to_string(),
mid <- input |> String.slice(0, 10),
true <- String.length(mid) >= 10 do
method_name =
Polyjuice.get_method_name_without_account_check(
map.to_account_id,
input |> to_string
)
{mid, method_name}
else
_ ->
{nil, nil}
end
map
|> Map.delete(:input)
|> Map.put(:method_id, method_id)
|> Map.put(:method_name, method_name)
end,
timeout: :infinity
)
|> Enum.map(fn {:ok, r} -> r end)
|> Enum.filter(fn r -> not is_nil(r.method_id) end)
Import.insert_changes_list(return,
for: Transaction,
timestamps: import_timestamps(),
on_conflict: {:replace, [:method_id, :method_name]},
conflict_target: :hash
)
IO.inspect(acc + length(return), label: "data was processed ==>")
end)
{:ok, result}
end
def common_base_query() do
common_query()
|> where([transaction: t], is_nil(t.method_id))
end
defp common_query() do
from(t in Transaction,
as: :transaction,
inner_join: sc in SmartContract,
on: t.to_account_id == sc.account_id,
as: :smart_contract,
inner_join: a in Account,
as: :account,
on: a.id == t.to_account_id,
where: a.type == :polyjuice_contract,
inner_join: p in Polyjuice,
as: :polyjuice,
on: t.hash == p.tx_hash,
where: p.input_size >= 10,
select: %{
hash: t.hash,
from_account_id: t.from_account_id,
to_account_id: t.to_account_id,
nonce: t.nonce,
args: t.args,
input: p.input
}
)
end
def check_method_name_query() do
common_query()
|> where([transaction: t], not is_nil(t.method_id) and is_nil(t.method_name))
|> where(
[smart_contract: sc],
not is_nil(sc.abi)
)
end
def process_order_by_limit(query) do
query
|> order_by([transaction: t], desc: t.updated_at)
|> limit(10000)
end
end |
pr link #1305 |
testnet-prod was deployed @FrederLu |
Verified. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1、This is a plain transaction to send pCKB https://v1.testnet.gwscan.com/tx/0xbccc4daef54ec6fd5cdafd893efbf311c0640d0280e580b4aedfc852d8c7ded8
The method is expected to be
null
, but0x00
is received.2、The contract has an ABI, but the standard method parsing exception in the transaction list.
![Image](https://user-images.githubusercontent.com/25676576/213099265-cc165b30-e805-4795-8c6c-89a830fcc8ff.png)
![Image](https://user-images.githubusercontent.com/25676576/213099538-37027748-3561-4a00-8cef-fe2b1648d8fa.png)
https://v1.testnet.gwscan.com/account/0xdac77963b2c03c666be8b64b4e41b7fc2af3d8f0?tab=transactions
https://v1.testnet.gwscan.com/nft-collection/0xdac77963b2c03c666be8b64b4e41b7fc2af3d8f0
The text was updated successfully, but these errors were encountered: