Skip to content

Commit 8869f17

Browse files
authored
Merge pull request #649 from openmina/develop
Merge `develop` into `main`
2 parents f49581c + 8d4d09e commit 8869f17

File tree

166 files changed

+3720
-1166
lines changed

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

+3720
-1166
lines changed

.github/workflows/docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
runs-on: ubuntu-arm64
124124
configuration:
125125
- build_configuration: compose
126-
- build_configuration: block_producers
126+
- build_configuration: staging
127127
runs-on: ${{ matrix.arch.runs-on }}
128128
steps:
129129
- name: Prepare
@@ -175,7 +175,7 @@ jobs:
175175
configuration:
176176
- build_configuration: compose
177177
tag_suffix: ""
178-
- build_configuration: block_producers
178+
- build_configuration: staging
179179
tag_suffix: "-producer-demo"
180180
runs-on: ubuntu-latest
181181
needs:

ARCHITECTURE.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,3 +860,93 @@ if let Some((callback, block_hash)) = callback_and_arg {
860860

861861
dispatcher.push(SnarkBlockVerifyAction::Finish { req_id: *req_id });
862862
```
863+
864+
#### Callbacks instead of conditional dispatches
865+
866+
A common pattern seen in the current code is conditional dispatches:
867+
868+
```rust
869+
if store.dispatch(SomeAction) {
870+
store.dispatch(SomeOtherAction);
871+
}
872+
```
873+
874+
The equivalent with queueing is to use `dispatcher.push_if_enabled` which will return `true` if the enabling condition for that action returns `true`. This will work most of the time, but it is possible for the state to change between the time the action was enqueued and when it is finally going to be dispatched, so the enabling condition may not be `true` anymore. This means that the equivalence is not strict.
875+
876+
A better approach is to add a callback to the first action. This ensures that the second action only happens when intended, avoiding the potential race condition of the state changing between enqueuing and dispatching.
877+
878+
First a callback is added to the action:
879+
880+
```diff
881+
#[derive(Serialize, Deserialize, Debug, Clone)]
882+
pub enum LedgerWriteAction {
883+
- Init { request: LedgerWriteRequest },
884+
+ Init {
885+
+ request: LedgerWriteRequest,
886+
+ on_init: redux::Callback<LedgerWriteRequest>,
887+
+ },
888+
Pending,
889+
// ...
890+
```
891+
892+
Then in the handling code is updated to dispatch the callback:
893+
894+
```diff
895+
match action {
896+
LedgerAction::Write(a) => match a {
897+
- LedgerWriteAction::Init { request } => {
898+
- store.service.write_init(request);
899+
+ LedgerWriteAction::Init { request, on_init } => {
900+
+ store.service.write_init(request.clone());
901+
store.dispatch(LedgerWriteAction::Pending);
902+
+ store.dispatch_callback(on_init, request);
903+
}
904+
```
905+
906+
Finally the dispatching of that action is update to provide a callback that will return the same action that was inside the body of the conditional dispatch:
907+
908+
```diff
909+
- if store.dispatch(LedgerWriteAction::Init {
910+
+ store.dispatch(LedgerWriteAction::Init {
911+
request: LedgerWriteRequest::StagedLedgerDiffCreate {
912+
pred_block: pred_block.clone(),
913+
global_slot_since_genesis: won_slot
914+
// ...
915+
supercharge_coinbase,
916+
transactions_by_fee,
917+
},
918+
- }) {
919+
- store.dispatch(BlockProducerAction::StagedLedgerDiffCreatePending);
920+
- }
921+
+ on_init: redux::callback!(
922+
+ on_staged_ledger_diff_create_init(_request: LedgerWriteRequest) -> crate::Action {
923+
+ BlockProducerAction::StagedLedgerDiffCreatePending
924+
+ }
925+
+ ),
926+
+ });
927+
```
928+
929+
In the above example the passed argument is not used, but for other callbacks it is useful. Consider this example where we need the block hash for the next action, which can be extracted from the data contained in the request:
930+
931+
```diff
932+
- if store.dispatch(LedgerWriteAction::Init {
933+
+ store.dispatch(LedgerWriteAction::Init {
934+
request: LedgerWriteRequest::BlockApply { block, pred_block },
935+
- }) {
936+
- store.dispatch(TransitionFrontierSyncAction::BlocksNextApplyPending {
937+
- hash: hash.clone(),
938+
- });
939+
- }
940+
+ on_init: redux::callback!(
941+
+ on_block_next_apply_init(request: LedgerWriteRequest) -> crate::Action {
942+
+ let LedgerWriteRequest::BlockApply { block, .. } = request
943+
+ else {
944+
+ // Cannot happen because this is the same value we passed above
945+
+ unreachable!()
946+
+ };
947+
+ let hash = block.hash().clone();
948+
+ TransitionFrontierSyncAction::BlocksNextApplyPending { hash }
949+
+ }
950+
+ ),
951+
+ });
952+
```

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.8.2] - 2024-09-06
11+
12+
### Fixed
13+
14+
- Include circuit blobs in docker images, required for block production.
15+
- Add missing bounds to ZkAppUri and TokenSymbol fields.
16+
- Various stability improvements to make sure the node will not crash in certain circumstances.
17+
18+
### Changed
19+
20+
- Root snarked ledger re-syncs now reuse the previously in-progress root snarked ledger instead of starting again from the next-epoch ledger.
21+
- Added `--libp2p-keypair=<path to json>` flag to specify encrypted secret key (with passphrase from `MINA_LIBP2P_PASS` environment variable).
22+
1023
## [0.8.1] - 2024-09-02
1124

1225
### Fixed
@@ -215,7 +228,8 @@ First public release.
215228
- Alpha version of the node which can connect and syncup to the berkeleynet network, and keep applying new blocks to maintain consensus state and ledger up to date.
216229
- Web-based frontend for the node.
217230

218-
[Unreleased]: https://github.com/openmina/openmina/compare/v0.8.1...develop
231+
[Unreleased]: https://github.com/openmina/openmina/compare/v0.8.2...develop
232+
[0.8.2]: https://github.com/openmina/openmina/releases/tag/v0.8.1...v0.8.2
219233
[0.8.1]: https://github.com/openmina/openmina/releases/tag/v0.8.0...v0.8.1
220234
[0.8.0]: https://github.com/openmina/openmina/releases/tag/v0.7.0...v0.8.0
221235
[0.7.0]: https://github.com/openmina/openmina/releases/tag/v0.6.0...v0.7.0

Cargo.lock

Lines changed: 27 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mina-poseidon = {git = "https://github.com/openmina/proof-systems", branch = "le
4646
poly-commitment = {git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf"}
4747
libp2p = { git = "https://github.com/openmina/rust-libp2p", rev = "5c44c7d9", default-features = false }
4848
vrf = { path = "vrf" }
49+
openmina-node-account = { path = "node/account" }
4950
redux = { git = "https://github.com/openmina/redux-rs.git", rev = "588dd76c", features = ["serde"] }
5051
serde = "1.0.190"
5152
serde_json = "1.0.107"

0 commit comments

Comments
 (0)