iuna

iuna

iuna - experimental mainnet-candidate protocol
git clone https://getiuna.org/git/iuna.git
Log | Files | Refs | README | LICENSE

commit 1e0f6c7e259f628017cdf02b43a7a5315b8aa585
parent ed480eea0d5dd63b3596aa592884d62e1c9e5b9a
Author: Joris Hartog <jorishartog@hotmail.com>
Date:   Thu, 10 Sep 2026 06:30:33 +0200

fix(p2p): honor local profile during initial sync

Diffstat:
Msrc/adapters/p2p/fetch.rs | 5+++--
Msrc/main.rs | 28+++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/adapters/p2p/fetch.rs b/src/adapters/p2p/fetch.rs @@ -20,7 +20,7 @@ use super::{ }; pub async fn fetch_snapshot(peer: &str) -> Result<ChainSnapshot> { - fetch_snapshot_with_announcement(peer, None).await + fetch_snapshot_with_announcement(peer, None, &LaunchProfile::default().profile_id).await } pub async fn fetch_peer_height(peer: &str) -> Result<u64> { @@ -71,6 +71,7 @@ async fn fetch_peer_status(peer: &str) -> Result<PeerStatus> { pub async fn fetch_snapshot_with_announcement( peer: &str, _advertised_addr: Option<SocketAddr>, + expected_profile_id: &str, ) -> Result<ChainSnapshot> { let stream = TcpStream::connect(peer) .await @@ -105,7 +106,7 @@ pub async fn fetch_snapshot_with_announcement( write_envelope(&mut writer, &join_client_hello()).await?; write_envelope(&mut writer, &GossipEnvelope::ChainBootstrapRequest).await?; let bootstrap = read_join_bootstrap_response(peer, &mut reader).await?; - validate_bootstrap_genesis(&LaunchProfile::default().profile_id, &bootstrap)?; + validate_bootstrap_genesis(expected_profile_id, &bootstrap)?; let mut snapshot = ChainSnapshot { genesis_allocations: bootstrap.genesis_allocations, diff --git a/src/main.rs b/src/main.rs @@ -641,7 +641,19 @@ async fn initialize_ledger( let ledger = match opts.chain_mode { ChainMode::Setup => Ok(setup_ledger(local_testnet)), ChainMode::Genesis => start_genesis_ledger(wallet_address, local_testnet), - ChainMode::Join => join_chain_ledger(&opts.join_peers, advertised_p2p_addr).await, + ChainMode::Join => { + let expected_profile = if local_testnet { + LaunchProfile::local_testnet() + } else { + LaunchProfile::default() + }; + join_chain_ledger( + &opts.join_peers, + advertised_p2p_addr, + &expected_profile.profile_id, + ) + .await + } }?; Ok(InitializedLedger { ledger, @@ -772,10 +784,20 @@ fn extrapolate_vdf_rounds(measured_rounds: u64, elapsed: Duration, target: Durat rounds.min(u128::from(MAX_VDF_ROUNDS)) as u64 } -async fn join_chain_ledger(join_peers: &[String], advertised_addr: SocketAddr) -> Result<Ledger> { +async fn join_chain_ledger( + join_peers: &[String], + advertised_addr: SocketAddr, + expected_profile_id: &str, +) -> Result<Ledger> { let mut errors = Vec::new(); for peer in join_peers { - match p2p::fetch_snapshot_with_announcement(peer, Some(advertised_addr)).await { + match p2p::fetch_snapshot_with_announcement( + peer, + Some(advertised_addr), + expected_profile_id, + ) + .await + { Ok(snapshot) => { let height = snapshot .blocks