Add M10.8c-2 client handoff switch and evo-server handoff configuration
Foundation / checks (deploy) (push) Successful in 3m20s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (client) (push) Failing after 12m9s
Foundation / checks (network) (push) Successful in 13m2s
Foundation / checks (tsan) (push) Successful in 8m7s
Foundation / checks (checks) (push) Successful in 32m1s
Foundation / checks (postgres) (push) Successful in 42m43s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 3m20s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (client) (push) Failing after 12m9s
Foundation / checks (network) (push) Successful in 13m2s
Foundation / checks (tsan) (push) Successful in 8m7s
Foundation / checks (checks) (push) Successful in 32m1s
Foundation / checks (postgres) (push) Successful in 42m43s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
ADR-0096. The engineering client follows a HandoffOffer into the next region with its ticket (no grant, no pause, the view kept) and a Redirect to the probe's owner, picking grants by region claim in rising serial order. evo-server gains --m10-area, --m10-handoff-key and --m10-neighbour (dev only), wiring the PostgreSQL probe and handoff ledgers; the probe tool writes multi-region bundles and reports handoffs and redirects. Refreshes the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "evo/network/dev_credentials.hpp"
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/server/region_sessions.hpp"
|
||||
#include "fixtures/fake_handoff_world.hpp"
|
||||
#include "remote_session.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <source_location>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -327,6 +329,131 @@ void refusals(Region& r) {
|
||||
CHECK(!RemoteSession::open(bad));
|
||||
CHECK(!RemoteSession::open(r.material({})));
|
||||
}
|
||||
// M10.8c-2 (ADR-0096): the client follows a crossing into the next region with the offer's
|
||||
// ticket (no grant, no pause, the view kept) and follows a redirect at login, picking grants
|
||||
// by region from a two-region bundle in rising serial order.
|
||||
void crossing_regions(const Files& f) {
|
||||
using evo::test::RegionDb;
|
||||
using evo::test::WorldDb;
|
||||
constexpr std::int64_t m = 1'000'000;
|
||||
const auto area = [](std::int64_t x0) {
|
||||
return network::motion::Area{x0, 0, x0 + (10 * m) - 1, (10 * m) - 1, 0};
|
||||
};
|
||||
WorldDb world;
|
||||
RegionDb db1{world, 1}, db2{world, 2};
|
||||
auto key1 = std::make_shared<const HandoffSigningKey>(
|
||||
*HandoffSigningKey::generate(DeploymentEnvironment::dev, 41));
|
||||
auto key2 = std::make_shared<const HandoffSigningKey>(
|
||||
*HandoffSigningKey::generate(DeploymentEnvironment::dev, 42));
|
||||
auto imported = GrantSigningKey::import(DeploymentEnvironment::dev, 1, scalar());
|
||||
CHECK(imported.has_value());
|
||||
const auto& issuer = *imported;
|
||||
const auto make = [&](std::uint64_t id, RegionDb& db,
|
||||
std::shared_ptr<const HandoffSigningKey> own,
|
||||
const HandoffSigningKey& neighbour_key, std::uint64_t neighbour,
|
||||
std::uint16_t neighbour_port, std::uint16_t port) {
|
||||
server::RegionSessionsConfig c;
|
||||
c.transport.certificate_pem_file = f.certificate.string();
|
||||
c.transport.key_pem_file = f.key.string();
|
||||
c.transport.port = port;
|
||||
c.control.environment = DeploymentEnvironment::dev;
|
||||
c.control.world = world_id;
|
||||
c.control.region = id;
|
||||
c.control.epoch = 3;
|
||||
c.control.max_account_attempts = 16;
|
||||
c.issuer_keys.push_back({1, *issuer.public_key()});
|
||||
c.ledger = &db;
|
||||
c.handoff = &db;
|
||||
c.probes = &db;
|
||||
c.handoff_key = std::move(own);
|
||||
c.handoff_keys.push_back(
|
||||
{neighbour, static_cast<std::uint32_t>(neighbour + 40), *neighbour_key.public_key()});
|
||||
c.neighbours.push_back(
|
||||
{{neighbour, "localhost:" + std::to_string(neighbour_port), std::string{name}},
|
||||
area(neighbour == 1 ? 0 : 10 * m)});
|
||||
c.ghost_poll = std::chrono::milliseconds{20};
|
||||
auto made = server::RegionSessions::create(std::move(c));
|
||||
CHECK(made.has_value());
|
||||
const auto x0 = id == 1 ? 0 : 10 * m;
|
||||
CHECK((*made)->set_motion_area(area(x0), x0 + (5 * m), 5 * m));
|
||||
(*made)->set_default_interest({(x0 / m) + 5, 5, 0, 7});
|
||||
return std::move(*made);
|
||||
};
|
||||
// Region 2 listens on a port found by binding a throwaway region first.
|
||||
std::uint16_t port2 = 0;
|
||||
{
|
||||
auto probe = make(2, db2, key2, *key1, 1, 1, 0);
|
||||
port2 = probe->port();
|
||||
}
|
||||
auto r1 = make(1, db1, key1, *key2, 2, port2, 0);
|
||||
auto r2 = make(2, db2, key2, *key1, 1, r1->port(), port2);
|
||||
std::uint64_t tick = 100;
|
||||
const auto grants = [&](const AccountId& who, std::uint64_t first) {
|
||||
std::vector<WireGrant> out;
|
||||
for (std::uint64_t i = 0; i < 4; ++i) {
|
||||
GrantClaims c;
|
||||
c.grant_id = 5000 + first + i;
|
||||
c.account = who;
|
||||
c.serial = first + i;
|
||||
c.world = world_id;
|
||||
c.region = (i % 2) + 1; // Interleaved: region 1, 2, 1, 2.
|
||||
c.issued_at = start;
|
||||
c.expires_at = start + 120;
|
||||
out.push_back(*issuer.sign(c));
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const auto material = [&](std::vector<WireGrant> g) {
|
||||
return client::ConnectMaterial{
|
||||
{"localhost", r1->port()}, std::string{name}, f.ca_pem, f.ca.string(), std::move(g)};
|
||||
};
|
||||
const auto pump = [&](const std::vector<Client*>& clients, const std::function<bool()>& done) {
|
||||
const auto end = Clock::now() + std::chrono::seconds{20};
|
||||
for (int i = 1; Clock::now() < end; ++i) {
|
||||
if (i % 5 == 0)
|
||||
++tick;
|
||||
for (auto* r : {r1.get(), r2.get()}) {
|
||||
r->poll({true, 3, tick}, start + 1, Clock::now());
|
||||
r->replicate(tick, [](const SessionInterest&) {
|
||||
ReplicationSource s;
|
||||
s.identity = world_id;
|
||||
return s;
|
||||
});
|
||||
static_cast<void>(r->take_events());
|
||||
}
|
||||
for (auto* c : clients)
|
||||
c->host.step(Clock::now(), c->intention, c->ui);
|
||||
if (done())
|
||||
return true;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{2});
|
||||
}
|
||||
return done();
|
||||
};
|
||||
const auto dana = account(31);
|
||||
Client a;
|
||||
CHECK(a.host.connect(RemoteSession::open(material(grants(dana, 10)))));
|
||||
auto& s = *a.host.session();
|
||||
CHECK(pump({&a}, [&] { return s.status().phase == "connected" && s.status().marker; }));
|
||||
CHECK(s.status().region == 1 && s.status().marker_x_mm == 5000);
|
||||
// Walking east: the crossing is followed into region 2 with the ticket, no grant used.
|
||||
a.intention.move_x = 1000;
|
||||
const auto left = s.status().grants_left;
|
||||
CHECK(pump({&a}, [&] {
|
||||
const auto st = s.status();
|
||||
return st.region == 2 && st.phase == "connected" && st.handoffs == 1 && st.marker;
|
||||
}));
|
||||
CHECK(s.status().grants_left == left && a.phase() == LaunchPhase::connected &&
|
||||
world.probes.at(dana).owner == 2 && s.status().marker_x_mm >= 10'000);
|
||||
a.intention.move_x = 0;
|
||||
// A second client with a newer bundle logs in at region 1 and is redirected to region 2,
|
||||
// where it takes over (the first is superseded).
|
||||
Client b;
|
||||
CHECK(b.host.connect(RemoteSession::open(material(grants(dana, 20)))));
|
||||
auto& t = *b.host.session();
|
||||
CHECK(
|
||||
pump({&a, &b}, [&] { return t.status().region == 2 && t.status().phase == "connected"; }));
|
||||
CHECK(a.phase() == LaunchPhase::failed && world.probes.at(dana).owner == 2);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() try {
|
||||
@@ -337,6 +464,7 @@ int main() try {
|
||||
remote_markers(r);
|
||||
refusals(r);
|
||||
}
|
||||
crossing_regions(files);
|
||||
std::filesystem::remove_all(files.dir);
|
||||
std::puts("client remote session tests passed");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user