Skip to content
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

Continue including valid user-commands after seeing an invalid one #6140

Merged
merged 4 commits into from
Sep 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/lib/staged_ledger/staged_ledger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,34 +1706,31 @@ module T = struct
O1trace.trace_event "found completed work" ;
(*Transactions in reverse order for faster removal if there is no space when creating the diff*)
let valid_on_this_ledger =
Sequence.fold_until transactions_by_fee ~init:Sequence.empty
~f:(fun seq txn ->
Sequence.fold_until transactions_by_fee ~init:(Sequence.empty, 0)
~f:(fun (seq, count) txn ->
match
O1trace.measure "validate txn" (fun () ->
Transaction_validator.apply_transaction ~constraint_constants
validating_ledger ~txn_state_view:current_state_view
(Command (txn :> User_command.t)) )
with
| Error e ->
let error_message =
sprintf
!"Staged_ledger_diff creation: Invalid user command! Error \
was: %s, command was: $user_command"
(Error.to_string_hum e)
in
[%log fatal]
~metadata:[("user_command", User_command.Valid.to_yojson txn)]
!"%s" error_message ;
Stop seq
[%log error]
~metadata:
[ ("user_command", User_command.Valid.to_yojson txn)
; ("error", `String (Error.to_string_hum e)) ]
"Staged_ledger_diff creation: Skipping user command: \
$user_command due to error: $error" ;
Continue (seq, count)
| Ok status ->
let txn_with_status = {With_status.data= txn; status} in
let seq' =
Sequence.append (Sequence.singleton txn_with_status) seq
in
if Sequence.length seq' = Scan_state.free_space t.scan_state then
Stop seq'
else Continue seq' )
~finish:Fn.id
let count' = count + 1 in
if count' >= Scan_state.free_space t.scan_state then Stop seq'
else Continue (seq', count') )
~finish:fst
in
let diff, log =
O1trace.measure "generate diff" (fun () ->
Expand Down