Represent cellular profile migration manifests
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (checks) (push) Failing after 11m27s
Foundation / checks (network) (push) Failing after 9m31s
Foundation / checks (client) (push) Successful in 13m14s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 1m57s
Foundation / checks (tsan) (push) Canceled after 1m49s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (checks) (push) Failing after 11m27s
Foundation / checks (network) (push) Failing after 9m31s
Foundation / checks (client) (push) Successful in 13m14s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 1m57s
Foundation / checks (tsan) (push) Canceled after 1m49s
This commit is contained in:
@@ -140,6 +140,14 @@ successor_manifest(const CheckpointManifest& predecessor, const Sha256Digest& pr
|
|||||||
Uuid commit, const LeaseGrant& lease, std::uint64_t end_tick,
|
Uuid commit, const LeaseGrant& lease, std::uint64_t end_tick,
|
||||||
const Sha256Digest& build, std::uint64_t payload_bytes,
|
const Sha256Digest& build, std::uint64_t payload_bytes,
|
||||||
const Sha256Digest& payload_sha256, const BatchDigests& batch);
|
const Sha256Digest& payload_sha256, const BatchDigests& batch);
|
||||||
|
// The only supported cellular profile transition: a leased, no-tick v1-to-v2
|
||||||
|
// representation migration. SQL publication must independently verify the pair.
|
||||||
|
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||||
|
cellular_profile_migration_manifest(const CheckpointManifest& predecessor,
|
||||||
|
const Sha256Digest& predecessor_digest, Uuid commit,
|
||||||
|
const LeaseGrant& lease, const Sha256Digest& build,
|
||||||
|
std::uint64_t payload_bytes,
|
||||||
|
const Sha256Digest& payload_sha256);
|
||||||
|
|
||||||
// Fully restores payload bytes (envelope checksum, bounds and replay audit), then
|
// Fully restores payload bytes (envelope checksum, bounds and replay audit), then
|
||||||
// requires manifest identity, end tick, tick quantum, envelope format 2 and a
|
// requires manifest identity, end tick, tick quantum, envelope format 2 and a
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ bool structural(const CheckpointManifest& m) noexcept {
|
|||||||
const auto& b = m.batch;
|
const auto& b = m.batch;
|
||||||
const bool primitive = m.profile == CheckpointProfile::primitive_lives_v1;
|
const bool primitive = m.profile == CheckpointProfile::primitive_lives_v1;
|
||||||
const bool cellular = m.profile == CheckpointProfile::cellular_lives_v1;
|
const bool cellular = m.profile == CheckpointProfile::cellular_lives_v1;
|
||||||
|
const bool cellular_migration =
|
||||||
|
cellular && m.sequence > 0 && m.cellular_versions == cellular_v2_versions &&
|
||||||
|
m.begin_tick == m.end_tick && m.end_tick > 0 && b == BatchDigests{};
|
||||||
if ((!cellular && m.cellular_versions != cellular_v1_versions) ||
|
if ((!cellular && m.cellular_versions != cellular_v1_versions) ||
|
||||||
(cellular && m.cellular_versions != cellular_v1_versions &&
|
(cellular && m.cellular_versions != cellular_v1_versions &&
|
||||||
m.cellular_versions != cellular_v2_versions) ||
|
m.cellular_versions != cellular_v2_versions) ||
|
||||||
@@ -91,10 +94,12 @@ bool structural(const CheckpointManifest& m) noexcept {
|
|||||||
}
|
}
|
||||||
const bool link = !zero(m.predecessor_commit) && m.predecessor_commit != m.commit &&
|
const bool link = !zero(m.predecessor_commit) && m.predecessor_commit != m.commit &&
|
||||||
!zero(m.predecessor_digest) && !zero(m.holder) && m.epoch != 0 &&
|
!zero(m.predecessor_digest) && !zero(m.holder) && m.epoch != 0 &&
|
||||||
m.end_tick > m.begin_tick &&
|
(m.end_tick > m.begin_tick || cellular_migration) &&
|
||||||
m.end_tick - m.begin_tick <= max_checkpoint_ticks;
|
m.end_tick - m.begin_tick <= max_checkpoint_ticks;
|
||||||
if (m.manifest_version == 1)
|
if (m.manifest_version == 1)
|
||||||
return link && no_batch;
|
return link && no_batch;
|
||||||
|
if (cellular_migration)
|
||||||
|
return link;
|
||||||
const auto ticks = m.end_tick - m.begin_tick;
|
const auto ticks = m.end_tick - m.begin_tick;
|
||||||
const auto cellular_legacy_min =
|
const auto cellular_legacy_min =
|
||||||
server::cellular_batch_header_bytes + ticks * sizeof(std::uint32_t);
|
server::cellular_batch_header_bytes + ticks * sizeof(std::uint32_t);
|
||||||
@@ -342,6 +347,37 @@ successor_manifest(const CheckpointManifest& p, const Sha256Digest& predecessor_
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::expected<CheckpointManifest, CheckpointError> cellular_profile_migration_manifest(
|
||||||
|
const CheckpointManifest& p, const Sha256Digest& predecessor_digest, Uuid commit,
|
||||||
|
const LeaseGrant& lease, const Sha256Digest& build, std::uint64_t payload_bytes,
|
||||||
|
const Sha256Digest& payload_sha256) {
|
||||||
|
if (!supported(p))
|
||||||
|
return std::unexpected{CheckpointError::unsupported};
|
||||||
|
if (!structural(p) || p.profile != CheckpointProfile::cellular_lives_v1 ||
|
||||||
|
p.cellular_versions != cellular_v1_versions || p.sequence == 0 || p.sequence == maximum ||
|
||||||
|
p.end_tick == 0 || lease.frame != p.frame || lease.holder == Uuid{} || lease.epoch == 0 ||
|
||||||
|
predecessor_digest == Sha256Digest{} || commit == Uuid{} || commit == p.commit ||
|
||||||
|
build == Sha256Digest{} || payload_bytes == 0 || payload_sha256 == Sha256Digest{})
|
||||||
|
return std::unexpected{CheckpointError::chain};
|
||||||
|
CheckpointManifest m = p;
|
||||||
|
m.commit = commit;
|
||||||
|
m.sequence = p.sequence + 1;
|
||||||
|
m.predecessor_commit = p.commit;
|
||||||
|
m.predecessor_digest = predecessor_digest;
|
||||||
|
m.begin_tick = p.end_tick;
|
||||||
|
m.end_tick = p.end_tick;
|
||||||
|
m.holder = lease.holder;
|
||||||
|
m.epoch = lease.epoch;
|
||||||
|
m.build = build;
|
||||||
|
m.payload_bytes = payload_bytes;
|
||||||
|
m.payload_sha256 = payload_sha256;
|
||||||
|
m.cellular_versions = cellular_v2_versions;
|
||||||
|
m.batch = {};
|
||||||
|
if (!structural(m))
|
||||||
|
return std::unexpected{CheckpointError::format};
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
std::expected<std::unique_ptr<processes::EnvironmentalCommunity>, CheckpointError>
|
std::expected<std::unique_ptr<processes::EnvironmentalCommunity>, CheckpointError>
|
||||||
restore_environmental_payload(std::span<const std::uint8_t> payload, const CheckpointManifest& m,
|
restore_environmental_payload(std::span<const std::uint8_t> payload, const CheckpointManifest& m,
|
||||||
std::size_t budget) {
|
std::size_t budget) {
|
||||||
|
|||||||
@@ -880,9 +880,18 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
|||||||
const auto genome = archive->find(life.identity.genome);
|
const auto genome = archive->find(life.identity.genome);
|
||||||
if (!genome)
|
if (!genome)
|
||||||
return std::unexpected{CellularLivesError::archive};
|
return std::unexpected{CellularLivesError::archive};
|
||||||
const auto generated =
|
const auto& offer = *life.mutation.offer;
|
||||||
biology::mutation_candidates(*genome, life.mutation.offer->context);
|
if (life.mutation.event_index == 0 || life.mutation.offer_tick == 0 ||
|
||||||
if (!generated || *generated != *life.mutation.offer)
|
life.mutation.offer_tick > saved_tick || offer.parent != life.identity.genome ||
|
||||||
|
offer.context.seed != mutation_seed(saved_world, saved_region, life.identity.life,
|
||||||
|
life.mutation.event_index) ||
|
||||||
|
offer.context.stream != cellular_mutation_stream ||
|
||||||
|
offer.context.event_index != life.mutation.event_index ||
|
||||||
|
offer.context.environment.temperature_millikelvin !=
|
||||||
|
config.ambient_temperature_millikelvin)
|
||||||
|
return std::unexpected{CellularLivesError::noncanonical};
|
||||||
|
const auto generated = biology::mutation_candidates(*genome, offer.context);
|
||||||
|
if (!generated || *generated != offer)
|
||||||
return std::unexpected{CellularLivesError::noncanonical};
|
return std::unexpected{CellularLivesError::noncanonical};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,6 +265,14 @@ void retained_feeding_earns_a_persistent_mutation_offer() {
|
|||||||
const auto saved = owner.snapshot();
|
const auto saved = owner.snapshot();
|
||||||
const auto recovered = CellularLives::restore(saved, 93, 1, 1, owner.tick());
|
const auto recovered = CellularLives::restore(saved, 93, 1, 1, owner.tick());
|
||||||
CHECK(recovered && (*recovered)->snapshot() == saved);
|
CHECK(recovered && (*recovered)->snapshot() == saved);
|
||||||
|
auto changed_seed = saved;
|
||||||
|
constexpr std::size_t v2_header_and_single_site = 220;
|
||||||
|
constexpr std::size_t v1_life_bytes = 168;
|
||||||
|
constexpr std::size_t mutation_seed_offset = 40;
|
||||||
|
changed_seed[v2_header_and_single_site + v1_life_bytes + mutation_seed_offset] ^= 1U;
|
||||||
|
refresh_checksum(changed_seed);
|
||||||
|
const auto noncanonical = CellularLives::restore(changed_seed, 93, 1, 1, owner.tick());
|
||||||
|
CHECK(!noncanonical && noncanonical.error() == CellularLivesError::noncanonical);
|
||||||
const auto replayed_offer = (*recovered)->mutation_offer(life_id);
|
const auto replayed_offer = (*recovered)->mutation_offer(life_id);
|
||||||
CHECK(replayed_offer && replayed_offer == earned);
|
CHECK(replayed_offer && replayed_offer == earned);
|
||||||
const std::array idle{CellularLifeIntent{life_id, {}}};
|
const std::array idle{CellularLifeIntent{life_id, {}}};
|
||||||
|
|||||||
@@ -457,6 +457,31 @@ void cellular_profile() {
|
|||||||
++bad_versions.cellular_versions.archive;
|
++bad_versions.cellular_versions.archive;
|
||||||
CHECK(!supported(bad_versions));
|
CHECK(!supported(bad_versions));
|
||||||
CHECK(!restore_cellular_payload(payload, bad_versions));
|
CHECK(!restore_cellular_payload(payload, bad_versions));
|
||||||
|
|
||||||
|
const auto legacy_genesis =
|
||||||
|
genesis_manifest(key, 9, filled<16>(0x10), 50000, build, payload.size(), filled<32>(0x11),
|
||||||
|
CheckpointProfile::cellular_lives_v1);
|
||||||
|
CHECK(legacy_genesis);
|
||||||
|
const auto legacy_head =
|
||||||
|
successor_manifest(*legacy_genesis, filled<32>(0x12), filled<16>(0x13), lease(), 1, build,
|
||||||
|
payload.size(), filled<32>(0x14), batch_for(1, 1));
|
||||||
|
CHECK(legacy_head && legacy_head->cellular_versions == cellular_v1_versions);
|
||||||
|
const auto migration =
|
||||||
|
cellular_profile_migration_manifest(*legacy_head, filled<32>(0x15), filled<16>(0x16),
|
||||||
|
lease(), build, payload.size(), filled<32>(0x17));
|
||||||
|
CHECK(migration && supported(*migration) && migration->sequence == 2 &&
|
||||||
|
migration->begin_tick == 1 && migration->end_tick == 1 &&
|
||||||
|
migration->cellular_versions == cellular_v2_versions &&
|
||||||
|
migration->batch == BatchDigests{});
|
||||||
|
const auto migration_bytes = encode_manifest(*migration);
|
||||||
|
CHECK(migration_bytes && decode_manifest(*migration_bytes) == *migration);
|
||||||
|
CHECK(!cellular_profile_migration_manifest(*migration, filled<32>(0x18), filled<16>(0x19),
|
||||||
|
lease(), build, payload.size(), filled<32>(0x20)));
|
||||||
|
const auto after_migration =
|
||||||
|
successor_manifest(*migration, filled<32>(0x21), filled<16>(0x22), lease(), 2, build,
|
||||||
|
payload.size(), filled<32>(0x23), batch_for(1, 1));
|
||||||
|
CHECK(after_migration && after_migration->cellular_versions == cellular_v2_versions);
|
||||||
|
|
||||||
auto bad_identity = *manifest;
|
auto bad_identity = *manifest;
|
||||||
bad_identity.key.region = 4;
|
bad_identity.key.region = 4;
|
||||||
const auto wrong_identity = restore_cellular_payload(payload, bad_identity);
|
const auto wrong_identity = restore_cellular_payload(payload, bad_identity);
|
||||||
|
|||||||
Reference in New Issue
Block a user