M12.4: isolate continued population replay after transfer
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 14m44s
Foundation / checks (checks) (push) Canceled after 14m44s
Foundation / checks (network) (push) Canceled after 14m43s
Foundation / checks (postgres) (push) Canceled after 14m42s
Foundation / checks (tsan) (push) Canceled after 14m43s

This commit is contained in:
dingo
2026-10-17 22:07:47 -04:00
parent 1e207b5ee4
commit 89f29fef3a
13 changed files with 209 additions and 10 deletions
+57
View File
@@ -153,6 +153,13 @@ CellularMigrationRequest request_for(const CellularLives& source, const Cellular
{target.region(), filled<16>(2), filled<16>(4), filled<32>(6)},
wildlife_genome(source)};
}
CellularPopulationExecution continuation(const CellularPopulation& population) {
const auto& s = population.state();
const CellularBatchHeader header{s.world(), s.region(), s.frame(), filled<16>(9),
filled<32>(10), s.tick(), s.tick() + 64};
auto inputs = checked(unattended_population_inputs(s, header), "transferred interval inputs");
return checked(prepare_population_batch(population, std::move(inputs)), "transferred interval");
}
void trace_contract() {
auto source = checked(funded()->migration_upgrade_candidate(), "trace source");
auto target = checked(destination(*source, 1)->migration_upgrade_candidate(), "trace target");
@@ -250,6 +257,46 @@ void trace_contract() {
require(!replay_migration_trace(*population, *peer, request, trace) &&
!replay_migration_trace(*source, *target, request, pop_trace),
"trace representation confused");
for (const auto* owner : {pop_replayed.source.get(), pop_replayed.destination.get()}) {
const auto bytes_before = owner->snapshot();
const auto ledger_before = owner->state().boundary_ledger();
auto interval = continuation(*owner);
require(interval.batch.format_version == 2, "new owner recorded old trace version");
const auto encoded =
checked(encode_population_batch(interval.batch), "encode new interval");
const auto decoded = checked(decode_population_batch(encoded), "decode new interval");
auto replay = checked(replay_population_batch(*owner, decoded), "replay new interval");
require(replay->snapshot() == interval.state->snapshot() &&
replay->state().boundary_ledger() == ledger_before &&
replay->state().current_total() == owner->state().current_total() &&
owner->snapshot() == bytes_before,
"new interval changed flows/history or failed exact replay");
auto legacy = decoded;
legacy.format_version = 1;
require(!replay_population_batch(*owner, legacy), "old trace reinterpreted for owner 7");
auto malformed = encoded;
malformed[7] = '1';
require(!decode_population_batch(malformed),
"new population trace magic/version confusion");
if (!owner->members().empty()) {
const auto& s = owner->state();
const CellularBatchHeader h{s.world(), s.region(), s.frame(), filled<16>(9),
filled<32>(10), s.tick(), s.tick()};
auto conversion = checked(
prepare_population_conversion(*owner, h, {owner->members().front().genome, false}),
"new manual trace");
const auto manual =
checked(decode_population_batch(checked(encode_population_batch(conversion.batch),
"new manual encode")),
"new manual decode");
auto materialized =
checked(replay_population_batch(*owner, manual), "new manual replay");
require(manual.format_version == 2 &&
materialized->state().snapshot() == s.snapshot() &&
materialized->members().empty(),
"new conversion changed exact biology");
}
}
require(source->snapshot() == before && target->snapshot() == peer_before,
"trace validation changed its input");
}
@@ -293,6 +340,10 @@ void record_restart(const std::string& prefix) {
checked(encode_migration_trace(pop.trace), "restart pop trace"));
write_bytes(prefix + ".pop.source.expected", pop.execution.source->snapshot());
write_bytes(prefix + ".pop.destination.expected", pop.execution.destination->snapshot());
auto interval = continuation(*pop.execution.destination);
write_bytes(prefix + ".pop.continuation.trace",
checked(encode_population_batch(interval.batch), "restart interval trace"));
write_bytes(prefix + ".pop.continuation.expected", interval.state->snapshot());
}
void replay_restart(const std::string& prefix) {
const auto raw =
@@ -321,6 +372,12 @@ void replay_restart(const std::string& prefix) {
"fresh population replay");
write_bytes(prefix + ".pop.source.resumed", pop_replayed.source->snapshot());
write_bytes(prefix + ".pop.destination.resumed", pop_replayed.destination->snapshot());
const auto interval =
checked(decode_population_batch(read_bytes(prefix + ".pop.continuation.trace")),
"fresh interval trace");
auto continued = checked(replay_population_batch(*pop_replayed.destination, interval),
"fresh transferred continuation");
write_bytes(prefix + ".pop.continuation.resumed", continued->snapshot());
}
void upgrade_and_move() {
auto original = funded();