name: solana
version: git
summary: Blockchain, Rebuilt for Scale
description: |
  710,000 tx/s with off-the-shelf hardware and no sharding.
  Scales with Moore's Law.
grade: devel

# TODO: solana-perf-fullnode does not yet run with 'strict' confinement due to the
# CUDA dependency, so use 'devmode' confinement for now
confinement: devmode

hooks:
  configure:
    plugs: [network]

apps:
  drone:
    command: solana-drone
    plugs:
      - network
      - network-bind
  fullnode:
    command: solana-fullnode
    plugs:
      - network
      - network-bind
      - home
  fullnode-config:
    command: solana-fullnode-config
    plugs:
      - network
      - network-bind
      - home
  genesis:
    command: solana-genesis
  keygen:
    command: solana-keygen
    plugs:
      - home
  ledger-tool:
    command: solana-ledger-tool
    plugs:
      - home
  bench-tps:
    command: solana-bench-tps
    plugs:
      - network
      - network-bind
      - home
  wallet:
    command: solana-wallet
    plugs:
      - network
      - home
  daemon-fullnode:
    daemon: simple
    command: scripts/snap-config-to-env.sh $SNAP/multinode-demo/fullnode.sh
    plugs:
      - network
      - network-bind
  daemon-bootstrap-leader:
    daemon: simple
    command: scripts/snap-config-to-env.sh $SNAP/multinode-demo/bootstrap-leader.sh
    plugs:
      - network
      - network-bind
  daemon-drone:
    daemon: simple
    command: scripts/snap-config-to-env.sh $SNAP/multinode-demo/drone.sh
    plugs:
      - network
      - network-bind
  daemon-oom-monitor:
    daemon: simple
    command: scripts/snap-config-to-env.sh $SNAP/scripts/oom-monitor.sh
    plugs:
      - network
  daemon-net-stats:
    daemon: simple
    command: scripts/snap-config-to-env.sh $SNAP/scripts/net-stats.sh
    plugs:
      - network

parts:
  solana:
    plugin: nil
    prime:
      - bin
      - multinode-demo
      - scripts
    override-build: |
      # Build/install all programs
      scripts/cargo-install-all.sh $SNAPCRAFT_PART_INSTALL

      # Install multinode-demo/
      mkdir -p $SNAPCRAFT_PART_INSTALL/multinode-demo/
      cp -av multinode-demo/* $SNAPCRAFT_PART_INSTALL/multinode-demo/

      # Install scripts/
      mkdir -p $SNAPCRAFT_PART_INSTALL/scripts/
      cp -av scripts/* $SNAPCRAFT_PART_INSTALL/scripts/

      # TODO: build curl,dig,rsync/multilog from source instead of sneaking it
      # in from the host system...
      set -x
      mkdir -p $SNAPCRAFT_PART_INSTALL/bin
      cp -av /usr/bin/curl $SNAPCRAFT_PART_INSTALL/bin/
      cp -av /usr/bin/dig $SNAPCRAFT_PART_INSTALL/bin/
      cp -av /usr/bin/multilog $SNAPCRAFT_PART_INSTALL/bin/
      cp -av /usr/bin/rsync $SNAPCRAFT_PART_INSTALL/bin/
