Integrate opt-in cellular v6 sessions
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Failing after 4m30s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 3m1s
Foundation / checks (postgres) (push) Canceled after 34s
Foundation / checks (checks) (push) Canceled after 5m8s

This commit is contained in:
dingo
2026-10-10 21:46:33 -04:00
parent 04a50be9cd
commit 747b063c65
9 changed files with 163 additions and 18 deletions
+42 -14
View File
@@ -134,7 +134,8 @@ struct RegionSessions::Impl {
}
// Realtime answers: a refused datagram is dropped; cumulative watermarks cover it.
void send_datagram(const Connection& c, const network::SessionMessage& m) {
(void)endpoint->send_datagram(c.id, network::encode_session(m)).has_value();
(void)endpoint->send_datagram(c.id, network::encode_session(m, c.protocol_version))
.has_value();
}
[[nodiscard]] network::AdmissionFacts admission() const {
return {facts.ready, control.epoch(), facts.simulated_tick};
@@ -322,9 +323,10 @@ struct RegionSessions::Impl {
intents.close(c.session);
return close(c, SessionCloseReason::capacity, now);
}
if (default_interest)
if (default_interest && c.protocol_version != network::session_protocol_v6)
(void)replication.set_interest(c.session, *default_interest).has_value();
if (markers.area()) // Full or refused: the session simply has no marker.
if (markers.area() && c.protocol_version != network::session_protocol_v6)
// Full or refused: the session simply has no marker.
(void)(c.probe ? markers.open_at(c.session, c.probe->x, c.probe->y)
: markers.open(c.session))
.has_value();
@@ -390,12 +392,20 @@ struct RegionSessions::Impl {
return;
std::uint16_t wire_version{};
const auto decoded = network::decode_session(bytes, &wire_version);
if (c.state != State::established || !decoded ||
wire_version != network::session_protocol_version ||
c.protocol_version != network::session_protocol_version)
if (c.state != State::established || !decoded || wire_version != c.protocol_version ||
(c.protocol_version != network::session_protocol_version &&
!(config.accept_cellular_intentions &&
c.protocol_version == network::session_protocol_v6)))
return close(c, SessionCloseReason::protocol, now);
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
return replication.acknowledge(c.session, *ack);
if (c.protocol_version == network::session_protocol_v6) {
const auto* m = std::get_if<network::CellularIntention>(&*decoded);
if (!m)
return close(c, SessionCloseReason::protocol, now);
send_datagram(c, intents.intention(c.session, *m, admission()));
return;
}
const auto* m = std::get_if<network::SessionIntention>(&*decoded);
if (!m)
return close(c, SessionCloseReason::protocol, now);
@@ -543,8 +553,11 @@ struct RegionSessions::Impl {
if (c.state == State::hello) {
c.protocol_version = wire_version;
const bool primitive_v5 = static_cast<bool>(config.create_primitive_life);
const bool cellular_v6 = config.accept_cellular_intentions;
if ((primitive_v5 && wire_version != network::session_protocol_v5) ||
(wire_version == network::session_protocol_v5 && !primitive_v5))
(wire_version == network::session_protocol_v5 && !primitive_v5) ||
(wire_version == network::session_protocol_v6 && !cellular_v6) ||
wire_version > network::session_protocol_v6)
return close(c, SessionCloseReason::unsupported_version, now);
} else if (wire_version != c.protocol_version) {
return close(c, SessionCloseReason::unsupported_version, now);
@@ -557,7 +570,8 @@ struct RegionSessions::Impl {
if (const auto* m = std::get_if<network::SessionRefresh>(&*decoded))
return refresh(c, *m, now_seconds, now);
if (const auto* m = std::get_if<network::SessionAction>(&*decoded)) {
if (c.protocol_version == network::session_protocol_v5)
if (c.protocol_version == network::session_protocol_v5 ||
c.protocol_version == network::session_protocol_v6)
return close(c, SessionCloseReason::protocol, now);
// A durable uniqueness check waits for this poll's single `verify` (M10.9d).
if (const auto receipt = intents.admit(c.session, *m, admission()))
@@ -565,12 +579,14 @@ struct RegionSessions::Impl {
return;
}
if (const auto* m = std::get_if<network::ActionQuery>(&*decoded)) {
if (c.protocol_version == network::session_protocol_v5)
if (c.protocol_version == network::session_protocol_v5 ||
c.protocol_version == network::session_protocol_v6)
return close(c, SessionCloseReason::protocol, now);
return send(c, intents.query(c.session, *m, admission()));
}
if (const auto* m = std::get_if<network::SessionInterest>(&*decoded)) {
if (c.protocol_version == network::session_protocol_v5)
if (c.protocol_version == network::session_protocol_v5 ||
c.protocol_version == network::session_protocol_v6)
return close(c, SessionCloseReason::protocol, now);
(void)replication.set_interest(c.session, *m).has_value(); // Clamped by the server.
return;
@@ -613,6 +629,7 @@ RegionSessions::create(RegionSessionsConfig config) {
config.ticket_lifetime == 0 || config.ticket_lifetime > network::max_ticket_lifetime ||
((config.create_primitive_life || config.query_primitive_life) &&
(!config.create_primitive_life || !config.query_primitive_life || !config.ledger)) ||
(config.accept_cellular_intentions && config.create_primitive_life) ||
config.transport.limits.max_connections < config.control.max_sessions ||
config.hello_deadline.count() <= 0 || config.close_flush.count() <= 0 ||
config.renew_interval.count() <= 0 || config.safety_margin.count() <= 0 ||
@@ -729,7 +746,8 @@ void RegionSessions::poll(const HostFacts& facts, std::uint64_t now_seconds,
for (const auto& [session, watermark] : m.intents.simulated(m.admission()))
if (auto* c = m.by_session(session);
c && c->state == Impl::State::established &&
c->protocol_version == network::session_protocol_version)
(c->protocol_version == network::session_protocol_version ||
c->protocol_version == network::session_protocol_v6))
m.send_datagram(*c, watermark);
for (const auto session : m.control.expire(now_seconds))
if (auto* c = m.by_session(session))
@@ -751,6 +769,11 @@ std::vector<network::CarriedAction> RegionSessions::carry(std::uint64_t tick) {
return impl_->intents.carry(tick);
}
std::vector<network::ScheduledCellularIntention>
RegionSessions::cellular_intentions(std::uint64_t tick) const {
return impl_->intents.scheduled_cellular_intentions(tick);
}
void RegionSessions::committed(std::span<const network::CarriedAction> actions,
std::uint64_t commit_sequence) {
impl_->deliver(impl_->intents.committed(actions, commit_sequence));
@@ -764,7 +787,9 @@ void RegionSessions::set_default_interest(network::SessionInterest interest) {
auto& m = *impl_;
m.default_interest = interest;
for (const auto& c : m.connections)
if (c.state == Impl::State::established && !m.replication.interest(c.session))
if (c.state == Impl::State::established &&
c.protocol_version != network::session_protocol_v6 &&
!m.replication.interest(c.session))
(void)m.replication.set_interest(c.session, interest).has_value();
}
@@ -785,7 +810,9 @@ void RegionSessions::replicate(
return s;
};
for (const auto& [session, chunks] : m.replication.tick(tick, with_markers, perceives, payload))
if (const auto* c = m.by_session(session); c && c->state == Impl::State::established)
if (const auto* c = m.by_session(session);
c && c->state == Impl::State::established &&
c->protocol_version != network::session_protocol_v6)
for (const auto& chunk : chunks)
m.send_datagram(*c, chunk); // A refused chunk leaves the snapshot unacknowledged.
}
@@ -810,7 +837,8 @@ bool RegionSessions::set_motion_area(const network::motion::Area& area, std::int
m.spawn_x = std::clamp(spawn_x, area.min_x, area.max_x);
m.spawn_y = std::clamp(spawn_y, area.min_y, area.max_y);
for (const auto& c : m.connections)
if (c.state == Impl::State::established && !m.markers.of(c.session))
if (c.state == Impl::State::established &&
c.protocol_version != network::session_protocol_v6 && !m.markers.of(c.session))
(void)m.markers.open(c.session).has_value();
return true;
}