Format M11 cellular code with clang-format 19
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (client) (push) Failing after 4m25s
Foundation / checks (network) (push) Failing after 3m2s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m47s
Foundation / checks (postgres) (push) Canceled after 1m24s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (client) (push) Failing after 4m25s
Foundation / checks (network) (push) Failing after 3m2s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m47s
Foundation / checks (postgres) (push) Canceled after 1m24s
This commit is contained in:
@@ -23,16 +23,16 @@ CellularPublicationFailure failure(PublicationError kind, ObjectError object = {
|
||||
CellularPreparedCommit prepared = {}) {
|
||||
return {kind, store, object, std::move(prepared)};
|
||||
}
|
||||
std::expected<void, CellularPublicationFailure>
|
||||
put_verified(const FilesystemObjectStore& objects, std::span<const std::uint8_t> bytes,
|
||||
VerifiedObject expected) {
|
||||
std::expected<void, CellularPublicationFailure> put_verified(const FilesystemObjectStore& objects,
|
||||
std::span<const std::uint8_t> bytes,
|
||||
VerifiedObject expected) {
|
||||
auto stored = objects.put(bytes);
|
||||
if (!stored)
|
||||
return std::unexpected{failure(PublicationError::upload, stored.error())};
|
||||
auto readback = objects.get(*stored);
|
||||
if (!readback || *stored != expected || !std::ranges::equal(*readback, bytes))
|
||||
return std::unexpected{failure(PublicationError::verify,
|
||||
readback ? ObjectError::corrupt : readback.error())};
|
||||
return std::unexpected{
|
||||
failure(PublicationError::verify, readback ? ObjectError::corrupt : readback.error())};
|
||||
return {};
|
||||
}
|
||||
std::expected<CommittedCheckpoint, CellularPublicationFailure>
|
||||
@@ -46,28 +46,29 @@ confirm(const RegionHead& head, const CellularPreparedCommit& prepared,
|
||||
return CommittedCheckpoint{head, prepared.manifest};
|
||||
}
|
||||
bool prepared_is_canonical(const CellularPreparedCommit& prepared,
|
||||
const CheckpointManifest& manifest,
|
||||
const server::CellularBatch& trace) {
|
||||
const CheckpointManifest& manifest, const server::CellularBatch& trace) {
|
||||
const auto decoded_actions = server::decode_cellular_action_block(
|
||||
prepared.actions, manifest.begin_tick, manifest.end_tick);
|
||||
const auto encoded_actions = decoded_actions
|
||||
? server::encode_cellular_action_block(*decoded_actions, manifest.begin_tick,
|
||||
manifest.end_tick)
|
||||
: std::expected<std::vector<std::uint8_t>, server::CellularActionBlockError>{
|
||||
std::unexpected{server::CellularActionBlockError::format}};
|
||||
const auto encoded_actions =
|
||||
decoded_actions
|
||||
? server::encode_cellular_action_block(*decoded_actions, manifest.begin_tick,
|
||||
manifest.end_tick)
|
||||
: std::expected<std::vector<std::uint8_t>, server::CellularActionBlockError>{
|
||||
std::unexpected{server::CellularActionBlockError::format}};
|
||||
const auto encoded_trace = server::encode_cellular_batch(trace);
|
||||
const auto digest = sha256(prepared.trace);
|
||||
return manifest.profile == CheckpointProfile::cellular_lives_v1 &&
|
||||
manifest.key == prepared.key && manifest.commit == prepared.commit &&
|
||||
manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() &&
|
||||
digest && *digest == manifest.batch.trace_sha256 &&
|
||||
manifest.batch.decision_count == 0 &&
|
||||
manifest.batch.decisions_sha256 == Sha256Digest{} && trace.header.world == prepared.key.world &&
|
||||
trace.header.region == prepared.key.region && trace.header.frame == manifest.frame &&
|
||||
manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() && digest &&
|
||||
*digest == manifest.batch.trace_sha256 && manifest.batch.decision_count == 0 &&
|
||||
manifest.batch.decisions_sha256 == Sha256Digest{} &&
|
||||
trace.header.world == prepared.key.world && trace.header.region == prepared.key.region &&
|
||||
trace.header.frame == manifest.frame &&
|
||||
trace.header.predecessor == manifest.predecessor_commit &&
|
||||
trace.header.predecessor_digest == manifest.predecessor_digest &&
|
||||
trace.header.begin_tick == manifest.begin_tick && trace.header.end_tick == manifest.end_tick &&
|
||||
encoded_actions && *encoded_actions == prepared.actions && encoded_trace &&
|
||||
trace.header.begin_tick == manifest.begin_tick &&
|
||||
trace.header.end_tick == manifest.end_tick && encoded_actions &&
|
||||
*encoded_actions == prepared.actions && encoded_trace &&
|
||||
*encoded_trace == prepared.trace;
|
||||
}
|
||||
} // namespace
|
||||
@@ -77,16 +78,17 @@ provision_cellular_region(Postgres& owner, const FilesystemObjectStore& objects,
|
||||
std::uint64_t frame, const server::CellularLives& opening, Uuid commit,
|
||||
const Sha256Digest& build, milliseconds timeout) {
|
||||
const auto payload = opening.snapshot();
|
||||
if (opening.world() != key.world || opening.region() != key.region || opening.frame() != frame ||
|
||||
opening.tick() != 0 || !opening.lives().empty() || !opening.corpses().empty() ||
|
||||
opening.archive().recorded() != 0 || opening.archive().archived() != 0)
|
||||
if (opening.world() != key.world || opening.region() != key.region ||
|
||||
opening.frame() != frame || opening.tick() != 0 || !opening.lives().empty() ||
|
||||
!opening.corpses().empty() || opening.archive().recorded() != 0 ||
|
||||
opening.archive().archived() != 0)
|
||||
return std::unexpected{failure(PublicationError::candidate)};
|
||||
const auto digest = sha256(payload);
|
||||
if (!digest)
|
||||
return std::unexpected{failure(PublicationError::digest)};
|
||||
auto manifest = genesis_manifest(key, frame, commit, biology::cellular_motion_tick_microseconds,
|
||||
build, payload.size(), *digest,
|
||||
CheckpointProfile::cellular_lives_v1);
|
||||
auto manifest =
|
||||
genesis_manifest(key, frame, commit, biology::cellular_motion_tick_microseconds, build,
|
||||
payload.size(), *digest, CheckpointProfile::cellular_lives_v1);
|
||||
auto encoded = manifest ? encode_manifest(*manifest)
|
||||
: std::expected<std::vector<std::uint8_t>, CheckpointError>{
|
||||
std::unexpected{CheckpointError::format}};
|
||||
@@ -140,10 +142,10 @@ retry_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
||||
auto result = publish_cellular_checkpoint(db, prepared.manifest, {}, prepared.actions,
|
||||
prepared.trace, timeout);
|
||||
if (!result) {
|
||||
return std::unexpected{failure(
|
||||
result.error().kind == LeaseStoreError::unknown ? PublicationError::unknown
|
||||
: PublicationError::rejected,
|
||||
{}, result.error(), prepared)};
|
||||
return std::unexpected{failure(result.error().kind == LeaseStoreError::unknown
|
||||
? PublicationError::unknown
|
||||
: PublicationError::rejected,
|
||||
{}, result.error(), prepared)};
|
||||
}
|
||||
return confirm(*result, prepared, *manifest);
|
||||
}
|
||||
@@ -155,29 +157,29 @@ resolve_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
||||
auto trace = server::decode_cellular_batch(prepared.trace);
|
||||
if (!manifest || !trace || !prepared_is_canonical(prepared, *manifest, *trace))
|
||||
return std::unexpected{LeaseStoreFailure{LeaseStoreError::invalid, {}}};
|
||||
return resolve_cellular_region_commit(db, prepared.key, prepared.commit, prepared.manifest,
|
||||
{}, prepared.actions, prepared.trace, timeout);
|
||||
return resolve_cellular_region_commit(db, prepared.key, prepared.commit, prepared.manifest, {},
|
||||
prepared.actions, prepared.trace, timeout);
|
||||
}
|
||||
|
||||
std::expected<PublishedCellularBatch, CellularPublicationFailure>
|
||||
publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects,
|
||||
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
|
||||
const server::CellularBatch& batch, const server::CellularLives& candidate,
|
||||
Uuid commit, const Sha256Digest& build, milliseconds timeout,
|
||||
const PublishHooks& hooks,
|
||||
publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
|
||||
const CommittedCheckpoint& predecessor, const server::CellularBatch& batch,
|
||||
const server::CellularLives& candidate, Uuid commit,
|
||||
const Sha256Digest& build, milliseconds timeout, const PublishHooks& hooks,
|
||||
std::span<const server::CellularActionRecord> actions) {
|
||||
const auto previous = decode_manifest(predecessor.manifest);
|
||||
const auto predecessor_digest = sha256(predecessor.manifest);
|
||||
const auto trace = server::encode_cellular_batch(batch);
|
||||
const auto action_block = server::encode_cellular_action_block(
|
||||
actions, batch.header.begin_tick, batch.header.end_tick);
|
||||
const auto action_block = server::encode_cellular_action_block(actions, batch.header.begin_tick,
|
||||
batch.header.end_tick);
|
||||
if (!previous || !predecessor_digest || !trace || !action_block ||
|
||||
previous->profile != CheckpointProfile::cellular_lives_v1 ||
|
||||
predecessor.head.digest != *predecessor_digest ||
|
||||
previous->sequence != predecessor.head.sequence || previous->commit != predecessor.head.commit ||
|
||||
previous->end_tick != predecessor.head.end_tick || batch.header.world != previous->key.world ||
|
||||
batch.header.region != previous->key.region || batch.header.frame != previous->frame ||
|
||||
batch.header.predecessor != previous->commit ||
|
||||
previous->sequence != predecessor.head.sequence ||
|
||||
previous->commit != predecessor.head.commit ||
|
||||
previous->end_tick != predecessor.head.end_tick ||
|
||||
batch.header.world != previous->key.world || batch.header.region != previous->key.region ||
|
||||
batch.header.frame != previous->frame || batch.header.predecessor != previous->commit ||
|
||||
batch.header.predecessor_digest != *predecessor_digest ||
|
||||
batch.header.begin_tick != previous->end_tick || candidate.world() != previous->key.world ||
|
||||
candidate.region() != previous->key.region || candidate.frame() != previous->frame ||
|
||||
@@ -201,8 +203,8 @@ publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects,
|
||||
if (!payload_digest || !trace_digest)
|
||||
return std::unexpected{failure(PublicationError::digest)};
|
||||
auto manifest = successor_manifest(*previous, *predecessor_digest, commit, lease,
|
||||
batch.header.end_tick, build, payload.size(), *payload_digest,
|
||||
{trace->size(), *trace_digest, 0, {}});
|
||||
batch.header.end_tick, build, payload.size(),
|
||||
*payload_digest, {trace->size(), *trace_digest, 0, {}});
|
||||
auto manifest_bytes = manifest ? encode_manifest(*manifest)
|
||||
: std::expected<std::vector<std::uint8_t>, CheckpointError>{
|
||||
std::unexpected{CheckpointError::format}};
|
||||
@@ -224,25 +226,24 @@ publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects,
|
||||
|
||||
std::expected<RecoveredCellularCheckpoint, RecoveryFailure>
|
||||
recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects, RegionKey key,
|
||||
const LeaseGrant& lease,
|
||||
std::span<const Sha256Digest> retained_builds,
|
||||
const LeaseGrant& lease, std::span<const Sha256Digest> retained_builds,
|
||||
milliseconds timeout) {
|
||||
const auto fail_with = [](RecoveryError kind) {
|
||||
return std::unexpected{RecoveryFailure{kind, {}}};
|
||||
};
|
||||
auto committed = load_region_checkpoint(db, key, timeout);
|
||||
if (!committed)
|
||||
return std::unexpected{RecoveryFailure{
|
||||
committed.error().kind == LeaseStoreError::not_provisioned
|
||||
? RecoveryError::not_provisioned
|
||||
: RecoveryError::store,
|
||||
committed.error()}};
|
||||
return std::unexpected{
|
||||
RecoveryFailure{committed.error().kind == LeaseStoreError::not_provisioned
|
||||
? RecoveryError::not_provisioned
|
||||
: RecoveryError::store,
|
||||
committed.error()}};
|
||||
const auto digest = sha256(committed->manifest);
|
||||
auto manifest = decode_manifest(committed->manifest);
|
||||
if (!digest || *digest != committed->head.digest || !manifest || manifest->key != key ||
|
||||
manifest->sequence != committed->head.sequence ||
|
||||
manifest->commit != committed->head.commit || manifest->end_tick != committed->head.end_tick ||
|
||||
manifest->frame != committed->head.frame)
|
||||
manifest->commit != committed->head.commit ||
|
||||
manifest->end_tick != committed->head.end_tick || manifest->frame != committed->head.frame)
|
||||
return fail_with(RecoveryError::manifest);
|
||||
if (!supported(*manifest) || manifest->profile != CheckpointProfile::cellular_lives_v1 ||
|
||||
std::ranges::find(retained_builds, manifest->build) == retained_builds.end())
|
||||
@@ -253,14 +254,15 @@ recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
|
||||
auto payload = objects.get({manifest->payload_sha256, manifest->payload_bytes});
|
||||
if (!payload)
|
||||
return fail_with(payload.error() == ObjectError::io ? RecoveryError::store
|
||||
: RecoveryError::corrupt_payload);
|
||||
: RecoveryError::corrupt_payload);
|
||||
auto state = restore_cellular_payload(*payload, *manifest);
|
||||
if (!state)
|
||||
return fail_with(RecoveryError::payload);
|
||||
|
||||
std::vector<server::CellularActionRecord> actions;
|
||||
if (manifest->sequence != 0) {
|
||||
auto action_bytes = load_cellular_publication_actions(db, key, lease, manifest->commit, timeout);
|
||||
auto action_bytes =
|
||||
load_cellular_publication_actions(db, key, lease, manifest->commit, timeout);
|
||||
if (!action_bytes)
|
||||
return std::unexpected{RecoveryFailure{RecoveryError::store, action_bytes.error()}};
|
||||
if (!*action_bytes)
|
||||
@@ -281,17 +283,15 @@ recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
|
||||
trace->header.end_tick != manifest->end_tick)
|
||||
return fail_with(RecoveryError::tail);
|
||||
|
||||
auto committed_births = load_cellular_publication_births(db, key, lease,
|
||||
manifest->commit, timeout);
|
||||
auto committed_births =
|
||||
load_cellular_publication_births(db, key, lease, manifest->commit, timeout);
|
||||
if (!committed_births)
|
||||
return std::unexpected{RecoveryFailure{RecoveryError::store,
|
||||
committed_births.error()}};
|
||||
return std::unexpected{RecoveryFailure{RecoveryError::store, committed_births.error()}};
|
||||
std::vector<CellularBirthBinding> traced_births;
|
||||
for (std::size_t tick_index = 0; tick_index < trace->ticks.size(); ++tick_index) {
|
||||
for (const auto& birth : trace->ticks[tick_index].births) {
|
||||
traced_births.push_back({birth.account, manifest->commit, birth.request,
|
||||
birth.identity,
|
||||
manifest->begin_tick + tick_index + 1,
|
||||
birth.identity, manifest->begin_tick + tick_index + 1,
|
||||
manifest->sequence});
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,8 @@ recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
|
||||
return fail_with(RecoveryError::tail);
|
||||
auto batch_actions = server::decode_cellular_action_block(
|
||||
**action_bytes, manifest->begin_tick, manifest->end_tick);
|
||||
if (!batch_actions || !server::match_cellular_actions_to_trace(**base, *trace, *batch_actions))
|
||||
if (!batch_actions ||
|
||||
!server::match_cellular_actions_to_trace(**base, *trace, *batch_actions))
|
||||
return fail_with(RecoveryError::history);
|
||||
auto replay = server::replay_cellular_batch(**base, *trace);
|
||||
if (!replay || (*replay)->snapshot() != *payload)
|
||||
|
||||
Reference in New Issue
Block a user