Skip to content

Conversation

@0xMimir
Copy link
Contributor

@0xMimir 0xMimir commented Dec 3, 2025

Issue #1641

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

OCaml Reference Validation Results

Repository: https://github.com/MinaProtocol/mina.git
Branch: compatible
Status: ❌ Validation failed

Click to see full validation output
Checking OCaml references against https://github.com/MinaProtocol/mina.git (branch: compatible)
Fetching current commit from compatible...
Current OCaml commit: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f

Validating references...
========================
✓ VALID: ledger/src/account/account.rs -> src/lib/mina_base/account.ml L:201-224
  ⚠ STALE COMMIT: fc6be4c58091c761f827c858229c2edf9519e941 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
❌ INVALID: ledger/src/scan_state/transaction_logic/for_tests.rs
   Code at L:2285-2285 differs between commit 5da42ccd72e791f164d4d200cf1ce300262873b3 and current branch
   Referenced: https://github.com/MinaProtocol/mina/blob/5da42ccd72e791f164d4d200cf1ce300262873b3/src/lib/transaction_logic/mina_transaction_logic.ml#L2285-L2285
   Current:    https://github.com/MinaProtocol/mina/blob/compatible/src/lib/transaction_logic/mina_transaction_logic.ml#L2285-L2285
❌ INVALID: ledger/src/scan_state/transaction_logic/for_tests.rs
   Code at L:2351-2356 differs between commit 5da42ccd72e791f164d4d200cf1ce300262873b3 and current branch
   Referenced: https://github.com/MinaProtocol/mina/blob/5da42ccd72e791f164d4d200cf1ce300262873b3/src/lib/transaction_logic/mina_transaction_logic.ml#L2351-L2356
   Current:    https://github.com/MinaProtocol/mina/blob/compatible/src/lib/transaction_logic/mina_transaction_logic.ml#L2351-L2356
❌ INVALID: ledger/src/scan_state/transaction_logic/for_tests.rs
   Code at L:2407 differs between commit 5da42ccd72e791f164d4d200cf1ce300262873b3 and current branch
   Referenced: https://github.com/MinaProtocol/mina/blob/5da42ccd72e791f164d4d200cf1ce300262873b3/src/lib/transaction_logic/mina_transaction_logic.ml#L2407-L2407
   Current:    https://github.com/MinaProtocol/mina/blob/compatible/src/lib/transaction_logic/mina_transaction_logic.ml#L2407-L2407
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/transaction_status.ml L:9-51
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/transaction_status.ml L:452-454
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/with_status.ml L:6-10
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/fee_transfer.ml L:76-80
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/fee_transfer.ml L:68-69
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/mina_base/coinbase.ml L:17-21
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/mod.rs -> src/lib/transaction/transaction.ml L:8-11
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:34-48
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/stake_delegation.ml L:11-13
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:179-181
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:239-243
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)
✓ VALID: ledger/src/scan_state/transaction_logic/signed_command.rs -> src/lib/mina_base/signed_command_payload.ml L:352-362
  ⚠ STALE COMMIT: 5da42ccd72e791f164d4d200cf1ce300262873b3 (current: 7b400877e1ba0c7ad1b8277d820471c9d954cc9f)

Summary
=======
Total references found: 16
Valid references: 13
Invalid references: 3
Stale commits: 13

❌ Validation failed: 3 invalid reference(s) found

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

✓ Code Reference Verification Passed

All code references in the documentation have been verified successfully!

Total references checked: 1
Valid references: 1

The documentation is in sync with the codebase on the develop branch.

@0xMimir 0xMimir force-pushed the feat/add-exit branch 2 times, most recently from 9033737 to b7212dd Compare December 3, 2025 10:04
@0xMimir 0xMimir changed the title Added exit if initial peers are invalid Added log if initial peers are invalid Dec 3, 2025
@0xMimir 0xMimir force-pushed the feat/add-exit branch 3 times, most recently from 35f70b1 to adf6fba Compare December 3, 2025 10:44
@0xMimir 0xMimir requested a review from dannywillems December 3, 2025 12:40
@0xMimir 0xMimir force-pushed the feat/add-exit branch 2 times, most recently from 51216b4 to 38dc53f Compare December 4, 2025 08:06
@dannywillems dannywillems moved this to In Review in Rust node Dec 4, 2025
@dannywillems
Copy link
Member

Looking at it now.
Running:

cargo run \
  -r \
  --bin mina -- \
    node \
    -P /ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont

crate::core::error!(
crate::core::log::system_time();
summary = "Exiting",
error = "Invalid initial peers"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are continuously printing on the stdout:

2025-12-04T16:42:16.552063Z ERROR node::reducer: time="1764866536552054251" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:16.656957Z ERROR node::reducer: time="1764866536656948167" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:16.761831Z ERROR node::reducer: time="1764866536761823042" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:16.866726Z ERROR node::reducer: time="1764866536866719208" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:16.971191Z ERROR node::reducer: time="1764866536971179084" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.076161Z ERROR node::reducer: time="1764866537076153209" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.181250Z ERROR node::reducer: time="1764866537181236750" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.286159Z ERROR node::reducer: time="1764866537286148292" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.391037Z ERROR node::reducer: time="1764866537391026792" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.496219Z ERROR node::reducer: time="1764866537496203709" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.601182Z ERROR node::reducer: time="1764866537601171959" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.706175Z ERROR node::reducer: time="1764866537706161792" summary="Exiting" error="Invalid initial peers"
2025-12-04T16:42:17.811069Z ERROR node::reducer: time="1764866537811057709" summary="Exiting" error="Invalid initial peers"

However, it does not say which peers to remove. I know from the command I run for my test, but a user might be confused. Can you make it more explicit, please?

RpcEffectful(RpcEffectfulAction),

WatchedAccounts(WatchedAccountsAction),
Exit(ExitAction),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no documentation for the others. Could you add a one-liner please?

Also, why do you call it Exit? By reading the code, I would have expected that it is an action to kill the node. But it is simply writing an error message. It is inconsistent with what we would expect by reading the code.

if p2p.ready_peers().is_empty() && kad_state.has_bootstraped {
if let Some(tip) = &state.transition_frontier.best_tip_breadcrumb() {
// TODO: this might need to change in future
if tip.height() == 296372 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this value come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure where it comes from exactly, but when adding:

dbg!(state
                .transition_frontier
                .best_tip_breadcrumb()
                .map(|t| t.height()));

To check timeouts action and running node without internet connecting that is the value that gets printed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To anyone reading this code, this is effectively a random number as there is no explanation or description. In general, one should not have any numbers like this in the middle of a file but use a named constant instead. I don't know the best way to name, this, but anything is better than no name.

const KNOWN_PROBLEMATIC_BLOCK_HEIGHT: usize = 296_372;
// ...
if tip_height == KNOWN_PROBLEMATIC_BLOCK_HEIGHT {
// ...

CHANGELOG.md Outdated
Dashboard, documenting all endpoints and specific data fields used by the
frontend ([#1566](https://github.com/o1-labs/mina-rust/issues/1566))

- **FEATURE**: Add logging if initial peers are invalid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **FEATURE**: Add logging if initial peers are invalid
- **Feature**: Add logging if an initial peer is invalid

FEATURE -> Feature: there is no need to capitalize the word.
Plural -> singular: one initial peer is enough to have a log.

Copy link
Member

@dannywillems dannywillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@dannywillems dannywillems moved this from In Review to In Progress in Rust node Dec 4, 2025
@0xMimir 0xMimir requested a review from dannywillems December 8, 2025 07:05
@0xMimir 0xMimir moved this from In Progress to In Review in Rust node Dec 9, 2025
@dannywillems
Copy link
Member

Rebasing. I will have a look today.


crate::core::error!(
crate::core::log::system_time();
summary = "Exiting",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log says:

2025-12-15T23:50:48.379914Z ERROR node::reducer: time="1765842648379890834" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:48.488578Z ERROR node::reducer: time="1765842648488538709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:48.597485Z ERROR node::reducer: time="1765842648597445917" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:48.706593Z ERROR node::reducer: time="1765842648706558709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:48.815594Z ERROR node::reducer: time="1765842648815556709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:48.925051Z ERROR node::reducer: time="1765842648925017709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.031912Z ERROR node::reducer: time="1765842649031889709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.140310Z ERROR node::reducer: time="1765842649140283709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.249481Z ERROR node::reducer: time="1765842649249446125" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.356963Z ERROR node::reducer: time="1765842649356923751" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.465792Z ERROR node::reducer: time="1765842649465760376" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.574145Z ERROR node::reducer: time="1765842649574116709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.680850Z ERROR node::reducer: time="1765842649680816250" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.791452Z ERROR node::reducer: time="1765842649791414375" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:49.903637Z ERROR node::reducer: time="1765842649903603709" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:50.012286Z ERROR node::reducer: time="1765842650012267167" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"
2025-12-15T23:50:50.120740Z ERROR node::reducer: time="1765842650120712542" summary="Exiting" error="Invalid initial peers" initial_peers="/ip4/5.5.5.5/tcp/8302/p2p/12D3KooWAMKZM7ysxRka2RfQWxCXXFTopjZ1eZcwtSi4VPgcdont"

but it does not actually exits. @0xMimir can you fix that please?

@dannywillems dannywillems moved this from In Review to In Progress in Rust node Dec 15, 2025
Comment on lines +20 to +22
if let Some(p2p) = state.p2p.ready() {
if let Some(kad_state) = &p2p.network.scheduler.discovery_state {
if p2p.ready_peers().is_empty() && kad_state.has_bootstraped {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should almost never had this much nesting in code. Please flatten out at least some of these conditionals:

Suggested change
if let Some(p2p) = state.p2p.ready() {
if let Some(kad_state) = &p2p.network.scheduler.discovery_state {
if p2p.ready_peers().is_empty() && kad_state.has_bootstraped {
let is_bootstrapped_and_empty = state
.p2p
.ready()
.map(|state| {
let has_bootstrapped = state
.netwowrk
.scheduler
.discovery_state
.map(|s| s.has_bootstraped)
.unwrap_or_default();
state.ready_peers().is_empty() && has_bootstrapped
})
.unwrap_or_default();
if is_bootstrapped_and_empty {

if p2p.ready_peers().is_empty() && kad_state.has_bootstraped {
if let Some(tip) = &state.transition_frontier.best_tip_breadcrumb() {
// TODO: this might need to change in future
if tip.height() == 296372 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To anyone reading this code, this is effectively a random number as there is no explanation or description. In general, one should not have any numbers like this in the middle of a file but use a named constant instead. I don't know the best way to name, this, but anything is better than no name.

const KNOWN_PROBLEMATIC_BLOCK_HEIGHT: usize = 296_372;
// ...
if tip_height == KNOWN_PROBLEMATIC_BLOCK_HEIGHT {
// ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Node runs indefinitely and doesn't exit if initial peer is invalid/offline

4 participants