naive: capture rpc errors when sending l2 batches

This commit is contained in:
yosoyubik 2021-05-22 08:10:30 +02:00
parent 3cee0ff3b8
commit 766e2ab610
2 changed files with 31 additions and 11 deletions

View File

@ -223,13 +223,13 @@
=+ !<([=term =tang] q.cage.sign) =+ !<([=term =tang] q.cage.sign)
%- (slog leaf+"{(trip dap.bowl)} failed" leaf+<term> tang) %- (slog leaf+"{(trip dap.bowl)} failed" leaf+<term> tang)
=^ cards state =^ cards state
(on-thread-result:do (rash i.t.wire dem) %.n^term) (on-thread-result:do (rash i.t.wire dem) %.n^'thread failed')
[cards this] [cards this]
:: ::
%thread-done %thread-done
~& ['all submitted to' t.wire] ~& ['all submitted to' t.wire]
:: is aggregator/send thread expected to maybe return an error? :: is aggregator/send thread expected to maybe return an error?
=+ !<(result=(each @ud term) q.cage.sign) =+ !<(result=(each @ud @t) q.cage.sign)
=^ cards state =^ cards state
(on-thread-result:do (rash i.t.wire dem) result) (on-thread-result:do (rash i.t.wire dem) result)
[cards this] [cards this]
@ -420,7 +420,7 @@
:: +on-thread-result: await resend after thread success or failure :: +on-thread-result: await resend after thread success or failure
:: ::
++ on-thread-result ++ on-thread-result
|= [nonce=@ud result=(each @ud term)] |= [nonce=@ud result=(each @ud @t)]
^- (quip card _state) ^- (quip card _state)
:: update gas price for this tx in state :: update gas price for this tx in state
:: ::

View File

@ -67,14 +67,19 @@
:: ::
::NOTE this fails the thread if sending fails, which in the app gives us ::NOTE this fails the thread if sending fails, which in the app gives us
:: the "retry with same gas price" behavior we want :: the "retry with same gas price" behavior we want
;< jon=json bind:m ;< =response:rpc bind:m (send-batch endpoint tx)
%+ request-rpc:ethio endpoint %- pure:m
[`'sendRawTransaction' %eth-send-raw-transaction tx] !> ^- (each @ud @t)
::TODO check that tx-hash in jon is non-zero? ?+ -.response %.n^'unexpected rpc response'
::TODO enforce max here, or in app? %error %.n^message.res
:: add five gwei to gas price of next attempt :: TODO:
:: :: check that tx-hash in +.response is non-zero?
(pure:m !>(%.y^(add use-gas-price 5.000.000.000))) :: log tx-hash to getTransactionReceipt(tx-hash)?
:: enforce max here, or in app?
:: add five gwei to gas price of next attempt
::
%result %.y^(add use-gas-price 5.000.000.000)
==
:: ::
::TODO should be distilled further, partially added to strandio? ::TODO should be distilled further, partially added to strandio?
++ fetch-gas-price ++ fetch-gas-price
@ -106,4 +111,19 @@
%. u.jon %. u.jon
=, dejs-soft:format =, dejs-soft:format
(ot 'result'^(ot 'FastGasPrice'^ni ~) ~) (ot 'result'^(ot 'FastGasPrice'^ni ~) ~)
::
++ send-batch
|= [endpoint=@ta batch=@ux]
=/ m (strand:strandio ,response:rpc)
^- form:m
=/ req=[(unit @t) request:rpc:ethereum]
[`'sendRawTransaction' %eth-send-raw-transaction batch]
;< res=(list response:rpc) bind:m
(request-batch-rpc-loose:ethio endpoint [req]~)
?: ?=([* ~] res)
(pure:m i.res)
%+ strand-fail:strandio
%unexpected-multiple-results
[>(lent res)< ~]
::
-- --