Skip to content

sgns::PublicChainInputValidator

Validator for transactions that reference external public-chain proofs.

#include <PublicChainInputValidator.hpp>

Inherits from sgns::IInputValidator

Public Functions

Name
void SetRpcEndpoints(const std::string & chain_id, std::vector< WeightedRpcEndpoint > endpoints)
Configure weighted RPC endpoints for a source chain.
virtual bool ValidateUTXOParameters(const UTXOTxParameters & params, const std::string & address, const UTXOManager & utxo_manager) const override
Validates local UTXO structure for externally sourced claims.
virtual bool ValidateWitness(const ConsensusSubject & subject, const std::shared_ptr< GeniusTransaction > & tx, const UTXOTxParameters & params, const std::shared_ptr< Blockchain > & blockchain) const override
Validates the external witness data supplied by consensus.
virtual bool RequiresConsensusUTXOData() const override
Public-chain validation does not require local UTXO witness data.
void SetTransportFactory(TransportFactory factory)
Inject a custom transport factory for DI-based mock support.
std::optional< std::string > GetFirstRpcUrl(const std::string & chain_id) const
Returns the first RPC endpoint URL for a given chain ID, if any exist.
std::vector< uint8_t > GetSlotHash(size_t slot_index, const std::string & chain_id) const
Returns the SHA-256 hash of an endpoint URL for a vote slot (Phase 6, D-01).
std::optional< std::string > GetFirstConfiguredChainId() const
Returns the first configured chain id, if any (Phase 6, D-01).

Additional inherited members

Public Types inherited from sgns::IInputValidator

Name
using const IInputValidator * ValidatorPtr

Public Functions inherited from sgns::IInputValidator

Name
virtual ~IInputValidator() =default
Destroys the input validator.
void Register(const std::string & chain_id, ValidatorPtr validator)
ValidatorPtr Get(const std::string & chain_id)

Public Functions Documentation

function SetRpcEndpoints

void SetRpcEndpoints(
    const std::string & chain_id,
    std::vector< WeightedRpcEndpoint > endpoints
)

Configure weighted RPC endpoints for a source chain.

Parameters:

  • chain_id Source chain identifier (e.g. "1" for Ethereum).
  • endpoints Weighted RPC endpoint URLs for verifying burn receipts.

function ValidateUTXOParameters

virtual bool ValidateUTXOParameters(
    const UTXOTxParameters & params,
    const std::string & address,
    const UTXOManager & utxo_manager
) const override

Validates local UTXO structure for externally sourced claims.

Parameters:

  • params UTXO inputs and outputs carried by the transaction.
  • address Source address; ignored for public-chain validation.
  • utxo_manager Local UTXO manager; ignored for public-chain validation.

Return: True when both input and output lists are non-empty.

Reimplements: sgns::IInputValidator::ValidateUTXOParameters

function ValidateWitness

virtual bool ValidateWitness(
    const ConsensusSubject & subject,
    const std::shared_ptr< GeniusTransaction > & tx,
    const UTXOTxParameters & params,
    const std::shared_ptr< Blockchain > & blockchain
) const override

Validates the external witness data supplied by consensus.

Parameters:

  • subject Consensus subject carrying UTXO commitment data.
  • tx Transaction that references the public-chain source event.
  • params UTXO inputs and outputs carrying the source reference and minted outputs.
  • blockchain Blockchain service; currently unused by public-chain validation.

Return: True when tx is present, params are non-empty, and the source reference verification succeeds.

Reimplements: sgns::IInputValidator::ValidateWitness

function RequiresConsensusUTXOData

inline virtual bool RequiresConsensusUTXOData() const override

Public-chain validation does not require local UTXO witness data.

Return: Always false.

Reimplements: sgns::IInputValidator::RequiresConsensusUTXOData

Bridge mints use the EVM transaction hash as input, not a local UTXO. Receipt verification is handled via RPC in VerifyPublicChainSmartContract.

function SetTransportFactory

inline void SetTransportFactory(
    TransportFactory factory
)

Inject a custom transport factory for DI-based mock support.

Parameters:

  • factory Callable taking (url, timeout) → unique_ptr.

When set, every call to VerifyPublicChainSmartContract() will use this factory to create transport instances instead of the default RpcHttpTransport factory. Not called in production (D-16).

function GetFirstRpcUrl

inline std::optional< std::string > GetFirstRpcUrl(
    const std::string & chain_id
) const

Returns the first RPC endpoint URL for a given chain ID, if any exist.

Parameters:

  • chain_id Numeric chain ID as a string (e.g. "1" for Ethereum).

Return: The first endpoint URL if one exists, std::nullopt otherwise.

Used by the startup catch-up scan to obtain an RPC URL for eth_getLogs queries without needing to re-parse the ChainList provider data.

function GetSlotHash

std::vector< uint8_t > GetSlotHash(
    size_t slot_index,
    const std::string & chain_id
) const

Returns the SHA-256 hash of an endpoint URL for a vote slot (Phase 6, D-01).

Parameters:

  • slot_index Vote slot (0, 1, or 2).
  • chain_id Source chain identifier.

Return: 32-byte SHA-256 of the qualifying endpoint URL, or an empty vector when no qualifying endpoint exists or the slot/chain is unknown.

Slot semantics (per the slot-based RPC-hash voting model):

  • slot 0: first DIRECT_API endpoint (consensus_weight >= 50, D-02).
  • slot 1: first PUBLIC endpoint (consensus_weight < 50).
  • slot 2: second PUBLIC endpoint (consensus_weight < 50).

The hash is over the endpoint's raw url string (UTF-8), NOT the resolved URL nor the bridge_contract_address/event_topic0 fields, so the hash is stable across config reloads and deterministic across peers that share config (T-06-03). An empty vector signals abstention (D-05).

function GetFirstConfiguredChainId

inline std::optional< std::string > GetFirstConfiguredChainId() const

Returns the first configured chain id, if any (Phase 6, D-01).

Return: First configured chain id, or std::nullopt when none configured.

Used by GeniusNode's slot-hash populator lambda to resolve a chain context for single-chain deployments (multi-chain resolution is a future enhancement). Read-only and additive (D-10: Tier 1 untouched).


Updated on 2026-06-28 at 18:54:57 -0700