2
2
3
3
# Hyperledger FireFly Transaction Manager
4
4
5
- Plugable microservice component of Hyperledger FireFly, responsible for:
5
+ The core component of the FireFly Connector Framework for Blockchains , responsible for:
6
6
7
7
- Submission of transactions to blockchains of all types
8
+ - Nonce management - idempotent submission of transactions, and assignment of nonces
8
9
- Protocol connectivity decoupled with additional lightweight API connector
9
10
- Easy to add additional protocols that conform to normal patterns of TX submission / events
10
11
@@ -16,12 +17,96 @@ Plugable microservice component of Hyperledger FireFly, responsible for:
16
17
- Extensible policy engine
17
18
- Gas station API integration
18
19
19
- - Event streaming [ * work in progress to extract from previous location in ethconnect ]
20
+ - Event streaming
20
21
- Protocol agnostic event polling/streaming support
21
22
- Reliable checkpoint restart
22
23
- At least once delivery API
23
24
24
- ![ Hyperledger FireFly Transaction Manager] ( ./images/firefly_transaction_manager.jpg )
25
+ ## Architecture
26
+
27
+ The core architecture of the FireFly Connector Framework is as follows:
28
+
29
+ [ ![ Hyperledger FireFly Transaction Manager] ( ./images/firefly_connector_framework_architecture.jpg )] ( ./images/firefly_connector_framework_architecture.jpg )
30
+
31
+ This re-usable codebase contains as much as possible of the re-usable heavy lifting code needed across any blockchain.
32
+
33
+ The framework is currently constrained to blockchains that adhere to certain basic principals:
34
+
35
+ 1 . Has transactions
36
+ - That are signed
37
+ - That can optionally have gas semantics (limits and prices, expressed in a blockchain specific way)
38
+ 2 . Has events (or "logs")
39
+ - That are emitted as a deterministic outcome of transactions
40
+ 3 . Has blocks
41
+ - Containing zero or more transactions, with their associated events
42
+ - With a sequential numeric order
43
+ - With a hash
44
+ - With a parent hash
45
+ 4 . Has finality for transactions & events that can be expressed as a level of confidence over time
46
+ - Confirmations: A number of sequential blocks in the canonical chain that contain the transaction
47
+
48
+ ## Nonce management
49
+
50
+ The nonces for transactions is assigned as early as possible in the flow:
51
+ - Before the REST API for submission of the transaction occurs
52
+ - After the FFCAPI blockchain connector verifies the transaction can be encoded successfully to the chain
53
+ - With protection against multiple parallel API requests for the same signing address
54
+ - With stateful persistence meaning the connector knows about all nonces it previously allocated, to avoids duplicates
55
+
56
+ This "at source" allocation of nonces provides the strictest assurance of order of transactions possible,
57
+ because the order is locked in with the coordination of the business logic of the application submitting the transaction.
58
+
59
+ As well as protecting against loss of transactions, this protects against duplication of transactions - even in crash
60
+ recovery scenarios with a sufficiently reliable persistence layer.
61
+
62
+ ### Avoid multiple nonce management systems against the same signing key
63
+
64
+ FFTM is optimized for cases where all transactions for a given signing address flow through the
65
+ same FireFly connector. If you have signing and nonce allocation happening elsewhere, not going through the
66
+ FireFly blockchain connector, then it is possible that the same nonce will be allocated in two places.
67
+
68
+ > Be careful that the signing keys for transactions you stream through the Nonce Management of the FireFly
69
+ > blockchain connector are not used elsewhere.
70
+
71
+ If you must have multiple systems performing nonce management against the same keys you use with FireFly nonce management,
72
+ you can set the ` transactions.nonceStateTimeout ` to ` 0 ` (or a low threshold like ` 100ms ` ) to cause the nonce management
73
+ to query the pending transaction pool of the node every time a nonce is allocated.
74
+
75
+ This reduces the window for concurrent nonce allocation to be small (basically the same as if you had
76
+ multiple simple web/mobile wallets used against the same key), but it does not eliminate it completely it.
77
+
78
+ ### Why "at source" nonce management was chosen vs. "at target"
79
+
80
+ The "at source" approach to ordering used in FFTM could be compared with the "at target" allocation of nonces used in
81
+ [ EthConnect] ( https://github.com/hyperledger/firefly-ethconnect ) ).
82
+
83
+ The "at target" approach optimizes for throughput and ability to send new transactions to the chain,
84
+ with an at-least-once delivery assurance to the applications.
85
+
86
+ An "at target" algorithm as used in EthConnect could resume transaction delivery automatically without operator intervention
87
+ from almost all scenarios, including where nonces have been double allocated.
88
+
89
+ However, "at target" comes with two compromises that mean FFTM chose the "at source" approach was chosen for FFTM:
90
+
91
+ - Individual transactions might fail in certain scenarios, and subsequent transactions will still be streamed to the chain.
92
+ While desirable for automation and throughput, this reduces the ordering guarantee for high value transactions.
93
+
94
+ - In crash recovery scenarios the assurance is at-least-once delivery for "at target" ordering (rather than "exactly once"),
95
+ although the window can be made very small through various optimizations included in the EthConnect codebase.
96
+
97
+ ## Policy Manager
98
+
99
+ > TODO: Add more detail to describe the pluggability of the Policy Manager component, to perform transaction gas price
100
+ > estimation, advanced monitoring of transactions, submission and re-submission of the transactions with updated
101
+ > parameters (such as gas price) etc.
102
+
103
+ ## Event streaming
104
+
105
+ One of the most sophisticated parts of the FireFly Connector Framework is the handling of event streams.
106
+
107
+ > TODO: More detail to back up this diagram.
108
+
109
+ [ ![ Event Streams] ( ./images/fftm_event_streams_architecture.jpg )] ( ./images/fftm_event_streams_architecture.jpg )
25
110
26
111
# Configuration
27
112
0 commit comments