Multi-party system for enterprise data flows. Allows developers to build decentralized applications rapidly on a blockchain-backed business network, with REST APIs and an event-driven programming model.

Hyperledger FireFly

codecov Go Report Card FireFy Documentation build

Hyperledger FireFly

Hyperledger FireFly is an API and data orchestration layer on top of core blockchain technologies.

It implements a multi-party system for building enterprise decentralized applications.

  • Transaction submission and event streaming
    • Radically simplified API access to your on-chain smart contracts
  • Multi-protocol blockchain integration
  • Developer friendly event-driven REST & WebSocket APIs
    • For building multi-party business applications that solve real enterprise use cases
  • Digital assets
    • Tokens and NFTs ready for use, with indexed transaction history, and easy extension/customization
  • On-chain/off-chain orchestration
    • Enterprise data flows backed by blockchain, with secure off-chain transfer of private docs+data
    • Pluggable private data exchange / messaging (inc. HTTPS + Mutual TLS)
  • Identity, data format, and interface distribution
    • Broadcast data schema, proven identity, and on-chain logic integration APIs across the network
    • Pluggable data distribution network with batch optimization (inc. IPFS)
    • Pluggable DIDs for identity and multi-protocol on-chain interface definition are work in progress
  • Microservice architecture, optimized for docker deployment
    • Fully pluggable architecture, embracing multiple runtime technologies (Go, Node.js, Java etc.)
  • Built by developers for developers
    • Ready to go in minutes, with a CLI, built-in UI explorer, OpenAPI spec, and samples
  • Data operations at the boundary of your data center
    • Fast database cache + audit of all data flowing out of your enterprise, to the network

Quick Start Guide

Follow the get started guide in the doc, and your local developer environment will be up in minutes.

You'll have your own private multi-party system, comprising a blockchain (Ethereum/Fabric) with API/Event connectors, a Private Data Exchange, an IPFS data sharing network, and ERC-1155 Token/NFT implementations.

All with the Hyperledger FireFly Explorer UI of course, and a samples to get you building fast.

FireFly Explorer

API Reference

All the Hyperledger FireFly APIs are self-documenting via Swagger, and you can just open them up on /api on your running FireFly.

Or you can check out the latest API here.

Documentation

https://hyperledger.github.io/firefly

Multi-party Systems

Hyperledger Firefly is an implementation of a multi-party system.

Multi-party System

Multi-party systems have the potential to unlock the next wave of digitization in core transaction processing systems. They combine the best features of the existing secure data exchange models for API/WebService/Messaging integration of business data/processes today, with the new technologies of the blockchain revolution.

Working within existing regulatory environments, and existing IT and data security governance frameworks, multi-party systems provide a secure gateway for organizations to participate securely in blockchain backed business ecosystems.

They are the middleware tier for decentralized applications, which are fundamentally different to centralized/SaaS applications because they are hosted independently by each IT organization, and can be customized by each organization to their own IT landscape. These applications communicate through a mix of blockchain, and private data exchange, to execute multi-party transactions at scale - powered by revolutionary new programming constructs like digital assets.

The next wave of business applications that build in a decentralized way on multi-party systems, can orchestrate data and business process flows across organizational boundaries. The integrity of the end-to-end transactions can be established throughout its lifecycle, rather than requiring complex handoff and compensation logic each time a new party performs its step. Yet the autonomy of each business and IT team is maintained in a way that could not be by pooling data and business logic in a 3rd party centralized business application.

Blockchain and other advanced cryptography technologies like zero-knowledge proofs (ZKPs), and trusted execution environments (TEEs), are the core technologies that enable this new model of cross-organizational data flow.

In an enterprise context these raw technologies are necessary, but not sufficient. Organizations need a comprehensive toolset at the boundary of their existing core systems of record to govern the flow of data out of their own secure IT infrastructure.

  • To store the private data staged in canonical formats ready for exchange with other parties
  • For retrieval of the state of transaction and data flows in-flight in the system
  • To provide an audit record and reporting system for what has been shared so far
  • Providing event-driven integration APIs fit for purpose to integrate to the core systems of record

This all needs to be fast, secure and reliable.

Learn more in the Hyperledger FireFly Documentation

Event-driven programming model

The core programming model of FireFly is event-driven:

  • FireFly delivers data and actions from your application instance, reliably to on-chain logic and privately to other parties in the network
  • FireFly receives data and actions from on-chain, and other parties in the network, correlates them, and once complete and verified delivers them to your application for processing

For this reason FireFly has a pluggable database that keeps track of all those interactions.

This database is not intended to replace your application database (apart from in early PoC scenarios). Instead it complements it.

You process the events from the network as they happen, including ones you submit because they have to be ordered with other events in the network (learn more).

Then you update the indexed business objects in your own database, as a result of the ordered state changes that come from the network. At any point you can go back and retrieve the set of events that caused that update to your "latest" state, whether that's on-chain transaction events, digital asset transfers (Tokens/NFTs), private data transfers, or a combination.

FireFly Event-driven Programming API Model

Learn more about Hyperledger FireFly Architecture

Hyperledger FireFly project status

A number projects are actively building on Hyperledger FireFly today, and the current feature set and API is sufficient to build many decentralized applications. Some of the microservice components have matured through a number of years (including production adoption), others are new, and some areas are still evolving quickly and subject to flux in the APIs and feature set.

Overall, the community is working hard towards a V1.0 release.

A good reference for the scope of the V1.0 release is included in issue #117. You might be interested in getting involved.

Git repositories

There are multiple Git repos making up the Hyperledger FireFly project, and this list is likely to grow as additional pluggable extensions come online in the community:

Contributing

Interested in contributing to the community?

Check out our Contributor Guide, and welcome!.

Navigating this core repo

Directories:

  • internal: The core Golang implementation code
  • pkg: Interfaces intended for external project use
  • cmd: The command line entry point
  • smart_contracts: smart contract code for Firefly's onchain logic, with support for Ethereum and Hyperledger Fabric in their respective sub-directories

Full code layout here

FireFly Core code hierarchy

┌──────────┐  ┌───────────────┐
│ cmd      ├──┤ firefly   [Ff]│  - CLI entry point
└──────────┘  │               │  - Creates parent context
              │               │  - Signal handling
              └─────┬─────────┘
                    │
┌──────────┐  ┌─────┴─────────┐  - HTTP listener (Gorilla mux)
│ internal ├──┤ api       [As]│    * TLS (SSL), CORS configuration etc.
└──────────┘  │ server        │    * WS upgrade on same port
              │               │  - REST route definitions
              └─────┬─────────┘    * Simple routing logic only, all processing deferred to orchestrator
                    │
              ┌─────┴─────────┐  - REST route definition framework
              │ openapi   [Oa]│    * Standardizes Body, Path, Query, Filter semantics
              │ spec          |      - OpenAPI 3.0 (Swagger) generation
              └─────┬─────────┘    * Including Swagger. UI
                    │
              ┌─────┴─────────┐  - WebSocket server
              │           [Ws]│    * Developer friendly JSON based protocol business app development
              │ websockets    │    * Reliable sequenced delivery
              └─────┬─────────┘    * _Event interface [Ei] supports lower level integration with other compute frameworks/transports_
                    │
              ┌─────┴─────────┐  - Core data types
              │ fftypes   [Ft]│    * Used for API and Serialization
              │               │    * APIs can mask fields on input via router definition
              └─────┬─────────┘
                    │
              ┌─────┴─────────┐  - Core runtime server. Initializes and owns instances of:
              │           [Or]│    * Components: Implement features
  ┌───────┬───┤ orchestrator  │    * Plugins:    Pluggable infrastructure services
  │       │   │               │  - Exposes actions to router
  │       │   └───────────────┘    * Processing starts here for all API calls
  │       │
  │  Components: Components do the heavy lifting within the engine
  │       │
  │       │   ┌───────────────┐  - Maintains a view of the entire network
  │       ├───┤ network   [Nm]│    * Integrates with network permissioning [NP] plugin
  │       │   │ map           │    * Integrates with broadcast plugin
  │       │   └───────────────┘    * Handles hierarchy of member identity, node identity and signing identity
  │       │
  │       │   ┌───────────────┐  - Broadcast of data to all parties in the network
  │       ├───┤ broadcast [Bm]│    * Implements dispatcher for batch component
  │       │   │ manager       |    * Integrates with public storage interface [Ps] plugin
  │       │   └───────────────┘    * Integrates with blockchain interface [Bi] plugin
  │       │
  │       │   ┌───────────────┐  - Send private data to individual parties in the network
  │       ├───┤ private   [Pm]│    * Implements dispatcher for batch component
  │       │   │ messaging     |    * Integrates with the data exchange [Dx] plugin
  │       │   └──────┬────────┘    * Messages can be pinned and sequenced via the blockchain, or just sent
  │       │          │
  │       │   ┌──────┴────────┐  - Groups of parties, with isolated data and/or blockchains
  │       │   │ group     [Gm]│    * Integrates with data exchange [Dx] plugin
  │       │   │ manager       │    * Integrates with blockchain interface [Bi] plugin
  │       │   └───────────────┘
  │       │
  │       │   ┌───────────────┐  - Private data management and validation
  │       ├───┤ data      [Dm]│    * Implements dispatcher for batch component
  │       │   │ manager       │    * Integrates with data exchange [Dx] plugin
  │       │   └──────┬────────┘    * Integrates with blockchain interface [Bi] plugin
  │       │          │
  │       │   ┌──────┴────────┐  - JSON data shema management and validation (architecture extensible to XML and more)
  │       │   │ json      [Jv]│    * JSON Schema validation logic for outbound and inbound messages
  │       │   │ validator     │    * Schema propagatation
  │       │   └──────┬────────┘    * Integrates with broadcast plugin
  │       │          │
  │       │   ┌──────┴────────┐  - Binary data addressable via ID or Hash
  │       │   │ blobstore [Bs]│    * Integrates with data exchange [Dx] plugin
  │       │   │               │    * Hashes data, and maintains mapping to payload references in blob storage
  │       │   └───────────────┘    * Integrates with blockchain interface [Bi] plugin
  │       │
  │       │   ┌───────────────┐
  │       ├───┤ identity [Im] │  - Central identity management service across components
  │       │   │ manager       │    * Resolves API input identity + key combos (short names, formatting etc.)
  │       │   │               │    * Resolves registered on-chain signing keys back to identities
  │       │   └───────────────┘    * Integrates with Blockchain Interface and plugable Identity Interface (TBD)
  │       │
  │       │   ┌───────────────┐  - Private data management and validation
  │       ├───┤ event     [Em]│    * Implements dispatcher for batch component
  │       │   │ manager       │    * Integrates with data exchange [Dx] plugin
  │       │   └──────┬────────┘    * Integrates with blockchain interface [Bi] plugin
  │       │          │
  │       │   ┌──────┴────────┐  - Handles incoming external data
  │       │   │           [Ag]│    * Integrates with data exchange [Dx] plugin
  │       │   │ aggregator    │    * Integrates with public storage interface [Ps] plugin
  │       │   │               │    * Integrates with blockchain interface [Bi] plugin
  │       │   │               │  - Ensures valid events are dispatched only once all data is available
  │       │   └──────┬────────┘    * Context aware, to prevent block-the-world scenarios
  │       │          │
  │       │   ┌──────┴────────┐  - Subscription manager
  │       │   │           [Sm]│    * Creation and management of subscriptions
  │       │   │ subscription  │    * Creation and management of subscriptions
  │       │   │ manager       │    * Message to Event matching logic
  │       │   └──────┬────────┘
  │       │          │
  │       │   ┌──────┴────────┐  - Manages delivery of events to connected applications
  │       │   │ event     [Ed]│    * Integrates with data exchange [Dx] plugin
  │       │   │ dispatcher    │    * Integrates with blockchain interface [Bi] plugin
  │       │   └───────────────┘
  │       │
  │       │   ┌───────────────┐  - Token operations
  │       ├───┤ asset     [Am]│    * NFT coupling with contexts
  │       │   │ manager       │    * Transfer coupling with data describing payment reason
  │       │   │               │  - ...
  │       │   └───────────────┘
  │       │
  │       │   ┌───────────────┐
  │       ├───┤ sync /   [Sa] │  - Sync/Async Bridge
  │       │   │ async bridge  │    * Provides synchronous request/reply APIs
  │       │   │               │    * Translates to underlying event-driven API
  │       │   └───────────────┘
  │       │
  │       │   ┌───────────────┐  - Aggregates messages and data, with rolled up hashes for pinning
  │       ├───┤ batch     [Ba]│    * Pluggable dispatchers
  │       │   │ manager       │  - Database decoupled from main-line API processing
  │       │   │               │    * See architecture diagrams for more info on active/active sequencing
  │       │   └──────┬────────┘  - Manages creation of batch processor instances
  │       │          │
  │       │   ┌──────┴────────┐  - Short lived agent spun up to assemble batches on demand
  │       │   │ batch     [Bp]│    * Coupled to an author+type of messages
  │       │   │ processor     │  - Builds batches of 100s messages for efficient pinning
  │       │   │               │    * Aggregates messages and data, with rolled up hashes for pinning
  │       │   └───────────────┘  - Shuts down automatically after a configurable inactivity period
  │       ... more TBD
  │
Plugins: Each plugin comprises a Go shim, plus a remote agent microservice runtime (if required)
  │
  │           ┌───────────────┐  - Blockchain Interface
  ├───────────┤           [Bi]│    * Transaction submission - including signing key management
  │           │ blockchain    │    * Event listening
  │           │ interface     │    * Standardized operations, and custom on-chain coupling
  │           └─────┬─────────┘
  │                 │
  │                 ├─────────────────────┬───────────────────┐
  │           ┌─────┴─────────┐   ┌───────┴───────┐   ┌───────┴────────┐
  │           │ ethereum      │   │ corda         │   │ fabric         │
  │           └───────────────┘   └───────────────┘   └────────────────┘
  │
  │           ┌───────────────┐  - P2P Content Addresssed Filesystem
  ├───────────┤ public    [Pi]│    * Payload upload / download
  │           │ storage       │    * Payload reference management
  │           │ interface     │
  │           └─────┬─────────┘
  │                 │
  │                 ├───────── ... extensible to any shared storage sytem, accessible to all members
  │           ┌─────┴─────────┐
  │           │ ipfs          │
  │           └───────────────┘
  │
  │           ┌───────────────┐  - Private Data Exchange
  ├───────────┤ data      [Dx]│    * Blob storage
  │           │ exchange      │    * Private secure messaging
  │           └─────┬─────────┘    * Secure file transfer
  │                 │
  │                 ├─────────────────────┬────────── ... extensible to any private data exchange tech
  │           ┌─────┴─────────┐   ┌───────┴───────┐
  │           │ httpdirect    │   │ kaleido       │
  │           └───────────────┘   └───────────────┘
  │
  │           ┌───────────────┐  - Pluggable identity infrastructure
  ├───────────┤ identity  [Ii]│    * TBD
  │           │ interface     │    * See Identity Manager component above
  │           └───────────────┘    * See Issue
  │
  │           ┌───────────────┐  - API Authentication and Authorization Interface
  ├───────────┤ api auth  [Aa]│    * Authenticates security credentials (OpenID Connect id token JWTs etc.)
  │           │               │    * Extracts API/user identity (for identity interface to map)
  │           └─────┬─────────┘    * Enforcement point for fine grained API access control
  │                 │
  │                 ├─────────────────────┬────────── ... extensible other single sign-on technologies
  │           ┌─────┴─────────┐   ┌───────┴───────┐
  │           │ apikey        │   │ jwt           │
  │           └───────────────┘   └───────────────┘
  │
  │           ┌───────────────┐  - Database Interactions
  ├───────────┤ database  [Di]│    * Create, Read, Update, Delete (CRUD) actions
  │           │ interace      │    * Filtering and update definition interace
  │           └─────┬─────────┘    * Migrations and Indexes
  │                 │
  │                 ├───────── ... extensible to NoSQL (CouchDB / MongoDB etc.)
  │           ┌─────┴─────────┐
  │           │ sqlcommon     │
  │           └─────┬─────────┘
  │                 ├───────────────────────┬───────── ... extensible other SQL databases
  │           ┌─────┴─────────┐     ┌───────┴────────┐
  │           │ postgres      │     │ sqlite3        │
  │           └───────────────┘     └────────────────┘
  │
  │           ┌───────────────┐  - Connects the core event engine to external frameworks and applications
  ├───────────┤ event     [Ei]│    * Supports long-lived (durable) and ephemeral event subscriptions
  │           │ interface     │    * Batching, filtering, all handled in core prior to transport
  │           └─────┬─────────┘    * Interface supports connect-in (websocket) and connect-out (broker runtime style) plugins
  │                 │
  │                 ├───────── ... extensible to integrate off-chain compute framework (Hyperledger Avalon, TEE, ZKP, MPC etc.)
  │                 │          ... extensible to additional event delivery brokers/subsystems (Webhooks, Kafka, AMQP etc.)
  │           ┌─────┴─────────┐
  │           │ websockets    │
  │           └───────────────┘
  │  ... more TBD

  Additional utility framworks
              ┌───────────────┐  - REST API client
              │ rest      [Re]│    * Provides convenience and logging
              │ client        │    * Standardizes auth, config and retry logic
              └───────────────┘    * Built on Resty

              ┌───────────────┐  - WebSocket client
              │ wsclient  [Wc]│    * Provides convenience and logging
              │               │    * Standardizes auth, config and reconnect logic
              └───────────────┘    * Built on Gorilla WebSockets

              ┌───────────────┐  - Translation framework
              │ i18n      [In]│    * Every translations must be added to `en_translations.json` - with an `FF10101` key
              │               │    * Errors are wrapped, providing extra features from the `errors` package (stack etc.)
              └───────────────┘    * Description translations also supported, such as OpenAPI description

              ┌───────────────┐  - Logging framework
              │ log       [Lo]│    * Logging framework (logrus) integrated with context based tagging
              │               │    * Context is used throughout the code to pass API invocation context, and logging context
              └───────────────┘    * Example: Every API call has an ID that can be traced, as well as a timeout

              ┌───────────────┐  - Configuration
              │ config    [Co]│    * File and Environment Variable based logging framework (viper)
              │               │    * Primary config keys all defined centrally
              └───────────────┘    * Plugins integrate by returning their config structure for unmarshaling (JSON tags)

Comments
  • FF-Perf: Websocket events appear to be dropped

    FF-Perf: Websocket events appear to be dropped

    Test: 25 broadcasts, 25 private messages, one subscription

    In this test, 25 workers were kicked off for both broadcasts and private messages. Shortly after the test is kicked off, workers are not receiving websocket events, preventing them from proceeding. The ff-perf.log has logs of message IDs and event IDs that can be used to correlate to the firefly logs that are also attached. Every minute, the perf test checks for messages that have not been confirmed in > 1 minute, do a Ctrl+F for Delinquent Messages and you will see the messageID that has not been confirmed yet, along with the time it was sent at.

    image

    log_ethconnect_0.log.zip log_firefly_core_0.log.zip ff-perf.log

  • Improved event sequencing and dispatching

    Improved event sequencing and dispatching

    In https://github.com/hyperledger/firefly/issues/493#issuecomment-1035538293 we found we missed an event due to the dispatcher skipping past events:

    [2022-02-10T20:32:14.213Z] DEBUG Dispatcher event state: readahead=0 candidates=5 matched=5 inflight=0 queued=0 dispatched=5 dispatchable=0 lastAck=37559 nacks=0 highest=37559 pid=1 role=ed[d2ff7b72-504d-40dd-ab3e-e325c2b7a5d9] sub=3cf508e4-21a7-4f00-8ad0-a6d08a0703d0/default:perf_54c7faaf-ad...
    [2022-02-10T20:32:14.366Z] DEBUG Dispatcher event state: readahead=0 candidates=1 matched=0 inflight=0 queued=0 dispatched=0 dispatchable=0 lastAck=0 nacks=0 highest=37595 pid=1 role=ed[d2ff7b72-504d-40dd-ab3e-e325c2b7a5d9] sub=3cf508e4-21a7-4f00-8ad0-a6d08a0703d0/default:perf_54c7faaf-ad...
    

    The root cause here is we are writing events concurrently in many goroutines, using different DB transactions - so it's not possible to detect the order of those via a separate DB listener.

    In this issue we will track the solution.

  • Token support

    Token support

    FireFly should support the creation and tracking of both fungible and non-fungible tokens. Some of the key concepts that must be supported:

    • Creating multiple types of tokens
    • Minting, transferring, and burning tokens of a given type
    • Tracking transaction history and current account balances (must include operations initiated by FireFly and also those initiated on-chain with no trigger from FireFly)
    • Attaching data to a token transfer, for correlating off-chain items with the transfer event on-chain

    The first connector will be focused on Ethereum tokens support via ERC1155. Source code for the connector is here: https://github.com/hyperledger/firefly-tokens-erc1155

    This functionality is part of milestone #117.

    Cross-chain functionality, including atomic swaps and the like, will not be part of this design effort (but will be part of a future item).

  • Enhancements to event data & websocket event filtering

    Enhancements to event data & websocket event filtering

    Events are extremely important to FireFly applications, but purposefully don't contain a large amount of information. After speaking with @eberger727 and @awrichar it was decided adding a new field, ReferenceType, would be useful to help developers determine which tables the events ref refers.

    Screen Shot 2022-02-22 at 4 48 19 PM

    The above events break down into the following categories, which will be the possible values of ReferenceType

    • TokenTransfer
    • TransferOperation
    • Messages
    • BlockchainEvent
    • TransactionSubmitted
    • TokenApproval [0]
    • TokenApprovalOperations [0]

    [0]: Coming in https://github.com/hyperledger/firefly/pull/529

  • Support for all token pool creation scenarios

    Support for all token pool creation scenarios

    Background

    Token pools are initialized with two steps:

    1. The actual pool is initialized on a blockchain smart contract
    2. The pool details (namespace, name, etc) are announced as a FireFly definition broadcast

    The pool creator is responsible for sending 2 only after 1 is confirmed. However, because these steps may or may not occur on the same blockchain, there are multiple possible ways for them to play out.

    Scenarios

    A) 1 and 2 both arrive and are guaranteed to be in that order for all nodes

    This is true for the case where tokens and messages are backed by the same blockchain (such as when using Ethereum with ERC1155). Each node may receive and record the blockchain transaction, then fill in the rest of the pool details after the announcement broadcast.

    B) 1 and 2 both arrive, but 2 may arrive before 1

    This is possible in cases where tokens and messages are backed by different blockchains. It should be uncommon, but networking conditions (for instance) could cause a particular node to receive 2 quickly while 1 is delayed. There must be a way to save the details from 2 but "rewind" and complete the message processing once 1 is received.

    C) Only 2 arrives, and 1 must be looked up on demand

    This is envisioned for cases where the "token pool" is a pre-existing set of tokens (could be on mainnet or a pre-existing private chain). In this case, step 1 for the author involves simply passing details about the existing tokens, but there will be no new blockchain transaction to define the pool. Therefore, the other nodes receiving the broadcast in step 2 must also have a way to lookup and verify the pre-existing token pool.

  • FIR-4 (rich query updates) and FIR-7 (DX manifests) integration to onchain-logic branch

    FIR-4 (rich query updates) and FIR-7 (DX manifests) integration to onchain-logic branch

    Delivery PR for this FIRs into the onchain-logic next-release branch:

    • https://github.com/hyperledger/firefly-fir/pull/4
    • https://github.com/hyperledger/firefly-fir/pull/7
  • Implement and use UpsertOptimization for groups

    Implement and use UpsertOptimization for groups

    Proposed fix for #512

    By implementing the UpsertOptimization pattern for Groups, it lets us state UpsertOptimizationNew everywhere we're currently just trying to do a query-then-insert approach. UpsertOptimizationNew results in an attempt-insert, then attempt-update approach - which should handle+swallow a duplicate key exception (rather than rolling back the TX).

  • Identity and signing key - architectural update

    Identity and signing key - architectural update

    We have some problems in the codebase today with a half-formed identity approach:

    • A Message contains a single Author field, and it is ambiguous whether this is the identity or the signing key
    • A shim Identity plugin designed to resolve an opaque string (such as a DID) into an identity on the platform... but without a definition of what that identity is
    • The requirement for us to properly solve Fabric signing keys and round-trip these to events like we do in ethereum - currently blocking merge of #184
    • The fact that both Ethereum and Fabric connectors have the concept of abstract lookup keys for actual signing keys (HD Wallets in Ethereum, and CN shortnames in Fabric)
    • The requirement to handle anonymous signing of transactions for privacy preservation
    • The requirement that the database representation of identity in a Message / Token Pool or On-chain event (coming soon) etc. must be consistent in every database of members allowed to see the object, even if they didn't submit the transaction

    This issue will track a number of threads needed to resolve this.

  • Provide a blocking mode for async msgs, and add more intuitive POST routes returning types not messages

    Provide a blocking mode for async msgs, and add more intuitive POST routes returning types not messages

    Implements #112

    • Does lots of dependency work to allow the sync-async bridge to be callable from broadcast/privatemessaging/networkmap
      • Adds a syshandlers package for the system event handlers that we previously bundled into events
      • Adds a sysmessaging that abstracts broadcast/private sends, and reply exchanges
      • Updates the orchestrator initialixation order to manage passing things between the internal components
    • Deprecates all the old routes
    • Adds new routes that:
      • Are all grouped on the path with the resources they create
      • Consistently return the object type that is the input
      • Have a ?confirm option to block until the confirmation event arrives (or a 500 on the case it's rejected)
    • Leaves the old routes there functioning exactly as today
      • Gives time for the CLI setup, and other consumers to move to the new routes
  • Perf-Test: Websocket events not being sent

    Perf-Test: Websocket events not being sent

    The FireFly performance tests use go routines to send multiple requests to an API at the same time. These routines then wait for their specific websocket event to confirm their transaction was completed before moving on to its next task.

    In v0.11.5 of FireFly, these websocket events were being sent correctly, allowing for workers to proceed as expected.

    In v0.12.0 of FireFly, one websocket event is received, then no more websocket events come through, resulting in workers not being able to confirm that their transaction completed and moving on to their next task.

    ff-perf v0-11-5.log ff-perf v0-12-0.log v0-12-0-ff_core.log

  • Add E2E tests for contract termination

    Add E2E tests for contract termination

    Part of FIR-12

    ~~Depends on https://github.com/hyperledger/firefly-cli/pull/197~~ ~~In a chain with #904~~

    Add a new E2E test which dynamically:

    • deploys two instances of the FireFly multiparty contract
    • dynamically adds a new namespace to the config of both nodes
    • resets both nodes to read the config
    • sends one message on the first contract
    • performs a network migration
    • sends one message on the new contract

    There are variations of this test for both V1->V2 contract migrations and V2->V2. Notably, the V1->V2 migration can only be performed once per stack, so it is not part of the main suites. We may need to add a dedicated nightly job for this test.

    This PR also includes loads of fixes for things exposed by the E2E tests, including major changes to how the legacy ff_system namespace is managed. There can now only be one multiparty V1 contract EVER used in the history of a FireFly node, and attempting to configure any namespace with a different V1 contract is an error. The ff_system orchestrator will be initialized with that V1 config (if any is found) and will live forever (walking back some of the changes from #884), because we can never be fully sure when all pins from ff_system have been aggregated.

  • Custom errors support in FFI contract invocations and queries

    Custom errors support in FFI contract invocations and queries

    For a test solidity contract that declares custom errors like the following :

    pragma solidity ^0.8.0;
    
    error CustomError1(uint256 x, uint256 y);
    error CustomError2(string x);
    
    contract SimpleStorage {
        uint256 storedData;
    
        function set(uint256 x) public {
            if (x == 0) {
                revert CustomError1({x: x, y: x});
            }
            if (x == 1) {
                revert CustomError2({x: "This is a custom error"});
            }
            require(x > 2, "Can not equal to 2");
            storedData = x;
        }
    }
    

    Use the POST /contracts/interfaces/generate endpoint to generate the corresponding FFI:

    {
        "namespace": "default",
        "name": "simple-storage-custom-errors",
        "description": "simple-storage-custom-errors",
        "version": "1.0.0",
        "methods": [
            {
                "name": "set",
                "pathname": "",
                "description": "",
                "params": [
                    {
                        "name": "x",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ],
                            "details": {
                                "type": "uint256",
                                "internalType": "uint256"
                            },
                            "description": "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum."
                        }
                    }
                ],
                "returns": [],
                "details": {
                    "stateMutability": "nonpayable"
                }
            }
        ],
        "errors": [
            {
                "signature": "",
                "name": "CustomError1",
                "description": "",
                "params": [
                    {
                        "name": "x",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ],
                            "details": {
                                "type": "uint256",
                                "internalType": "uint256"
                            },
                            "description": "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum."
                        }
                    },
                    {
                        "name": "y",
                        "schema": {
                            "oneOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ],
                            "details": {
                                "type": "uint256",
                                "internalType": "uint256"
                            },
                            "description": "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum."
                        }
                    }
                ]
            }
        ]
    }
    

    Then when invoking the generated API:

    matching custom error

    curl --location --request POST 'http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/invoke/set' \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "input": {
        "x": 0
      }
    }'
    

    response:

    {
        "error": "FF10111: Error from ethereum connector: FF23021: EVM reverted: CustomError1(\"0\", \"0\")"
    }
    

    no matching custom error (raw error data returned):

    curl --location --request POST 'http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/invoke/set' \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "input": {
        "x": 1
      }
    }'
    

    response:

    {
        "error": "FF10111: Error from ethereum connector: FF23022: EVM reverted: 0x60b7d47e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001654686973206973206120637573746f6d206572726f7200000000000000000000"
    }
    

    regular error from the require()

    curl --location --request POST 'http://127.0.0.1:5000/api/v1/namespaces/default/apis/simple-storage/invoke/set' \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "input": {
        "x": 2
      }
    }'
    

    response:

    {
        "error": "FF10111: Error from ethereum connector: FF23021: EVM reverted: Can not equal to 2"
    }
    
  • Add ability to bind a contract interface to a token pool

    Add ability to bind a contract interface to a token pool

    Part of FIR-16. Depends on https://github.com/hyperledger/firefly-tokens-erc20-erc721/pull/106.

    Discussion about the overall architecture/usefulness of this proposed feature should be directed to FIR-16, while discussion here should focus on specific technical details of the current proposed approach.

    This adds the ability for FireFly to provide ABI details to a token connector, making it easier for the token connector to know the shape of the underlying contract it is dealing with (vs. having to probe/guess at the methods available).

    Notes

    • This feature is only useful to users who have significant knowledge of the underlying token contract that sits on the other side of their token connector.
    • It's likely to be most useful when creating a pool against a pre-deployed contract - ie when passing config.address. Worth mentioning that FireFly doesn't really "know" you can create pools against pre-deployed contracts (as config is opaque), but it's up to the user to understand the combination of features that are useful here.
    • Theoretically you could create a factory contract that deploys custom ERC20/ERC721 instances, and then you'd need to pass interface on every pool creation even while relying on the factory sitting on the other side of the token connector to do the deploy. Seems like a less useful combo, but calling it out here for completeness.
  • Add support for passing custom HTTP headers through

    Add support for passing custom HTTP headers through

    Depends on https://github.com/hyperledger/firefly-common/pull/41

    Adds support for setting a list of HTTP headers to put on the request Context. If an FFResty client is also to pass headers through, it will set all the same headers on any request that it makes.

    Example config:

    api:
      address: 0.0.0.0
      port: 5000
      publicURL: http://127.0.0.1:5000
      passthroughHeaders:
        - X-SuperCoolCustomHeader
    plugins:
      blockchain:
        - ethereum:
            ethconnect:
              url: http://127.0.0.1:5102
              passthroughHeadersEnabled: true
    

    This would configure FireFly to pass a header named X-SuperCoolCustomHeader through from an HTTP request all the way to the Ethereum blockchain connector.

  • FireFly crash if a token pool event is received with an empty data string

    FireFly crash if a token pool event is received with an empty data string

    If "poolDataString" is an empty string and therefore "poolData" is nil, this line results in a nil pointer dereference.

    https://github.com/hyperledger/firefly/blob/490745489fe98779cff07821d19ba7a83b8421bf/internal/tokens/fftokens/fftokens.go#L335

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xbef3d1]
    
    goroutine 58 [running]:
    github.com/hyperledger/firefly/internal/tokens/fftokens.(*FFTokens).handleTokenPoolCreate(0xc0002cf960, {0x1093520, 0xc0007e1ec0}, 0xc000d3a630, 0x0)
    	/firefly/internal/tokens/fftokens/fftokens.go:335 +0x371
    github.com/hyperledger/firefly/internal/tokens/fftokens.(*FFTokens).handleMessage(0xc0002cf960, {0x1093520, 0xc0007e1d00}, {0xc00087b000, 0x3f3, 0x400})
    	/firefly/internal/tokens/fftokens/fftokens.go:511 +0x434
    github.com/hyperledger/firefly/internal/tokens/fftokens.(*FFTokens).handleMessage(0xc0002cf960, {0x10935c8, 0xc00024d530}, {0xc000840100, 0x44c, 0x580})
    	/firefly/internal/tokens/fftokens/fftokens.go:506 +0x878
    github.com/hyperledger/firefly/internal/tokens/fftokens.(*FFTokens).eventLoop(0xc0002cf960)
    	/firefly/internal/tokens/fftokens/fftokens.go:553 +0x28f
    created by github.com/hyperledger/firefly/internal/tokens/fftokens.(*FFTokens).Init
    	/firefly/internal/tokens/fftokens/fftokens.go:234 +0x296
    
    
Blockchain-go - A repository that houses a blockchain implemented in Go

blockchain-go This is a repository that houses a blockchain implemented in Go. F

May 1, 2022
This is a close to decentralized RSS3 Network implementation of RSS3 protocol v0.4.0 with full indexing function in Go
This is a close to decentralized RSS3 Network implementation of RSS3 protocol v0.4.0 with full indexing function in Go

This is a close to decentralized RSS3 Network implementation of RSS3 protocol v0.4.0 with full indexing function in Go

Aug 4, 2022
The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.

Fabric Smart Client The Fabric Smart Client (FSC, for short) is a new Fabric client-side component whose objective is twofold. FSC aims to simplify th

Dec 14, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Jan 9, 2023
A third-party wrapper for CryptAPI written in golang.

A third-party wrapper for CryptAPI written in golang.

Jan 31, 2022
⚡️Curated list of resources for the development and applications of blockchain.
⚡️Curated list of resources for the development and applications of blockchain.

Awesome Blockchain Curated list of resources for the development and applications of block chain. The blockchain is an incorruptible digital ledger of

Jan 9, 2023
The Cosmos-SDK is a framework for building blockchain applications in Golang.
The Cosmos-SDK is a framework for building blockchain applications in Golang.

The Cosmos-SDK is a framework for building blockchain applications in Golang. It is being used to build Gaia, the first implementation of the Cosmos Hub.

Nov 26, 2021
Build your own blockchain!
Build your own blockchain!

Build your own Blockchain in Javascript With all the hype about blockchains and cryptocurrencies, I decided to learn a bit more about it. And what bet

Dec 31, 2022
The source-code for: "Build a Blockchain from Scratch in Go" eBook.
The source-code for:

The Blockchain Bar The source-code for: "Build a Blockchain from Scratch in Go" eBook. ?? Get the eBook from: https://gumroad.com/l/build-a-blockchain

Jan 2, 2023
Mastering Bitcoin 2nd Edition - Programming the Open Blockchain

Code Examples: Mastering Bitcoin Mastering Bitcoin is a book for developers, although the first two chapters cover bitcoin at a level that is also app

Jan 1, 2023
Minlib - Multi-Identifier Network Development Library

minlib 1. Install git clone https://gitea.qjm253.cn/PKUSZ-future-network-lab/min

Jan 7, 2022
A blockchain-based demo that shows an alternative strategy for ensuring data and log integrity on aircraft

A blockchain-based demo that shows an alternative strategy for ensuring data and log integrity on aircraft. (Coded in less than 24 hours for GunnHack)

Feb 6, 2022
Tessera - Enterprise Implementation of Quorum's transaction manager
Tessera - Enterprise Implementation of Quorum's transaction manager

Important: If using version 21.4.1 and earlier Tessera is now released as a zipped distribution instead of an uber jar. If using version 21.4.1 and ea

Dec 15, 2022
run ABI encoded data against the ethereum blockchain

Run EVM code against a database at a certain block height - Note You can't run this against a running geth node - because that would share the db and

Nov 11, 2021
Powerful Blockchain streaming data engine, based on StreamingFast Firehose technology.

Substreams - A streaming data engine for The Graph - by StreamingFast DEVELOPER PREVIEW OF SUBSTREAMS Think Fluvio for deterministic blockchain data.

Dec 30, 2022
go-actor is a lightweight message framework using actor model

go-actor go-actor is a lightweight message framework using actor model 初衷 想能在代码逻辑上方便的写无锁的同步rpc调用代码,同时又不会阻塞住其他服务对这个Actor的调用 一个Actor可以有多种身份,想能比较方便的分类管理A

Oct 21, 2022
A decentralized, cryptocurrency platform that can change this world!

Go Detonus Official Golang implementation of the Detonus protocol. Building the source For prerequisites and detailed build instructions please read t

Oct 19, 2021
Cosmochat - A decentralized chat app on Cosmos.

cosmochat cosmochat is a blockchain built using Cosmos SDK and Tendermint and created with Starport. Get started starport chain serve serve command i

Jan 2, 2022
Running chaincode in development mode: Smart contract developers that want to iteratively develop and test their chaincode packages without the overhead of the smart contract lifecycle process for every update.

Fabric DEVMODE - Nano bash 1 ORG + 1 PEER + 1 ORDERER Based on fabric-samples/test-network-nano-bash, but using devmode fabric peer Prereqs Follow the

May 14, 2022