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
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:
@@ -62,7 +62,8 @@ struct RegionSessionClient::Impl {
|
||||
return end(SessionCloseReason::protocol, true); // Malformed snapshot.
|
||||
if (const auto ack = accepted.value_or(std::nullopt); ack && connection != 0)
|
||||
// A lost ack only means the next delta is against an older baseline.
|
||||
(void)endpoint->send_datagram(connection, network::encode_session(*ack))
|
||||
(void)endpoint
|
||||
->send_datagram(connection, network::encode_session(*ack, protocol_version))
|
||||
.has_value();
|
||||
return;
|
||||
}
|
||||
@@ -149,7 +150,8 @@ RegionSessionClient::~RegionSessionClient() = default;
|
||||
std::expected<std::unique_ptr<RegionSessionClient>, network::quic::EndpointError>
|
||||
RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point now) {
|
||||
if (config.protocol_version != network::session_protocol_version &&
|
||||
config.protocol_version != network::session_protocol_v5)
|
||||
config.protocol_version != network::session_protocol_v5 &&
|
||||
config.protocol_version != network::session_protocol_v6)
|
||||
return std::unexpected(network::quic::EndpointError::configuration);
|
||||
auto endpoint = network::quic::Endpoint::connect(config.transport);
|
||||
if (!endpoint)
|
||||
@@ -219,6 +221,28 @@ RegionSessionClient::send_intention(std::uint64_t tick, std::int16_t move_x, std
|
||||
return m.next_sequence++;
|
||||
}
|
||||
|
||||
std::optional<std::uint64_t> RegionSessionClient::send_cellular_intention(
|
||||
std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target) {
|
||||
auto& m = *impl_;
|
||||
if (m.protocol_version != network::session_protocol_v6 ||
|
||||
m.state != RegionSessionState::established || m.connection == 0 || !m.welcome)
|
||||
return std::nullopt;
|
||||
const network::CellularIntention intention{m.welcome->session,
|
||||
m.welcome->epoch,
|
||||
m.next_sequence,
|
||||
tick,
|
||||
move_x,
|
||||
move_y,
|
||||
intake_target.has_value(),
|
||||
intake_target ? intake_target->first : 0,
|
||||
intake_target ? intake_target->second : 0};
|
||||
if (!m.endpoint->send_datagram(m.connection,
|
||||
network::encode_session(intention, m.protocol_version)))
|
||||
return std::nullopt;
|
||||
return m.next_sequence++;
|
||||
}
|
||||
|
||||
bool RegionSessionClient::send_action(std::uint64_t action_id, network::ActionKind kind,
|
||||
std::uint64_t tick) {
|
||||
auto& m = *impl_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user