Skip to content

Commit 00edec8

Browse files
committed
use all cores for eventgen
1 parent 359e18d commit 00edec8

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

ex/config/runtime.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ config :ama, :snapshot_height, (System.get_env("SNAPSHOT_HEIGHT") || "43401193")
2020
# https://snapshots.amadeus.bot/000041960861.zip
2121
# zip -0 -r 000037454455.zip db/
2222
# aws s3 cp --checksum-algorithm=CRC32 --endpoint-url https://20bf2f5d11d26a322e389687896a6601.r2.cloudflarestorage.com 000039434469.zip s3://ama-snapshot
23-
# aria2c -x 2 https://snapshots.amadeus.bot/000041960861.zip
23+
# aria2c -x 2 https://snapshots.amadeus.bot/000043401193.zip
2424

2525
# tar -C /tmp/000037454455 --xform 's@^\./@@' -cf - . | zstd -T0 -1 -o /tmp/000037454455.tar.zst
2626
# zstd -T0 -d --stdout /tmp/000037454455.tar.zst | tar -C /tmp/restore -xf -
@@ -38,6 +38,7 @@ config :ama, :udp_ipv4_tuple, udp_ipv4_iface
3838
config :ama, :udp_port, (System.get_env("UDP_PORT") || "36969") |> :erlang.binary_to_integer()
3939

4040
config :ama, :rpc_url, (System.get_env("RPC_URL") || "https://nodes.amadeus.bot")
41+
config :ama, :rpc_events, ((System.get_env("RPC_EVENTS") || "true") == "true")
4142

4243
#Nodes
4344
if !Util.verify_time_sync() do

ex/lib/api/api_tx.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ defmodule API.TX do
157157

158158
tx = put_in(tx, [:tx, :action], action)
159159

160+
tx = if !tx[:receipt] do tx else
161+
logs = Enum.map(tx.receipt.logs, fn(line)-> RocksDB.ascii_dump(line) end)
162+
receipt = Map.merge(tx.receipt, %{result: RocksDB.ascii_dump(tx.receipt.result), logs: logs})
163+
Map.put(tx, :receipt, receipt)
164+
end
165+
160166
if !Map.has_key?(tx, :metadata) do tx else
161167
put_in(tx, [:metadata, :entry_hash], Base58.encode(tx.metadata.entry_hash))
162168
end

ex/lib/api/db_chain.ex

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ defmodule DB.Chain do
5555
entry = DB.Entry.by_hash(map.entry_hash, db_opts)
5656
tx_bytes = binary_part(entry_bytes, map.index_start, map.index_size)
5757

58-
receipt = if map[:result] do map.result else
59-
receipt = map.receipt
60-
result = RocksDB.ascii_dump(receipt.result)
61-
logs = Enum.map(receipt.logs, & RocksDB.ascii_dump(&1))
62-
Map.merge(receipt, %{result: result, logs: logs})
63-
end
58+
receipt = if map[:result] do map.result else map.receipt end
6459

6560
TX.unpack(tx_bytes)
6661
|> Map.put(:receipt, receipt)

ex/lib/consensus/coordination/fabric_event_gen.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ defmodule FabricEventGen do
5151
end
5252

5353
#IO.inspect API.Chain.format_entry_for_client(entry), limit: 11111
54-
entry_b58 = API.Chain.format_entry_for_client(entry)
55-
txs = Enum.map(entry.txs, fn(txu)->
56-
API.TX.format_tx_for_client(txu)
54+
txs_task = Task.async(fn ->
55+
entry.txs
56+
|> Task.async_stream(fn txu -> API.TX.format_tx_for_client(txu) end)
57+
|> Enum.map(fn {:ok, res} -> res end)
5758
end)
59+
entry_b58 = API.Chain.format_entry_for_client(entry)
60+
txs = Task.await(txs_task, :infinity)
61+
5862
broadcast({:update_stats_entry_tx, API.Chain.stats(), entry_b58, txs})
5963

6064
{:noreply, state}

ex/lib/consensus/fabric_gen.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ defmodule FabricGen do
131131
:erlang.halt()
132132

133133
true ->
134-
FabricEventGen.event_rooted(best_entry, muts_hash)
134+
Application.fetch_env!(:ama, :rpc_events) && FabricEventGen.event_rooted(best_entry, muts_hash)
135135
%{db: db, cf: cf} = :persistent_term.get({:rocksdb, Fabric})
136136
RocksDB.put("rooted_tip", best_entry.hash, %{db: db, cf: cf.sysconf})
137137
proc_consensus()
@@ -187,7 +187,7 @@ defmodule FabricGen do
187187
result = %{error: :ok} -> result
188188
end
189189

190-
FabricEventGen.event_applied(entry, m_hash, m, r)
190+
Application.fetch_env!(:ama, :rpc_events) && FabricEventGen.event_applied(entry, m_hash, m, r)
191191
TXPool.delete_packed(entry.txs)
192192

193193
proc_entries()

0 commit comments

Comments
 (0)