Skip to content

sgns::MigrationAllowList

Stores observed legacy balances and validates migration claim eligibility.

#include <MigrationAllowList.hpp>

Public Types

Name
using std::pair< std::string, uint64_t > AddressBalance
Address and observed balance pair stored in the migration allow-list.

Public Functions

Name
MigrationAllowList(std::shared_ptr< storage::rocksdb > db, std::string migration_version)
Creates an allow-list view scoped to a specific migration version.
outcome::result< void > StoreObservedBalance(const std::string & address, uint64_t balance)
Persists the observed legacy balance for a single address.
outcome::result< void > StoreObservedBalances(const std::vector< AddressBalance > & balances)
Persists observed legacy balances for multiple addresses.
outcome::result< std::optional< uint64_t > > LoadObservedBalance(const std::string & address) const
Loads the observed legacy balance for a single address when present.
outcome::result< bool > IsEligible(const std::string & address, uint64_t claimed_balance) const
Checks whether an address may claim the provided migrated balance.
outcome::result< std::vector< AddressBalance > > ListObservedBalances() const
Lists every stored observed balance in the current migration namespace.
std::string BuildPrefix(std::string_view migration_version)
Builds the RocksDB key prefix used for a migration version namespace.
std::string BuildKey(std::string_view migration_version, std::string_view address)
Builds the RocksDB key used for a specific address inside a migration namespace.

Friends

Name
class ::MigrationParamTest

Public Types Documentation

using AddressBalance

using sgns::MigrationAllowList::AddressBalance = std::pair<std::string, uint64_t>;

Address and observed balance pair stored in the migration allow-list.

Public Functions Documentation

function MigrationAllowList

MigrationAllowList(
    std::shared_ptr< storage::rocksdb > db,
    std::string migration_version
)

Creates an allow-list view scoped to a specific migration version.

Parameters:

  • db RocksDB instance used to persist and query observed balances.
  • migration_version Source migration version namespace, for example "3.6.0".

function StoreObservedBalance

outcome::result< void > StoreObservedBalance(
    const std::string & address,
    uint64_t balance
)

Persists the observed legacy balance for a single address.

Parameters:

  • address Legacy source address whose balance was observed.
  • balance Observed balance for address.

Return: Success when the balance is written, or a database error on failure.

function StoreObservedBalances

outcome::result< void > StoreObservedBalances(
    const std::vector< AddressBalance > & balances
)

Persists observed legacy balances for multiple addresses.

Parameters:

  • balances Address and balance pairs to persist.

Return: Success when every balance is written, or the first write error encountered.

function LoadObservedBalance

outcome::result< std::optional< uint64_t > > LoadObservedBalance(
    const std::string & address
) const

Loads the observed legacy balance for a single address when present.

Parameters:

  • address Legacy source address to look up.

Return: Optional observed balance; empty when no allow-list entry exists for address.

function IsEligible

outcome::result< bool > IsEligible(
    const std::string & address,
    uint64_t claimed_balance
) const

Checks whether an address may claim the provided migrated balance.

Parameters:

  • address Legacy source address making the migration claim.
  • claimed_balance Balance claimed by the migration transaction.

Return: True when address exists in the allow-list and claimed_balance is no more than twice the observed balance.

Note: The maximum allowed claim saturates at std::numeric_limits<uint64_t>::max() to avoid overflow.

function ListObservedBalances

outcome::result< std::vector< AddressBalance > > ListObservedBalances() const

Lists every stored observed balance in the current migration namespace.

Return: Address and balance pairs sorted by address.

function BuildPrefix

static std::string BuildPrefix(
    std::string_view migration_version
)

Builds the RocksDB key prefix used for a migration version namespace.

Parameters:

  • migration_version Source migration version namespace.

Return: Key prefix for all allow-list entries under migration_version.

function BuildKey

static std::string BuildKey(
    std::string_view migration_version,
    std::string_view address
)

Builds the RocksDB key used for a specific address inside a migration namespace.

Parameters:

  • migration_version Source migration version namespace.
  • address Legacy source address.

Return: Full allow-list key for address under migration_version.

Friends

friend ::MigrationParamTest

friend class ::MigrationParamTest(
    ::MigrationParamTest 
);

Updated on 2026-06-05 at 17:22:18 -0700