Skip to content

TODO #1

Open
Open

Description

@andrewvy

Needs

transactions

  • transaction_from_serialized (convert serialized protobuf into transaction struct)
  • verify_txin (verifies txin is valid, that it points to an unspent txout)

blocks

  • block_to_proto (convert block struct into proto struct)
  • block_to_serialized (convert block struct into serialized)
  • block_from_serialized (convert serialized protobuf into block struct)
  • add mempool (pool of verified TXs waiting to be put into block)
  • compute_merkle_root (computes merkle root)
  • insert TXs from mempool into currently mined block
  • verify_merkle_root (verifies merkle root)
  • verify_block (verify entire block, its txin, merkle root, whole boi)

blockchain

  • insert_block_into_blockchain (serializes block, puts serialized block into blockchain db)
  • get number of blocks in the database
  • fetch_block_from_db (fetches block struct, deserializing from db using passed in hash)
  • get_block_from_tx (fetches block struct from a TX struct)
  • get_block_height_for_block (gets the block height to a certain block hash, used for determining best blockchain)
  • remove_block_from_db
  • undo_block (must go through blocks if new branch is valid, undo old blocks, apply new branch)
  • insert_tx_into_index (if block is inserted into chain, add index for those block's txs to point to the block hash)
  • remove tx from index
  • leveldb transaction index. TX hash as key, value points to block key where TX is located
  • get_blocks_since_hash gets future blocks from a given start hash, returns a set size (iterates over all blocks to find start hash, while buffering blocks)
  • keeps track of unspent transactions and their unspent txouts (UTXOs)
  • Block insertion marks unspent UTXOs as spent

api

  • protobuf RPC for local client (elevated operations, wallet management, etc.)
  • protobuf RPC for node RPC / broadcast
  • Switch RPC implementation to GRPC https://github.com/Juniper/grpc-c

  • list all dynamic mem allocs // ensure memory hygiene
  • ensure proto -> struct bytearray sizes are correct, or bail
  • setup CI (need to install dependencies on CI environment)

Conscious decisions:

  • no raw append-only block storage like bitcoin, using leveldb as the entire storage of the chain rather than only block headers (slower access, more size, faster to develop)
  • no double sha256 for merkle root calculation

Activity

  1. andrewvy commented on Sep 5, 2017

    @andrewvy
    OwnerAuthor

    image

    IT'S ALIVE

    kinda

    empty txless block mining on local (no-net)

  2. andrewvy commented on Sep 19, 2017

    @andrewvy
    OwnerAuthor
                                                             ┌──────────────────────────────────────────┐                                                                                      ┌──────────────────────────────────────────┐
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │               Opal Daemon                │                                                                                      │                Opal Peer                 │
                                                             │                                          │                                     P2P Layer                                        │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             │                                          │                                                                                      │                                          │
                                                             ├────────────┐                ┌────────────┤                                                                                      │                             ┌────────────┤
                                                             │Internal RPC│                │External RPC│                                                                                      │                             │External RPC│
                                                             │   (9898)   │                │   (9899)   │                                                                                      │                             │   (9899)   │
                                                             └────────────┴────────────────┴────────────┘                                                                                      └─────────────────────────────┴────────────┘
                                                                    │                             │                                                                                                                                 ▲      
                                                                    │                             │                                                                                                                                 │      
                                                                    │                             ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
                                                                    │                             │ Protobuf over HTTP                                                                                                                     
                                                                    │                             │                                                                                            ┌──────────────────────────────────────────┐
                                                  Protobuf over HTTP│                             │                                                                                            │                                          │
          Client Agnostic RPC Layer              ┌──────────────────┤                             │                                                                                            │                                          │
                                                 │                  │                             │                                                                                            │                                          │
                                                 │                  │                             │                                                                                            │                                          │
                                                 │                  │                             │                                                                                            │                                          │
                                                 │                  │                             │                                                                                            │                                          │
                                                 │                  │                             │                                                                                            │                Opal Peer                 │
                                                 │                  │                             │                                                                                            │                                          │
                                                 ▼                  ▼                             │                                                                                            │                                          │
                                           ┌───────────┐    ┌───────────────┐                     │                                                                                            │                                          │
                                           │Rust Client│    │Built-in Client│                     │                                                                                            │                             ┌────────────┤
                                           └───────────┘    └───────────────┘                     │                                                                                            │                             │External RPC│
                                                                                                  │                                                                                            │                             │   (9899)   │
                                                                                                  │                                                                                            └─────────────────────────────┴────────────┘
                                                                                                  │                                                                                                                                 ▲      
                                                                                                  │                                                                                                                                 │      
                                                                                                  ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
                                                                                                  │                                                                                                                                        
                                                                                                  │                                                                                            ┌──────────────────────────────────────────┐
                                                                                                  │                                                                                            │                                          │
          ┌─────────────────────────┐                                                             │                                                                                            │                                          │
          │ Initialization Sequence │                                                             │                                                                                            │                                          │
          └─────────────────────────┘                                                             │                                                                                            │                                          │
                                                                                                  │                                                                                            │                                          │
                                                                                                  │                                                                                            │                                          │
          1) Get external facing IP address using UPnP                                            │                                                                                            │                Opal Peer                 │
                                                                                                  │                                                                                            │                                          │
          2) Broadcast 'Peer Advertise' message with                                              │                                                                                            │                                          │
          external IP                                                                             │                                                                                            │                                          │
                                                                                                  │                                                                                            │                             ┌────────────┤
          3) Call 'Peer List' on seed DNS nodes and keep                                          │                                                                                            │                             │External RPC│
          track in a local list of peers, also saved for                                          │                                                                                            │                             │   (9899)   │
          later peer discovery seed usage.                                                        │                                                                                            └─────────────────────────────┴────────────┘
                                                                                                  │                                                                                                                                 ▲      
          4) Start downloading block headers from peers                                           │                                                                                                                                 │      
                                                                                                  └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
          5) Validate headers and figure out the 'best                                                                                                                                                                                     
          header chain'                                                                                                                                                                                                                    
                                                                                                                                                                                                                                           
          6) Once best header chain has been found, start                                                                                                                                                                                  
          downloading full blocks from peers.                                                                                                                                                                                              
                                                                                                                                                                                                                                           
          7) Start validating full blocks and maintain a                                                                                                                                                                                   
          UXTO database                                                                                                                                                                                                                    
                                                                                                                                                                                                                                           
          8) You are ready to start accepting TXs and                                                                                                                                                                                      
          Blocks!                                                                                                                                                                                                                          
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions