Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ CPMAddPackage(
EXCLUDE_FROM_ALL FALSE
)
CPMAddPackage(
NAME numeric
NAME ae-numeric
GIT_REPOSITORY "https://github.com/aethernetio/aethernet-numeric.git"
GIT_TAG "main"
OPTIONS "AE_NUMERIC_INSTALL ${AE_INSTALL}" "AE_BUILD_TESTS ${AE_BUILD_TESTS}"
GIT_TAG "68fcbb3d7975adddf2be5fae4c8c22ef725da5e7"
OPTIONS "AE_NUMERIC_INSTALL ${AE_INSTALL}" "AE_BUILD_TESTS OFF"
EXCLUDE_FROM_ALL FALSE
)
CPMAddPackage(
Expand All @@ -150,7 +150,7 @@ CPMAddPackage(
CPMAddPackage(
NAME aether-tele
GIT_REPOSITORY "https://github.com/aethernetio/aether-tele.git"
GIT_TAG "main"
GIT_TAG "7424eb5bdd49e78bd73aa1e453594d3660c111c4"
OPTIONS "AE_TELE_INSTALL ${AE_INSTALL}"
"AE_TELE_BUILD_TESTS ${AE_BUILD_TESTS}"
EXCLUDE_FROM_ALL FALSE
Expand Down Expand Up @@ -188,7 +188,7 @@ target_link_libraries(${TARGET_NAME} PUBLIC
gcem
etl
stdexec
numeric
ae-numeric
aether::miscpp)

message(STATUS "Aether build for CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
Expand Down
2 changes: 1 addition & 1 deletion aether/ae_actions/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# include "aether/aether.h"
# include "aether/tele_statistics.h"
# include "aether/tiered_int_serializer.h" // IWYU pragma: keep
# include "aether/types/packed_size.h" // IWYU pragma: keep

# include "aether/ae_actions/ae_actions_tele.h"

Expand Down
5 changes: 1 addition & 4 deletions aether/api_protocol/api_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
#include <tuple>
#include <vector>

#include <numeric/tiered_int.h>

#include "aether-miscpp/serialization/serialization.h"

#include "aether/types/packed_size.h"
#include "aether/vector_buffer.h"

namespace ae {

using MessageId = std::uint8_t;

using PackedSize = TieredInt<std::uint64_t, std::uint8_t, 250>;

class ApiParser;
class ApiPacker;

Expand Down
2 changes: 1 addition & 1 deletion aether/obj/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "aether-miscpp/serialization/binary_archive.h"
#include "aether-miscpp/serialization/serialization.h"
#include "aether/ptr/ptr_view.h"
#include "aether/tiered_int_serializer.h"
#include "aether/types/packed_size.h"

#include "aether/obj/idomain_storage.h"
#include "aether/obj/obj_id.h"
Expand Down
2 changes: 0 additions & 2 deletions aether/server_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <cassert>
#include <cstdint>

#include <numeric/tiered_int.h>

#include "aether/crypto/crypto_nonce.h"
#include "aether/crypto/key.h"
#include "aether/types/server_id.h"
Expand Down
2 changes: 1 addition & 1 deletion aether/stream_api/sized_packet_gate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace ae {

static constexpr std::size_t kSizedPacketOverhead =
sizeof(PacketSize::ValueType); // max for packet size
PacketSize::kMaxWireBytes; // max for packet size

DataBuffer SizedPacketGate::WriteIn(DataBuffer&& buffer) {
DataBuffer write_buffer;
Expand Down
5 changes: 3 additions & 2 deletions aether/stream_api/stream_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <cstddef>

#include "aether/types/packed_size.h"

namespace ae {
StreamApiImpl::StreamApiImpl(ProtocolContext& protocol_context)
: ApiClass{protocol_context}, stream{protocol_context} {}
Expand Down Expand Up @@ -46,8 +48,7 @@ std::uint8_t StreamIdGenerator::GetNextServerStreamId() {

static constexpr std::size_t kStreamMessageOverhead =
1 + 1 +
sizeof(
PackedSize::ValueType); // message code + stream id + child data size
PackedSize::kMaxWireBytes; // message code + stream id + child data size

StreamApiGate::StreamApiGate(StreamApiImpl& stream_api, StreamId stream_id)
: stream_id_{stream_id},
Expand Down
1 change: 1 addition & 0 deletions aether/tele_statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "aether/config.h"
#include "aether/obj/obj.h"
#include "aether/types/packed_size.h"

namespace ae {
class TeleStatistics : public Obj {
Expand Down
74 changes: 0 additions & 74 deletions aether/tiered_int_serializer.h

This file was deleted.

7 changes: 3 additions & 4 deletions aether/transport/data_packet_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ std::pair<std::size_t, std::size_t> StreamDataPacketCollector::GetPacketSize(
std::uint8_t const* data, std::size_t size) {
auto temp_buffer_size = temp_data_buffer_.size();

// use no more than packet size may contain
auto use_max_size = sizeof(PacketSize::ValueType) < size
? sizeof(PacketSize::ValueType)
: size;
// use no more than the max serialized packet-size header
auto use_max_size =
PacketSize::kMaxWireBytes < size ? PacketSize::kMaxWireBytes : size;

temp_data_buffer_.insert(temp_data_buffer_.end(), data, data + use_max_size);

Expand Down
5 changes: 1 addition & 4 deletions aether/transport/data_packet_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
#include <utility>
#include <vector>

#include <numeric/tiered_int.h>

#include "aether/types/packed_size.h"
#include "aether/types/data_buffer.h"

namespace ae {

using PacketSize = TieredInt<std::uint64_t, std::uint8_t, 250>;

struct Packet {
explicit Packet(std::size_t expected_size);
Packet(Packet const&) = delete;
Expand Down
89 changes: 89 additions & 0 deletions aether/types/packed_size.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2026 Aethernet Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef AETHER_TYPES_PACKED_SIZE_H_
#define AETHER_TYPES_PACKED_SIZE_H_

#include <cstddef>
#include <cstdint>

#include "ae-numeric/tiered_int.h"
#include "ae-numeric/wire_io.h"

#include "aether-miscpp/serialization/binary_archive.h"

namespace ae {

// Canonical legacy-compatible wire size encoding used by packet and message
// framing. Byte-for-byte equivalent of the old
// TieredInt<std::uint64_t, std::uint8_t, 250>.
using PackedSize = TieredInt<std::uint8_t, 250, 1514, 1049834>;

// Transport framing uses the same wire encoding; keep the historical name as
// an alias so packet code stays readable without duplicating the type.
using PacketSize = PackedSize;

} // namespace ae

namespace ae::seri {

// BinaryArchive adapter for ae-numeric TieredInt via wire_traits /
// Serialize / Deserialize. Truncated input maps to read_eof (no exceptions,
// no heap allocations). The same wire_io entry points can later back
// FixedPoint / Exponential serializers without changing BinaryArchive.
template <BinaryBuffer B, typename WireCell, std::uint32_t... TierMaxVals>
struct Serializer<BinaryArchive<B>, TieredInt<WireCell, TierMaxVals...>> {
using Archive = BinaryArchive<B>;
using TInt = TieredInt<WireCell, TierMaxVals...>;

SeriResult Seri(Archive& archive, Meta<TInt const> meta) const {
std::uint8_t buf[MaxWireBytes<TInt>()];
std::size_t const n = ae::Serialize(meta.value, buf);
return archive.buffer().Write(DataWriteTag{buf, n});
}

SeriResult Deseri(Archive& archive, Meta<TInt> meta) const {
std::uint8_t buf[MaxWireBytes<TInt>()]{};
std::size_t len = 0;

// Grow one byte at a time until WireBytesNeeded reports a complete value.
// Avoids reading past this field into the next wire value.
while (len < MaxWireBytes<TInt>()) {
auto const read_res =
archive.buffer().Read(DataReadTag{buf + len, std::size_t{1}});
if (!read_res) {
return read_res;
}
++len;

if (TInt::WireBytesNeeded(buf, len) == 0) {
continue;
}

auto const decoded = ae::Deserialize<TInt>(buf, len);
if (decoded.bytes_read == 0 || decoded.bytes_read != len) {
return Error{read_eof};
}
meta.value = decoded.value;
return Ok{good};
}
return Error{read_eof};
}
};

} // namespace ae::seri

#endif // AETHER_TYPES_PACKED_SIZE_H_
35 changes: 19 additions & 16 deletions aether/vector_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@
#ifndef AETHER_VECTOR_BUFFER_H_
#define AETHER_VECTOR_BUFFER_H_

#include <cassert>
#include <cstddef>
#include <cstring>
#include <vector>

#include <numeric/tiered_int.h> // IWYU pragma: keep
#include "aether-miscpp/serialization/binary_archive.h"

#include "aether/tiered_int_serializer.h"
#include "aether/types/packed_size.h"

namespace ae {

template <typename TieredInt>
template <typename SizeT>
struct VectorBuffer {
using PackedSize = TieredInt;
using PackedSize = SizeT;

seri::SeriResult Write(seri::SizeWriteTag tag) {
auto v = PackedSize{tag.size};
auto writer = seri::TIntWriter{.buffer = *this};
v.Serialize(writer);
return writer.res;
auto const v = PackedSize{tag.size};
std::uint8_t buf[PackedSize::kMaxWireBytes];
std::size_t const n = v.Serialize(buf);
return Write(seri::DataWriteTag{buf, n});
}

seri::SeriResult Write(seri::DataWriteTag tag) {
Expand All @@ -47,16 +45,21 @@ struct VectorBuffer {
}

seri::SeriResult Read(seri::SizeReadTag tag) {
auto v = PackedSize{};
auto reader = seri::TIntReader{.buffer = *this};
TierDeserializeRes r = v.Deserialize(reader);
if (r != TierDeserializeRes::kFinished) {
auto const available = buff.size() - read_offset;
std::size_t const n =
PackedSize::WireBytesNeeded(buff.data() + read_offset, available);
if (n == 0) {
return Error{seri::read_eof};
}
if (!reader.res) {
return reader.res;

PackedSize decoded{};
std::size_t const bytes_read =
decoded.Deserialize(buff.data() + read_offset, n);
if (bytes_read == 0) {
return Error{seri::read_eof};
}
tag.size = static_cast<std::size_t>(v);
read_offset += bytes_read;
tag.size = static_cast<std::size_t>(decoded);
return Ok{seri::good};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test-api-protocol/assert_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "aether-miscpp/serialization/binary_archive.h"

#include "aether/api_protocol/api_message.h"
#include "aether/tiered_int_serializer.h" // IWYU pragma: export
#include "aether/types/packed_size.h" // IWYU pragma: export

#if defined(__clang__) || defined(__GNUC__)
# define FUNCTION_NAME __PRETTY_FUNCTION__
Expand Down
2 changes: 1 addition & 1 deletion tests/test-object-system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if(NOT CM_PLATFORM)
# for aether
target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE unity etl numeric aether::miscpp aether-tele)
target_link_libraries(${PROJECT_NAME} PRIVATE unity etl ae-numeric aether::miscpp aether-tele)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AE_DISTILLATION=1")
target_compile_definitions(${PROJECT_NAME} PRIVATE "AE_PROJECT_VERSION=\"0.0.0\"")

Expand Down
Loading
Loading