From 8a0943f783f034d331f4077d2229b085ef79b0d8 Mon Sep 17 00:00:00 2001 From: Serguey Zefirov Date: Wed, 31 May 2023 17:28:22 +0300 Subject: [PATCH] Initial commit of a consensus prototype --- flake.nix | 4 +- hbs2-consensus/Consensus.hs | 11 ++ hbs2-consensus/LICENSE | 30 ++++++ hbs2-consensus/hbs2-git.cabal | 149 +++++++++++++++++++++++++++ hbs2-consensus/lib/HBS2/Consensus.hs | 8 ++ 5 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 hbs2-consensus/Consensus.hs create mode 100644 hbs2-consensus/LICENSE create mode 100644 hbs2-consensus/hbs2-git.cabal create mode 100644 hbs2-consensus/lib/HBS2/Consensus.hs diff --git a/flake.nix b/flake.nix index baddc891..69c73920 100644 --- a/flake.nix +++ b/flake.nix @@ -69,8 +69,8 @@ outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs: ]; shellExtBuildInputs = {pkgs}: with pkgs; [ - haskellPackages.haskell-language-server - haskellPackages.cbor-tool +# haskellPackages.haskell-language-server +# haskellPackages.cbor-tool pkg-config inputs.hspup.packages.${pkgs.system}.default inputs.fixme.packages.${pkgs.system}.default diff --git a/hbs2-consensus/Consensus.hs b/hbs2-consensus/Consensus.hs new file mode 100644 index 00000000..e5a5afc1 --- /dev/null +++ b/hbs2-consensus/Consensus.hs @@ -0,0 +1,11 @@ +-- |Consensus.hs +-- +-- A fact graph database consensus, Tendermint with a twist. +-- +-- Copyright (C) Serguey Zefirov, 2023. + +module Consensus where + +main = do + putStrLn "consensus!" + return () diff --git a/hbs2-consensus/LICENSE b/hbs2-consensus/LICENSE new file mode 100644 index 00000000..3086ee5d --- /dev/null +++ b/hbs2-consensus/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2023, Dmitry Zuikov + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Dmitry Zuikov nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/hbs2-consensus/hbs2-git.cabal b/hbs2-consensus/hbs2-git.cabal new file mode 100644 index 00000000..d10015f7 --- /dev/null +++ b/hbs2-consensus/hbs2-git.cabal @@ -0,0 +1,149 @@ +cabal-version: 3.0 +name: hbs2-git +version: 0.1.0.0 +-- synopsis: +-- description: +license: BSD-3-Clause +license-file: LICENSE +author: Dmitry Zuikov +maintainer: dzuikov@gmail.com +-- copyright: +category: Development +build-type: Simple +extra-doc-files: CHANGELOG.md +-- extra-source-files: + +common shared-properties + ghc-options: + -Wall + -Wno-type-defaults + -- -fno-warn-unused-matches + -- -fno-warn-unused-do-bind + -- -Werror=missing-methods + -- -Werror=incomplete-patterns + -- -fno-warn-unused-binds + + + default-language: Haskell2010 + + default-extensions: + ApplicativeDo + , BangPatterns + , BlockArguments + , ConstraintKinds + , DataKinds + , DeriveDataTypeable + , DeriveGeneric + , DerivingStrategies + , DerivingVia + , ExtendedDefaultRules + , FlexibleContexts + , FlexibleInstances + , GADTs + , GeneralizedNewtypeDeriving + , ImportQualifiedPost + , LambdaCase + , MultiParamTypeClasses + , OverloadedStrings + , QuasiQuotes + , RecordWildCards + , ScopedTypeVariables + , StandaloneDeriving + , TupleSections + , TypeApplications + , TypeFamilies + + + build-depends: hbs2-core + , aeson + , async + , base16-bytestring + , bytestring + , containers + , cryptonite + , directory + , filepath + , memory + , microlens-platform + , mtl + , prettyprinter + , prettyprinter-ansi-terminal + , safe + , serialise + , suckless-conf + , text + , transformers + , typed-process + , uniplate + , hashable + , sqlite-simple + , stm + , unordered-containers + , filelock + , http-conduit + , exceptions + +library + import: shared-properties + + exposed-modules: + HBS2.Consensus + + -- other-modules: + -- other-extensions: + build-depends: base + , exceptions + , http-types + + hs-source-dirs: lib + default-language: Haskell2010 + +executable consensus-kv + import: shared-properties + main-is: Consensus.hs + + ghc-options: + -threaded + -rtsopts + "-with-rtsopts=-N4 -A64m -AL256m -I0" + + other-modules: + RunShow + + -- other-extensions: + build-depends: + base, hbs2-git + , optparse-applicative + , http-types + + hs-source-dirs: git-hbs2 + default-language: Haskell2010 + + +executable git-remote-hbs2 + import: shared-properties + main-is: GitRemoteMain.hs + + ghc-options: + -threaded + -rtsopts + "-with-rtsopts=-N4 -A64m -AL256m -I0" + + other-modules: + GitRemoteTypes + GitRemotePush + + -- other-extensions: + build-depends: + base, hbs2-git + , async + , attoparsec + , optparse-applicative + , unix + , unliftio + , terminal-progress-bar + , http-types + + hs-source-dirs: git-hbs2 + default-language: Haskell2010 + diff --git a/hbs2-consensus/lib/HBS2/Consensus.hs b/hbs2-consensus/lib/HBS2/Consensus.hs new file mode 100644 index 00000000..ffeb8d8c --- /dev/null +++ b/hbs2-consensus/lib/HBS2/Consensus.hs @@ -0,0 +1,8 @@ +-- |HBS2.Consensus +-- +-- A FSM and support routines for Tendermint with a twist. +-- +-- Copyright (C) Serguey Zefirov, 2023. + +module HBS2.Consensus where +