The Network Service (token/services/network) is the bridge layer of Panurus. It provides a consistent, backend-agnostic interface that translates generic token operations into the specific formats and protocols required by the underlying Distributed Ledger Technology (DLT), such as Hyperledger Fabric, FabricX, or Ethereum/EVM.
The Network Service abstracts the complexities of different ledger implementations, allowing Application Services (like TTX) and Token Drivers to remain agnostic of the specific network backend. This abstraction enables Panurus to support multiple DLT platforms through a pluggable driver architecture.
graph TB
subgraph "Application Layer"
TTX[TTX Service]
Driver[Token Driver]
end
subgraph "Network Service (Bridge)"
NS[Network Service Interface]
Provider[Network Provider]
end
subgraph "Driver Layer"
FabricD[Fabric Driver]
FabricXD[FabricX Driver]
EVMD[EVM Driver]
end
subgraph "DLT Backends"
Fabric[Hyperledger Fabric<br/>with Token Chaincode]
FabricX[FabricX<br/>with FSC Endorsers]
EVM[Ethereum/EVM<br/>with FSC Endorsers]
end
TTX --> NS
Driver --> NS
NS --> Provider
Provider --> FabricD
Provider --> FabricXD
Provider --> EVMD
FabricD --> Fabric
FabricXD --> FabricX
EVMD --> EVM
The Network Service uses a driver pattern to enable pluggable backend implementations. This design separates the interface from the implementation, allowing Panurus to support different DLT platforms without changing application code.
driver.Network)
driver.Driver)
New(network, channel string) (Network, error)Provider)
sequenceDiagram
participant App as Application
participant Provider as Network Provider
participant Driver as Network Driver
participant Backend as DLT Backend
App->>Provider: GetNetwork(network, channel)
Provider->>Driver: New(network, channel)
Driver->>Backend: Initialize connection
Backend-->>Driver: Connection established
Driver-->>Provider: Network instance
Provider-->>App: Network instance
App->>Provider: RequestApproval(...)
Provider->>Backend: Execute via driver
Backend-->>Provider: Endorsed envelope
Provider-->>App: Result
Key Benefits:
The Network Service is responsible for several critical functions:
Translating high-level token requests (e.g., “Transfer 10 tokens from A to B”) into ledger-specific transaction envelopes. Each driver implementation handles the specifics of its target platform.
Broadcasting endorsed transaction envelopes to the network’s ordering service via Broadcast.
Monitoring the ledger for transaction commitment. It provides a listener-based API (FinalityListener) that notifies Panurus when a transaction is validated or invalidated.
The Network Service also instantiates the Transaction Recovery Service from the Storage Service to handle pending transactions that may have lost their finality listeners.
Acting as the primary fetcher for the system’s Public Parameters. It monitors the ledger for updates and ensures Panurus is synchronized with the latest cryptographic material.
Providing a Ledger interface to retrieve the current state of tokens and other relevant ledger data.
The driver.Network interface defines the following key methods:
Name() string - Returns the network identifierChannel() string - Returns the channel/partition nameNormalize(opt) (*ServiceOptions, error) - Populates default service options from network configurationConnect(ns) ([]ServiceOption, error) - Initializes the connection to the backend for a namespaceBroadcast(ctx, blob) error - Submits transactions to ordering serviceNewEnvelope() Envelope - Creates a new transaction envelopeRequestApproval(...) (Envelope, error) - Requests transaction endorsementSetupPublicParams(...) (Envelope, error) - Submits new/updated public parameters, including first-time namespace setupComputeTxID(*TxID) string - Calculates transaction identifiersFetchPublicParameters(namespace) ([]byte, error) - Retrieves public parametersQueryTokens(...) ([][]byte, error) - Queries token stateAreTokensSpent(...) ([]bool, error) - Checks token spent statusLocalMembership() LocalMembership - Returns the local membership service for node identitiesAddFinalityListener(...) error - Registers finality notificationsGetTransactionStatus(...) (status, hash, message, error) - Retrieves current status and token request hash for a transactionLookupTransferMetadataKey(...) ([]byte, error) - Scans the ledger for transfer-action metadataLedger() (Ledger, error) - Provides ledger accessPanurus currently provides network driver implementations for the following platforms:
Traditional Fabric network with token chaincode deployed on peers for endorsement and validation.
Documentation: Network Service - Fabric Implementation
Key Features:
Optimized Fabric variant where FSC nodes act as endorsers, eliminating the need for traditional chaincode.
Documentation: Network Service - FabricX Implementation
Key Features:
Network driver for Ethereum and EVM-compatible blockchains, implemented in
x/token/services/network/evm.
The design document describes two architectural approaches; only Approach 2 (Pre-Order Execution
with FSC Endorsers) is implemented and shipped today. It supports both the fabtoken and
zkatdlog/nogh token drivers.
Documentation:
Key Features (Approach 2, shipped):
StateDelta with EIP-712; the chain only checks endorser signatures, public-parameters version, and spend legalityTokenState clone per TMS; one Ethereum transaction per token requestfabtoken and zkatdlog/nogh are both graph-revealing)Key Considerations:
Each Token Management Service (TMS) must be mapped to a network and channel:
token:
tms:
my-tms-id:
network: my-network-name # Matches fsc.networks configuration
channel: my-channel-name
namespace: my-chaincode-id
The Network Service uses this configuration to:
Drivers are registered during system initialization:
// Example: Registering a network driver
networkProvider := network.NewProvider(configService)
networkProvider.RegisterDriver(fabricDriver)
networkProvider.RegisterDriver(fabricxDriver)
The provider automatically selects the appropriate driver based on the network configuration when GetNetwork() is called.
The Network Service instantiates and manages the Transaction Recovery Service provided by the Storage Service. This integration ensures that pending transactions are automatically recovered if their finality listeners are lost due to node restarts, network interruptions, or other failures.
Key Integration Points:
For detailed information about the recovery mechanism, see Storage Service - Transaction Recovery.