op-geth/les
Felföldi Zsolt 4eb9296910
p2p/nodestate: ensure correct callback order (#21436)
This PR adds an extra guarantee to NodeStateMachine: it ensures that all
immediate effects of a certain change are processed before any subsequent
effects of any of the immediate effects on the same node. In the original
version, if a cascaded change caused a subscription callback to be called
multiple times for the same node then these calls might have happened in a
wrong chronological order.

For example:

- a subscription to flag0 changes flag1 and flag2
- a subscription to flag1 changes flag3
- a subscription to flag1, flag2 and flag3 was called in the following order:

   [flag1] -> [flag1, flag3]
   [] -> [flag1]
   [flag1, flag3] -> [flag1, flag2, flag3]

This happened because the tree of changes was traversed in a "depth-first
order". Now it is traversed in a "breadth-first order"; each node has a
FIFO queue for pending callbacks and each triggered subscription callback
is added to the end of the list. The already existing guarantees are
retained; no SetState or SetField returns until the callback queue of the
node is empty again. Just like before, it is the responsibility of the
state machine design to ensure that infinite state loops are not possible.
Multiple changes affecting the same node can still happen simultaneously;
in this case the changes can be interleaved in the FIFO of the node but the
correct order is still guaranteed.

A new unit test is also added to verify callback order in the above scenario.
2020-09-14 14:01:18 +02:00
..
checkpointoracle les: update checktime even if check fails 2020-08-07 10:57:02 +02:00
flowcontrol all: update author list and licenses 2019-07-22 12:17:27 +03:00
lespay/client les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
utils les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
api.go les: make clientPool.connectedBias configurable (#21305) 2020-07-21 10:23:40 +02:00
api_backend.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
api_test.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
balance.go les: rename UpdateBalance to AddBalance and simplify return format (#20304) 2019-11-18 12:42:49 +01:00
balance_test.go les: rework clientpool (#20077) 2019-11-02 13:02:35 +01:00
benchmark.go les, les/lespay/client: add service value statistics and API (#20837) 2020-04-09 11:55:32 +02:00
bloombits.go les: handler separation (#19639) 2019-08-21 11:29:34 +02:00
client.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
client_handler.go les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
clientpool.go les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
clientpool_test.go les: make clientPool.connectedBias configurable (#21305) 2020-07-21 10:23:40 +02:00
commons.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
costtracker.go les: add missing Ticker.Stop call (#20864) 2020-04-02 15:54:59 +02:00
distributor.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
distributor_test.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
enr_entry.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
fetcher.go les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
fetcher_test.go les: fix unittest (#21382) 2020-07-29 13:44:14 +03:00
handler_test.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
metrics.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
odr.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
odr_requests.go core, eth, les, trie: add a prefix to contract code (#21080) 2020-08-21 15:10:40 +03:00
odr_test.go les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
peer.go les: close all connected les-server when shutdown (#21426) 2020-08-07 15:33:00 +02:00
peer_test.go les: remove invalid use of t.Fatal in TestHandshake (#21012) 2020-05-01 13:48:52 +02:00
protocol.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
pruner.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00
pruner_test.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00
request_test.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00
retrieve.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
server.go les: close all connected les-server when shutdown (#21426) 2020-08-07 15:33:00 +02:00
server_handler.go core, eth, les, trie: add a prefix to contract code (#21080) 2020-08-21 15:10:40 +03:00
serverpool.go p2p/nodestate: ensure correct callback order (#21436) 2020-09-14 14:01:18 +02:00
serverpool_test.go les, les/lespay: implement new server pool (#20758) 2020-05-22 13:46:34 +02:00
servingqueue.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
sync.go les: separate peer into clientPeer and serverPeer (#19991) 2020-02-26 11:41:24 +02:00
sync_test.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00
test_helper.go les: implement new les fetcher (#20692) 2020-07-28 18:02:35 +03:00
txrelay.go les, les/lespay/client: add service value statistics and API (#20837) 2020-04-09 11:55:32 +02:00
ulc.go cmd, eth, les: fix up ultra light config integration 2019-07-09 20:34:42 +03:00
ulc_test.go les: historical data garbage collection (#19570) 2020-07-13 11:02:54 +02:00