feat(persistence): admit durable funded maturation upgrades
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 2m24s
Foundation / checks (network) (push) Successful in 20m40s
Foundation / checks (client) (push) Successful in 21m57s
Foundation / checks (tsan) (push) Successful in 26m32s
Foundation / checks (postgres) (push) Successful in 1h3m17s
Foundation / checks (checks) (push) Successful in 1h14m29s
Foundation / postgres-tools (push) Successful in 34s
Foundation / server-image (push) Successful in 4m6s
Foundation / image (push) Successful in 4m52s

This commit is contained in:
dingo
2026-10-19 06:23:51 -04:00
parent a5307c768b
commit 463b091056
25 changed files with 799 additions and 74 deletions
+39 -15
View File
@@ -243,7 +243,8 @@ retry_cellular_profile_migration(Postgres& db, const CellularProfileMigrationPre
manifest->cellular_versions == cellular_v3_versions)) ||
((manifest->profile == CheckpointProfile::cellular_lives_v1 ||
manifest->profile == CheckpointProfile::cellular_population_v1) &&
manifest->cellular_versions == cellular_v10_versions)) ||
(manifest->cellular_versions == cellular_v10_versions ||
manifest->cellular_versions == cellular_v11_versions))) ||
manifest->begin_tick != manifest->end_tick || manifest->batch != BatchDigests{})
return std::unexpected{migration_failure(PublicationError::candidate, {}, {}, prepared)};
@@ -276,11 +277,12 @@ retry_cellular_profile_migration(Postgres& db, const CellularProfileMigrationPre
migration_failure(PublicationError::rejected, {}, published.error(), prepared)};
}
namespace {
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
migrate_rules_profile(Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit,
const Sha256Digest& build, milliseconds timeout, const PublishHooks& hooks,
bool maturation) {
const auto previous = decode_manifest(predecessor.manifest);
const auto previous_digest = sha256(predecessor.manifest);
if (!previous || !previous_digest || predecessor.head.digest != *previous_digest ||
@@ -292,14 +294,17 @@ migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& obj
auto source = objects.get({previous->payload_sha256, previous->payload_bytes});
if (!source)
return std::unexpected(migration_failure(PublicationError::predecessor, source.error()));
auto payload = cellular_boundary_upgrade_payload(*source, *previous);
auto payload = maturation ? cellular_maturation_upgrade_payload(*source, *previous)
: cellular_boundary_upgrade_payload(*source, *previous);
if (!payload)
return std::unexpected(migration_failure(PublicationError::candidate));
const auto digest = sha256(*payload);
if (!digest)
return std::unexpected(migration_failure(PublicationError::digest));
auto manifest = cellular_boundary_upgrade_manifest(*previous, *previous_digest, commit, lease,
build, payload->size(), *digest);
const auto derive =
maturation ? cellular_maturation_upgrade_manifest : cellular_boundary_upgrade_manifest;
auto manifest =
derive(*previous, *previous_digest, commit, lease, build, payload->size(), *digest);
if (!manifest)
return std::unexpected(migration_failure(PublicationError::candidate));
auto encoded = encode_manifest(*manifest);
@@ -312,6 +317,23 @@ migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& obj
return retry_cellular_profile_migration(db, {previous->key, commit, std::move(*encoded)},
timeout);
}
} // namespace
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
false);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_maturation_profile(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
true);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_profile_to_v2(Postgres& db, const FilesystemObjectStore& objects,
@@ -597,18 +619,20 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
// evidence above is fenced by the CURRENT lease, which may be a newer epoch.
const LeaseGrant recorded{m.holder, m.epoch, m.frame, milliseconds{0}};
const bool boundary = m.cellular_versions == cellular_v10_versions;
auto expected =
boundary ? cellular_boundary_upgrade_manifest(*source, *source_digest, m.commit, recorded,
m.build, m.payload_bytes, m.payload_sha256)
: cellular_profile_migration_manifest(*source, *source_digest, m.commit, recorded,
m.build, m.payload_bytes, m.payload_sha256);
const bool maturation = m.cellular_versions == cellular_v11_versions;
const auto derive = maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
auto expected = derive(*source, *source_digest, m.commit, recorded, m.build, m.payload_bytes,
m.payload_sha256);
if (!expected || *expected != m)
return fail(RecoveryError::history);
auto bytes = objects.get({source->payload_sha256, source->payload_bytes});
if (!bytes)
return fail(RecoveryError::tail);
if (boundary) {
auto upgraded = cellular_boundary_upgrade_payload(*bytes, *source);
if (boundary || maturation) {
auto upgraded = maturation ? cellular_maturation_upgrade_payload(*bytes, *source)
: cellular_boundary_upgrade_payload(*bytes, *source);
if (!upgraded || !std::ranges::equal(*upgraded, payload))
return fail(RecoveryError::history);
} else {