Commit a6a0503
Base layer actions (#485)
Everything starts when a scheduled Intent arrives...
# Architecture
## Schedulers
We can't directly spawn bunch of **IntentExecutor**s. The reason is that
one message can block execution of another message. To handle this the
messages have to go through Scheduling.
Details: Once message make it to
`CommittorProcessor::schedule_base_intents` it outsources intent to
tokio task `IntentExecutionEngine` which figures out a scheduling.
## IntentExecutionEngine
Accepts new messages, schedules them, and spawns up to 50 parallel
**IntentExecutor**s for each Intent. Once a particular
**IntentExecutor** finishes execution we broadcast result to
subscribers, like: `RemoteScheduledCommitsProcessor` or
`ExternalAccountsManager`
details: For scheduling logic see **IntentScheduler**. Number of
parallel **IntentExecutor** is controller by Semaphore.
## IntentExecutor
IntentExecutor - responsible for execution of Intent. Calls
**TransactionPreparator** and then executes a transaction returning as
result necessary signatures
## TransactionPreparator
TransactionPreparator - is an entity that handles all of the above
"Transaction preparation" calling **TaskBuilderV1**, **TaskStrategist**,
**DeliveryPreparator** and then assempling it all and passing to
**MessageExecutor**
## DeliveryPreparator
After our **L1Task**s are ready we need to prepare eveything for their
successful execution. **DeliveryPreparator** - handles ALTs and commit
buffers
## TaskBuilder
First, lets build atomic tasks from scheduled message/intent.
High level: TaskBuilder responsible for creating L1Tasks(to be
renamed...) from ScheduledL1Message(to be renamed...).
Details: To do that is requires additional information from
DelegationMetadata, it is provided **CommitIdFetcher**
### L1Task
High level: L1Task - is an atomic operation that is to be performed on
the Base layer, like: Commit, Undelegate, Finalize, Action.
Details: There's to implementation of L1Tasks: ArgsTask, BufferTask.
ArgsTask - gives instruction using args. BufferTask - gives instruction
using buffer. BufferTask at the moment supports only commits
### CommitIdFetcher
High level: for account to be accepted by dlp it needs to have
incremental commit ids. CommitIdFetcher provides a user with the correct
ids/nonces for set of committees
Details: CommitIdTracker - implementation of CommitIdFetcher, that
caches and locally increments commit ids using LruCache
## TaskStrategist
After our tasks were built with **TaskBuilder**, they need to be
optimized to fit into transaction. That what TaskStrategist does.
Details: Initially **TaskBuilder** builds ArgsTasks, **TaskStrategist**
if needed optimzes them to BufferTask.
### Changes
- Persister changed from reqid & bundle_id format to message_id. Meaning
row created per message. A particular Row tracking lifespan of Intent
- Persister will be passed along into Executors & Scheduler for them to
update Intent statuses during execution
- No notion of bundles anymore, we represent things by Intent id
- AccountsManager doesn't use custom `AccountCommitter` for periodic
commits of accounts but instead uses CommittorService
- RemoteScheduledCommitsProcessor extracted from AccountsManager since
has nothing to do with it
# Benchmarks
Using the same config as in this
[PR](#366)
Here's best result on master I got on my machine:
```
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Metric | Observations | Median | Min | Max | Avg | 95th Perc | Stddev |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| sendTransaction Response (μs) | 2000 | 3401 | 1499 | 23918 | 3543 | 5079 | 1244 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Account Update (μs) | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Signature Confirmation (μs) | 2000 | 3460 | 1520 | 13509 | 3609 | 5430 | 1123 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Transactions Per Second (TPS) | 51 | 40 | 40 | 40 | 40 | 40 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Requests Per Second (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| getX Request Response (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
```
Here's the best result on feat/base-layer-ix/main which is current PR on
review
```
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Metric | Observations | Median | Min | Max | Avg | 95th Perc | Stddev |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| sendTransaction Response (μs) | 2000 | 3241 | 1450 | 17898 | 3397 | 4907 | 954 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Account Update (μs) | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Signature Confirmation (μs) | 2000 | 3332 | 1504 | 17947 | 3517 | 5187 | 988 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Transactions Per Second (TPS) | 51 | 40 | 40 | 40 | 40 | 40 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Requests Per Second (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| getX Request Response (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
```
So results are almost the same, but current `feat/base-layer-ix/main`
sends 2 txs for commit & finalize, while master sends 1.
Here's results on optimized branch feat/base-layer-ix/single-tx-intent
which sends just 1 tx as well. We get ~13% increase in performance on
our trait fuel
```
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Metric | Observations | Median | Min | Max | Avg | 95th Perc | Stddev |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| sendTransaction Response (μs) | 2000 | 2896 | 1360 | 14462 | 3050 | 4619 | 1060 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Account Update (μs) | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Signature Confirmation (μs) | 2000 | 2977 | 1376 | 15452 | 3149 | 4916 | 1149 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Transactions Per Second (TPS) | 51 | 40 | 40 | 40 | 40 | 40 | 0 |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| Requests Per Second (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
| getX Request Response (TPS) | --- | --- | --- | --- | --- | --- | --- |
+-------------------------------+--------------+--------+------+-------+------+-----------+--------+
```
---------
Co-authored-by: Thorsten Lorenz <thlorenz@gmx.de>
Co-authored-by: Dodecahedr0x <90185028+Dodecahedr0x@users.noreply.github.com>
Co-authored-by: Arthur Bretas <158767751+BretasArthur1@users.noreply.github.com>
Co-authored-by: Dodecahedr0x <hexadecifish@gmail.com>
Co-authored-by: Gabriele Picco <piccogabriele@gmail.com>1 parent 5eafcf7 commit a6a0503
File tree
166 files changed
+12450
-9016
lines changed- magicblock-account-cloner
- src
- magicblock-account-dumper/src
- magicblock-accounts-api/src
- magicblock-accounts
- src
- tests
- stubs
- magicblock-api/src
- magicblock-bank/src
- magicblock-committor-program
- bin
- src
- instruction_builder
- state
- utils
- tests
- magicblock-committor-service
- src
- commit
- intent_execution_manager
- intent_executor
- persist
- types
- stubs
- tasks
- task_visitors
- transaction_preparator
- magicblock-core
- src
- magic_program
- magicblock-ledger/src/database
- magicblock-metrics/src/metrics
- magicblock-mutator/src
- magicblock-rpc-client/src
- magicblock-table-mania/src
- programs/magicblock/src
- mutate_accounts
- schedule_transactions
- utils
- test-integration
- configs
- programs
- flexi-counter/src
- processor
- schedulecommit
- src
- schedulecommit
- elfs
- test-scenarios/tests
- utils
- test-security/tests
- utils
- test-committor-service
- src
- tests
- utils
- test-config/tests
- test-magicblock-api
- tests
- test-runner/bin
- test-schedule-intent
- src
- tests
- test-tools/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
166 files changed
+12450
-9016
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | 69 | | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
103 | 105 | | |
| 106 | + | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
| |||
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
121 | | - | |
122 | | - | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
159 | | - | |
160 | 161 | | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
164 | 165 | | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | | - | |
179 | 180 | | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| 186 | + | |
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
188 | | - | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | | - | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
103 | 115 | | |
104 | 116 | | |
105 | 117 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
740 | | - | |
| 740 | + | |
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
744 | | - | |
745 | 744 | | |
746 | 745 | | |
747 | 746 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | 184 | | |
186 | 185 | | |
187 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
9 | 12 | | |
0 commit comments