Skip to content

Commit e101cb7

Browse files
committed
fix validator grabbing invalid txs
1 parent 8424340 commit e101cb7

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

ex/lib/consensus/fabric_gen.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule FabricGen do
5050

5151
def tick_slot(state) do
5252
#IO.inspect "tick_slot"
53-
Application.fetch_env!(:ama, :testnet) && Process.sleep(500)
53+
Application.fetch_env!(:ama, :testnet) && Process.sleep(350)
5454

5555
if proc_if_my_slot() do
5656
proc_entries()
@@ -206,6 +206,7 @@ defmodule FabricGen do
206206
lastSlot = :persistent_term.get(:last_made_entry_slot, nil)
207207

208208
rooted_tip = DB.Chain.rooted_tip()
209+
209210
emptyHeight = DB.Entry.by_height(next_height)
210211
emptyHeight = emptyHeight == []
211212

ex/lib/consensus/models/tx.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ defmodule TX do
5858

5959
def validate(txu, is_special_meeting_block \\ false) do
6060
try do
61+
true = !txu[:tx_encoded]
62+
6163
txu = Map.take(txu, @fields)
6264
tx_encoded = RDB.vecpak_encode(txu.tx)
6365

ex/lib/node/txpool.ex

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,21 @@ defmodule TXPool do
111111
segment_vr_hash = DB.Chain.segment_vr_hash()
112112
{acc, state} = :ets.foldl(fn({key, txu}, {acc, state_old})->
113113
try do
114-
case validate_tx(txu, %{epoch: chain_epoch, segment_vr_hash: segment_vr_hash, batch_state: state_old}) do
115-
%{error: :ok, batch_state: batch_state} ->
116-
acc = acc ++ [txu]
117-
if length(acc) == amt do
118-
throw {:choose, acc}
114+
case TX.validate(txu) do
115+
%{error: :ok} ->
116+
case validate_tx(txu, %{epoch: chain_epoch, segment_vr_hash: segment_vr_hash, batch_state: state_old}) do
117+
%{error: :ok, batch_state: batch_state} ->
118+
acc = acc ++ [txu]
119+
if length(acc) == amt do
120+
throw {:choose, acc}
121+
end
122+
{acc, batch_state}
123+
#delete stale
124+
%{key: key} ->
125+
:ets.delete(TXPool, key)
126+
{acc, state_old}
119127
end
120-
{acc, batch_state}
121-
#delete stale
122-
%{key: key} ->
128+
_ ->
123129
:ets.delete(TXPool, key)
124130
{acc, state_old}
125131
end

0 commit comments

Comments
 (0)