diff --git a/.github/workflows/ledger.yml b/.github/workflows/ledger.yml deleted file mode 100644 index 7a44297e..00000000 --- a/.github/workflows/ledger.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Test the ledger modules -name: Ledger (go) - -on: - push: - branches: - - main - - pull_request: - types: - - opened - - synchronize - - reopened - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - env: - OPENSSL_DIR: /opt/openssl - - defaults: - run: - working-directory: ./ledger - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis - - - name: Use go 1.21 - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - - uses: actions/cache@v3 - id: cache-openssl - with: - path: ${{ env.OPENSSL_DIR }} - key: ${{ runner.os }}-openssl - - # Inspired from https://github.com/sfackler/rust-openssl/blob/master/.github/workflows/ci.yml - - name: Build OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: | - url="https://openssl.org/source/openssl-3.0.3.tar.gz" - OS_COMPILER=linux-x86_64 - - mkdir /tmp/build - cd /tmp/build - curl -L $url | tar --strip-components=1 -xzf - - ./Configure --prefix=$OPENSSL_DIR --libdir=lib $OS_COMPILER -fPIC -g $OS_FLAGS no-shared - make - make install_sw - - - name: Install ZMQ - run: sudo apt install libzmq3-dev - - - name: Test all - run: | - go test -v -coverpkg=./... -coverprofile=coverage.out ./... -json > report.json - - - name: Run code analysis - uses: SonarSource/sonarcloud-github-action@master - with: - projectBaseDir: ledger - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_LEDGER }} \ No newline at end of file diff --git a/ledger/.gitignore b/ledger/.gitignore deleted file mode 100644 index 2ec5195d..00000000 --- a/ledger/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config/ \ No newline at end of file diff --git a/ledger/README.md b/ledger/README.md deleted file mode 100644 index 8e2ec9e0..00000000 --- a/ledger/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Introduction - -This folder contains the Sawtooth transaction families. For more about -transaction families, see the [Sawtooth -documentation](https://sawtooth.hyperledger.org/docs/1.2/app_developers_guide/overview.html): - -> Sawtooth separates the application level from the core system level with -> **transaction families**, which allows application developers to write in the -> languages of their choice. Each application defines the custom transaction -> families for its unique requirements. - -In short, transaction families are our custom smart contracts that will be -deployed on the Sawtooth network. - -In a transaction family folder, you will find the following folders: - -- **cmd**: contains the CLIs to 1) register the transaction family, 2) send - transactions -- **handler**: holds the smart contract's logic -- **payload**: defines the contend of the transaction sent to the smart contract -- **state**: defines the state of the smart contract - -## Prerequisites - -1) Install **docker** and **docker-compose**: - -https://docs.docker.com/get-docker/ - -2) Install **zeromq**: - -https://zeromq.org/download/ - -3) Install **openssl**, and make sure PKG_CONFIG_PATH is set. For example on Mac: - -```sh -brew install openssl -export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig" -``` - -## Setup - -1) Run docker-compose: - -```sh -docker-compose -f sawtooth-default.yml up -``` - -If is was previously running, stop it first with: - -```sh -docker-compose -f sawtooth-default.yml down -``` - -2) Run the smart contract handler: - -```sh -cd cmd/handler -go run . -vv -``` - -3) Use the client CLI to interact with the smart contract. For example: - -```sh -cd cmd/client -go run . -k /tmp/private.key add --id "XX" -``` \ No newline at end of file diff --git a/ledger/financial/cmd/client/batcher.go b/ledger/financial/cmd/client/batcher.go deleted file mode 100644 index 2bf75106..00000000 --- a/ledger/financial/cmd/client/batcher.go +++ /dev/null @@ -1,226 +0,0 @@ -package main - -import ( - "bytes" - "crypto/rand" - "crypto/sha512" - "encoding/base64" - "encoding/hex" - "fmt" - "io/ioutil" - "ledger/financial/handler" - "ledger/financial/payload" - "ledger/financial/state" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - - "github.com/hyperledger/sawtooth-sdk-go/protobuf/batch_pb2" - "github.com/hyperledger/sawtooth-sdk-go/signing" - "google.golang.org/protobuf/proto" - - tx_pb2 "github.com/hyperledger/sawtooth-sdk-go/protobuf/transaction_pb2" -) - -// batcher defines the primitive to send transactions -type batcher interface { - sendTransaction(payload payload.FinancialPayload) (string, error) -} - -// newBatcher returns a new initialized batcher. url must be the REST endpoint, -// and key must be the filepath to a private key that is allowed to send -// batches. -func newBatcher(url url.URL, keyfilePath string) (batcher, error) { - privateKey, err := loadKey(keyfilePath) - if err != nil { - return nil, fmt.Errorf("failed to load key: %v", err) - } - - pk := signing.NewSecp256k1Context().GetPublicKey(privateKey) - fmt.Println("pk:", pk.AsHex()) - - cryptoFac := signing.NewCryptoFactory(signing.NewSecp256k1Context()) - signer := *cryptoFac.NewSigner(privateKey) - - return basicBatcher{ - url: url, - signer: signer, - }, nil -} - -// batcher holds the functionality of creating and sending batches -type basicBatcher struct { - url url.URL - signer signing.Signer -} - -// sendTransaction implements batcher -func (b basicBatcher) sendTransaction(payload payload.FinancialPayload) (string, error) { - - payloadBuff, err := payload.ToBytes() - if err != nil { - return "", fmt.Errorf("failed to transform payload into bytes: %v", err) - } - - hash := sha512.New() - hash.Write(payloadBuff) - - payloadSha512 := strings.ToLower(hex.EncodeToString(hash.Sum(nil))) - - address := state.KeyAddress - - nonce := make([]byte, 16) - - _, err = rand.Read(nonce) - if err != nil { - return "", fmt.Errorf("failed to get random nonce: %v", err) - } - - rawTxHeader := tx_pb2.TransactionHeader{ - SignerPublicKey: b.signer.GetPublicKey().AsHex(), - FamilyName: handler.FamilyName, - FamilyVersion: handler.FamilyVersion, - Dependencies: []string{}, - Nonce: base64.RawStdEncoding.EncodeToString(nonce), - BatcherPublicKey: b.signer.GetPublicKey().AsHex(), - Inputs: []string{address}, - Outputs: []string{address}, - PayloadSha512: payloadSha512, - } - - txHeader, err := proto.Marshal(&rawTxHeader) - if err != nil { - return "", fmt.Errorf("failed to marshal transaction header: %v", err) - } - - txHeaderSig := hex.EncodeToString(b.signer.Sign(txHeader)) - - transaction := tx_pb2.Transaction{ - Header: txHeader, - HeaderSignature: txHeaderSig, - Payload: payloadBuff, - } - - rawBatchList, err := b.createBatch([]*tx_pb2.Transaction{&transaction}) - if err != nil { - return "", fmt.Errorf("failed to create batch: %v", err) - } - - // batchID := rawBatchList.Batches[0].HeaderSignature - - batchList, err := proto.Marshal(&rawBatchList) - if err != nil { - return "", fmt.Errorf("failed to proto marshal batch list: %v", err) - } - - response, err := b.sendRequest(batchList, BatchSubmitAPI, ContentTypeOctetStream) - if err != nil { - return "", fmt.Errorf("failed to send request: %v", err) - } - - return response, nil -} - -func (b basicBatcher) sendRequest(data []byte, apiSuffix, contentType string) (string, error) { - - url := b.url.String() + "/" + apiSuffix - - logger.Infof("sending request to %q", url) - - var resp *http.Response - var err error - - if len(data) > 0 { - resp, err = http.Post(url, contentType, bytes.NewBuffer(data)) - } else { - resp, err = http.Get(url) - } - - if err != nil { - return "", fmt.Errorf("failed to send http query: %v", err) - } - - defer resp.Body.Close() - - if resp.StatusCode != http.StatusAccepted { - buff, _ := ioutil.ReadAll(resp.Body) - return "", fmt.Errorf("unexpected status %q: %s", resp.Status, buff) - } - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("failed to read body: %v", err) - } - - return string(body), nil -} - -func (b basicBatcher) createBatch(txs []*tx_pb2.Transaction) (batch_pb2.BatchList, error) { - - txSignatures := make([]string, len(txs)) - for i, tx := range txs { - txSignatures[i] = tx.GetHeaderSignature() - } - - rawBatchHeader := batch_pb2.BatchHeader{ - SignerPublicKey: b.signer.GetPublicKey().AsHex(), - TransactionIds: txSignatures, - } - - batchHeader, err := proto.Marshal(&rawBatchHeader) - if err != nil { - return batch_pb2.BatchList{}, fmt.Errorf("failed to proto marshal batch header: %v", err) - } - - batchHeaderSignature := hex.EncodeToString(b.signer.Sign(batchHeader)) - - batch := batch_pb2.Batch{ - Header: batchHeader, - HeaderSignature: batchHeaderSignature, - Transactions: txs, - } - - return batch_pb2.BatchList{ - Batches: []*batch_pb2.Batch{&batch}, - }, nil -} - -// loadKey loads an existing private or creates one -func loadKey(keyfilePath string) (signing.PrivateKey, error) { - var privateKey signing.PrivateKey - - _, err := os.Stat(keyfilePath) - if err != nil && os.IsExist(err) { - return nil, fmt.Errorf("failed to check the private key: %v", err) - } - - if os.IsNotExist(err) { - privateKey = signing.NewSecp256k1Context().NewRandomPrivateKey() - - err = os.MkdirAll(filepath.Dir(keyfilePath), 0600) - if err != nil { - return nil, fmt.Errorf("failed to create folder: %v", err) - } - - err = os.WriteFile(keyfilePath, []byte(privateKey.AsHex()), 0600) - if err != nil { - return nil, fmt.Errorf("failed to write key file: %v", err) - } - } else { - privateKeyHex, err := os.ReadFile(keyfilePath) - if err != nil { - return nil, fmt.Errorf("failed to read private key file: %v", err) - } - - privateKeyBuff, err := hex.DecodeString(string(bytes.TrimSpace(privateKeyHex))) - if err != nil { - return nil, fmt.Errorf("failed to decode key hex: %v", err) - } - - privateKey = signing.NewSecp256k1PrivateKey(privateKeyBuff) - } - - return privateKey, nil -} diff --git a/ledger/financial/cmd/client/cmdAdd.go b/ledger/financial/cmd/client/cmdAdd.go deleted file mode 100644 index 27d78c44..00000000 --- a/ledger/financial/cmd/client/cmdAdd.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "fmt" - "ledger/financial/payload" - "ledger/financial/state" - - flag "github.com/jessevdk/go-flags" -) - -func newCmdAdd(batcher batcher) command { - return &cmdAdd{ - batcher: batcher, - } -} - -// cmdAdd defines a command to add a new wallet -// -// - implements command -type cmdAdd struct { - Test string `long:"test" description:"This is a test arg"` - KeyFilePath string `short:"k" long:"keyfilepath" description:"Filepath of the private key" default:""` - ID string `long:"id" description:"the wallet ID" required:"true"` - - batcher batcher -} - -// register implements command -func (a *cmdAdd) register(command *flag.Command) error { - _, err := command.AddCommand("add", "adds a wallet", "adds a waller", a) - if err != nil { - return fmt.Errorf("faield to add command: %v", err) - } - - return nil -} - -// Execute implements flag.Commander -func (a cmdAdd) Execute(args []string) error { - - payload := payload.FinancialPayload{ - Action: "create", - CreatePayload: payload.CreatePayload{ - WalletID: state.WalletID(a.ID), - }, - } - - res, err := a.batcher.sendTransaction(payload) - if err != nil { - return fmt.Errorf("failed to send transaction: %v", err) - } - - fmt.Println("res:", res) - - return nil -} diff --git a/ledger/financial/cmd/client/mod.go b/ledger/financial/cmd/client/mod.go deleted file mode 100644 index 6c461343..00000000 --- a/ledger/financial/cmd/client/mod.go +++ /dev/null @@ -1,97 +0,0 @@ -package main - -import ( - "fmt" - "ledger/financial/serde" - "net/url" - "os" - - "github.com/hyperledger/sawtooth-sdk-go/logging" - "github.com/jessevdk/go-flags" - flag "github.com/jessevdk/go-flags" -) - -var defaultSerde = serde.JSON{} - -const ( - // BatchSubmitAPI represents the REST endpoint to send batches - BatchSubmitAPI string = "batches" - - // ContentTypeOctetStream represents the octet stream content type - ContentTypeOctetStream string = "application/octet-stream" -) - -// Opts defines the main CLI options -type Opts struct { - Verbose []bool `short:"v" long:"verbose" description:"Increase verbosity"` - PrivateKeyFile string `short:"k" long:"privatekeyfile" description:"Filepath of the private key that is allowed sign batches" required:"true"` -} - -type command interface { - flag.Commander - - register(*flag.Command) error -} - -var logger *logging.Logger = logging.Get() - -func main() { - var opts Opts - parser := flags.NewParser(&opts, flags.Default) - parser.Command.Name = "financial" - - url := url.URL{ - Scheme: "http", - Host: "localhost:8008", - } - - // needed to already have the private key file - parser.Parse() - - batcher, err := newBatcher(url, opts.PrivateKeyFile) - if err != nil { - logger.Errorf("failed to create batcher: %v", err) - os.Exit(1) - } - - commands := []command{ - newCmdAdd(batcher), - } - - for _, command := range commands { - err := command.register(parser.Command) - if err != nil { - logger.Errorf("failed to register command: %v", err) - os.Exit(1) - } - } - - remaining, err := parser.Parse() - if err != nil { - flagsErr, ok := err.(*flags.Error) - if ok && flagsErr.Type == flags.ErrHelp { - os.Exit(0) - } - logger.Errorf("failed to parse args: %v", err) - os.Exit(2) - } - - if len(remaining) != 0 { - logger.Errorf("unrecognized arguments: %v", remaining) - os.Exit(1) - } - - switch len(opts.Verbose) { - case 2: - logger.SetLevel(logging.DEBUG) - case 1: - logger.SetLevel(logging.INFO) - default: - logger.SetLevel(logging.WARN) - } - - if parser.Command.Active == nil { - fmt.Println("no command provided") - os.Exit(2) - } -} diff --git a/ledger/financial/cmd/handler/mod.go b/ledger/financial/cmd/handler/mod.go deleted file mode 100644 index adb97aae..00000000 --- a/ledger/financial/cmd/handler/mod.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "ledger/financial/handler" - "ledger/financial/serde" - "os" - "syscall" - - "github.com/hyperledger/sawtooth-sdk-go/logging" - "github.com/hyperledger/sawtooth-sdk-go/processor" - flags "github.com/jessevdk/go-flags" -) - -var defaultSerde = serde.JSON{} - -// Opts defines the CLI options -type Opts struct { - Verbose []bool `short:"v" long:"verbose" description:"Increase verbosity"` - Connect string `short:"C" long:"connect" description:"Validator component endpoint to connect to" default:"tcp://localhost:4004"` -} - -func main() { - var opts Opts - - logger := logging.Get() - - parser := flags.NewParser(&opts, flags.Default) - - remaining, err := parser.Parse() - if err != nil { - flagsErr, ok := err.(*flags.Error) - if ok && flagsErr.Type == flags.ErrHelp { - os.Exit(0) - } - logger.Errorf("failed to parse args: %v", err) - os.Exit(2) - } - - if len(remaining) != 0 { - logger.Errorf("unrecognized arguments: %v", remaining) - } - - endpoint := opts.Connect - - switch len(opts.Verbose) { - case 2: - logger.SetLevel(logging.DEBUG) - case 1: - logger.SetLevel(logging.INFO) - default: - logger.SetLevel(logging.WARN) - } - - logger.Debugf("command line arguments: %v\n", os.Args) - logger.Debugf("verbose = %v\n", len(opts.Verbose)) - logger.Debugf("endpoint = %v\n", endpoint) - - processor := processor.NewTransactionProcessor(endpoint) - processor.AddHandler(handler.NewFinancialHandler(defaultSerde)) - processor.ShutdownOnSignal(syscall.SIGINT, syscall.SIGTERM) - - err = processor.Start() - if err != nil { - logger.Errorf("failed to start: %v", err) - os.Exit(1) - } -} diff --git a/ledger/financial/handler/mod.go b/ledger/financial/handler/mod.go deleted file mode 100644 index f5dd0d01..00000000 --- a/ledger/financial/handler/mod.go +++ /dev/null @@ -1,151 +0,0 @@ -package handler - -import ( - "crypto/sha512" - "fmt" - "ledger/financial/payload" - "ledger/financial/serde" - "ledger/financial/state" - "strconv" - - "github.com/hyperledger/sawtooth-sdk-go/logging" - "github.com/hyperledger/sawtooth-sdk-go/processor" - "github.com/hyperledger/sawtooth-sdk-go/protobuf/processor_pb2" - "go.dedis.ch/kyber/v3/sign/schnorr" - "go.dedis.ch/kyber/v3/suites" -) - -// defines the transaction family constants -const ( - FamilyName = "hbt_financial" - FamilyVersion = "1.0" -) - -var suite = suites.MustFind("ed25519") - -var logger *logging.Logger = logging.Get() - -// NewFinancialHandler returns a new initialized financial handler -func NewFinancialHandler(serde serde.Serde) processor.TransactionHandler { - return &FinancialHandler{ - serde: serde, - } -} - -// FinancialHandler defines the handler of the financial smart contract -// -// - implement processor.TransactionHandler -type FinancialHandler struct { - serde serde.Serde -} - -// FamilyName implement processor.TransactionHandler. It should return the name -// of the transaction family that this handler can process, e.g. "intkey" -func (f *FinancialHandler) FamilyName() string { - return FamilyName -} - -// FamilyVersions implement processor.TransactionHandler. It should return the -// versions of the transaction family that this handler can process. Eg., -// ["1.0", "1.5"] -func (f *FinancialHandler) FamilyVersions() []string { - return []string{FamilyVersion} -} - -// Namespaces implement processor.TransactionHandler. It should return a slice -// containing all the handler's namespaces, e.g. []string{"abcdef"} -func (f *FinancialHandler) Namespaces() []string { - return []string{state.KeyAddress[:6]} -} - -// Apply implement processor.TransactionHandler. It is the single method where -// all the business logic for a transaction family is defined. The method will -// be called by the transaction processor upon receiving a TpProcessRequest that -// the handler understands and will pass in the TpProcessRequest and an -// initialized instance of the Context type. -func (f *FinancialHandler) Apply(request *processor_pb2.TpProcessRequest, - context *processor.Context) error { - - payload, err := payload.FromBytes(request.GetPayload()) - if err != nil { - return fmt.Errorf("failed to get payload: %v", err) - } - - logger.Debugf("financial tx %v: action: %s", request.Signature, payload.Action) - - stateHandler, err := state.NewHandler(context, f.serde) - if err != nil { - return fmt.Errorf("faield to create state handler: %v", err) - } - - switch payload.Action { - case "create": - createPayload := payload.CreatePayload - - err := stateHandler.CreateWallet(createPayload.WalletID) - if err != nil { - return &processor.InvalidTransactionError{ - Msg: fmt.Sprintf("failed to create wallet: %v", err), - } - } - - logger.Infof("wallet with id %q created", createPayload.WalletID) - case "transfer": - err := f.transfer(stateHandler, payload.TransferPayload) - if err != nil { - return &processor.InvalidTransactionError{ - Msg: fmt.Sprintf("failed to call transfer: %v", err), - } - } - default: - return &processor.InvalidTransactionError{ - Msg: fmt.Sprintf("invalid action: %q", payload.Action), - } - } - - return nil -} - -func (f *FinancialHandler) transfer(state state.Handler, - payload payload.TransferPayload) error { - - fromWallet, err := state.GetWallet(payload.FromWallet) - if err != nil { - return fmt.Errorf("failed to get 'from' wallet %q: %v", payload.FromWallet, err) - } - - fromKey, err := payload.FromWallet.ToPoint() - if err != nil { - return fmt.Errorf("failed to key fromKey: %v", err) - } - - hash := sha512.New() - hash.Write([]byte(strconv.Itoa(int(payload.Amount)))) - hash.Write([]byte(payload.FromWallet)) - hash.Write([]byte(payload.ToWallet)) - - err = schnorr.Verify(suite, fromKey, hash.Sum(nil), []byte(payload.Signature)) - if err != nil { - return fmt.Errorf("signature verification failed: %v", err) - } - - if fromWallet.GetBalance() < payload.Amount { - return fmt.Errorf("insufficient funds: %d < %d", fromWallet.GetBalance(), - payload.Amount) - } - - toWallet, err := state.GetWallet(payload.ToWallet) - if err != nil { - return fmt.Errorf("failed to get 'from' wallet %q: %v", payload.ToWallet, err) - } - - fromWallet.Balance -= payload.Amount - toWallet.Balance += payload.Amount - - err = state.StoreState() - if err != nil { - return fmt.Errorf("failed to store state: %v", err) - } - - return nil -} diff --git a/ledger/financial/payload/mod.go b/ledger/financial/payload/mod.go deleted file mode 100644 index ef6e6cb3..00000000 --- a/ledger/financial/payload/mod.go +++ /dev/null @@ -1,49 +0,0 @@ -package payload - -import ( - "encoding/json" - "fmt" - "ledger/financial/state" -) - -// FinancialPayload represents the payload sent in a financial transaction -type FinancialPayload struct { - Action string - CreatePayload CreatePayload - TransferPayload TransferPayload -} - -// CreatePayload defines the sub-payload "create" -type CreatePayload struct { - WalletID state.WalletID -} - -// TransferPayload defines the sub-payload "transfer" -type TransferPayload struct { - FromWallet state.WalletID - ToWallet state.WalletID - Amount uint64 - Signature string // hex encoded signature -} - -// FromBytes unmarshals the buffer into a payload -func FromBytes(buff []byte) (FinancialPayload, error) { - var payload FinancialPayload - - err := json.Unmarshal(buff, &payload) - if err != nil { - return FinancialPayload{}, fmt.Errorf("failed to unmarshal payload: %v", err) - } - - return payload, nil -} - -// ToBytes marshalls the payload into bytes -func (p FinancialPayload) ToBytes() ([]byte, error) { - buff, err := json.Marshal(p) - if err != nil { - return nil, fmt.Errorf("failed to json marshal: %v", err) - } - - return buff, nil -} diff --git a/ledger/financial/serde/json.go b/ledger/financial/serde/json.go deleted file mode 100644 index 9ef2a476..00000000 --- a/ledger/financial/serde/json.go +++ /dev/null @@ -1,18 +0,0 @@ -package serde - -import "encoding/json" - -// JSON implements a JSON-based serialization/deserialization mechanism -// -// - implements state.Serde -type JSON struct{} - -// Marshal implements state.Serde -func (JSON) Marshal(v any) ([]byte, error) { - return json.Marshal(v) -} - -// Unmarshal implements state.Serde -func (JSON) Unmarshal(buff []byte, v any) error { - return json.Unmarshal(buff, v) -} diff --git a/ledger/financial/serde/json_test.go b/ledger/financial/serde/json_test.go deleted file mode 100644 index 18ea6267..00000000 --- a/ledger/financial/serde/json_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package serde - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -// Sanity check on marshal / unmarshal -func TestJSON(t *testing.T) { - serde := JSON{} - - data := map[string]string{ - "a": "b", - "1": "2", - } - - buff, err := serde.Marshal(&data) - require.NoError(t, err) - - result := map[string]string{} - - err = serde.Unmarshal(buff, &result) - require.NoError(t, err) - - require.Equal(t, data, result) -} diff --git a/ledger/financial/serde/mod.go b/ledger/financial/serde/mod.go deleted file mode 100644 index 7c0916bf..00000000 --- a/ledger/financial/serde/mod.go +++ /dev/null @@ -1,7 +0,0 @@ -package serde - -// Serde abstracts away the serialization/deserialization mechanism -type Serde interface { - Marshal(v any) ([]byte, error) - Unmarshal(buff []byte, v any) error -} diff --git a/ledger/financial/state/mod.go b/ledger/financial/state/mod.go deleted file mode 100644 index 720c25d7..00000000 --- a/ledger/financial/state/mod.go +++ /dev/null @@ -1,160 +0,0 @@ -// package state implements the state handling of our transaction family. Note -// that the serialization / deserialization must be deterministic, according to -// Sawtooth documentation: -// -// https://sawtooth.hyperledger.org/docs/1.2/architecture/global_state.html -// -// > It is critical to select a serialization scheme which is deterministic -// > across executions of the transaction, across platforms, and across -// > versions of the serialization framework. - -package state - -import ( - "crypto/sha512" - "encoding/hex" - "fmt" - "strings" - - "ledger/financial/serde" - - "github.com/hyperledger/sawtooth-sdk-go/processor" - "go.dedis.ch/kyber/v3" - "go.dedis.ch/kyber/v3/suites" -) - -// KeyAddress defines the key address of the financial smart contract state -var KeyAddress = hexdigest("hbt_financial")[:70] - -var suite = suites.MustFind("ed25519") - -// WalletID is a hex-encoded public key - kyber point -type WalletID string - -// ToPoint returns the point representation of the walletID -func (w WalletID) ToPoint() (kyber.Point, error) { - buff, err := hex.DecodeString(string(w)) - if err != nil { - return nil, fmt.Errorf("failed to decode hex: %v", err) - } - - p := suite.Point() - - err = p.UnmarshalBinary(buff) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal point: %v", err) - } - - return p, nil -} - -// newState returns a new initialized state -func newState() state { - return state{ - Wallets: Wallets{}, - } -} - -// state defines the data stored by the smart contract -type state struct { - Wallets Wallets -} - -// NewHandler returns a new initialized Handler -func NewHandler(ctx *processor.Context, serde serde.Serde) (Handler, error) { - state, err := loadState(ctx, serde) - if err != nil { - return Handler{}, fmt.Errorf("failed to load state: %v", err) - } - - return Handler{ - context: ctx, - serde: serde, - state: state, - }, nil -} - -// Handler handles addressing and (de)serialization of the state -type Handler struct { - context *processor.Context - serde serde.Serde - state state -} - -// CreateWallet creates a new wallet with walletID. Returns an error if the -// wallet already exists. -func (h Handler) CreateWallet(wid WalletID) error { - _, found := h.state.Wallets.Get(wid) - if found { - return fmt.Errorf("wallet with id %q already exists", wid) - } - - h.state.Wallets.Set(Wallet{ - Balance: 0, - State: WalletOK, - }) - - err := h.StoreState() - if err != nil { - return fmt.Errorf("failed to store state: %v", err) - } - - return nil -} - -// GetWallet returns the wallet corresponding to the walletID, or an error if -// not found. -func (h Handler) GetWallet(wid WalletID) (Wallet, error) { - wallet, found := h.state.Wallets.Get(wid) - if !found { - return Wallet{}, fmt.Errorf("wallet with id %q already exists", wid) - } - - return wallet, nil -} - -// StoreState saves the current state -func (h Handler) StoreState() error { - buff, err := h.serde.Marshal(h.state) - if err != nil { - return fmt.Errorf("failed to marshal state: %v", err) - } - - _, err = h.context.SetState(map[string][]byte{ - KeyAddress: buff, - }) - if err != nil { - return fmt.Errorf("failed to set state: %v", err) - } - - return nil -} - -func loadState(ctx *processor.Context, serde serde.Serde) (state, error) { - results, err := ctx.GetState([]string{KeyAddress}) - if err != nil { - return state{}, fmt.Errorf("failed to get state: %v", err) - } - - // In case the state is not initialized we use a new initialized state - s := newState() - - result, found := results[KeyAddress] - if found { - err = serde.Unmarshal(result, &s) - if err != nil { - return state{}, fmt.Errorf("failed to unmarshal state: %v", err) - } - } - - return s, nil -} - -func hexdigest(str string) string { - hash := sha512.New() - - hash.Write([]byte(str)) - buff := hash.Sum(nil) - - return strings.ToLower(hex.EncodeToString(buff)) -} diff --git a/ledger/financial/state/wallet.go b/ledger/financial/state/wallet.go deleted file mode 100644 index 99812063..00000000 --- a/ledger/financial/state/wallet.go +++ /dev/null @@ -1,64 +0,0 @@ -package state - -type walletState int - -// defines the states of a wallet -const ( - WalletOK = iota - WalletBlacklisted - WalletPending -) - -// Wallet represents a main or sub-wallet -type Wallet struct { - ID WalletID - Balance uint64 - State walletState -} - -// GetBalance returns the wallet's balance -func (w Wallet) GetBalance() uint64 { - return w.Balance -} - -// Wallets represents a list of wallets. A map would be more efficient but -// unfortunately not deterministic. -type Wallets []Wallet - -// Get returns the wallet corresponding to the ID, or false. -func (ws Wallets) Get(id WalletID) (Wallet, bool) { - for _, w := range ws { - if w.ID == id { - return w, true - } - } - - return Wallet{}, false -} - -// Set sets a new wallets on the list. It ensures uniqueness of wallets based on -// their ID. This is to mimic a map. So, if a wallet already exists with the -// wallet ID, it will be replaced by the provided wallet. -func (ws *Wallets) Set(w1 Wallet) { - for i, w2 := range *ws { - if w2.ID == w1.ID { - (*ws)[i] = w1 - return - } - } - - *ws = append(*ws, w1) -} - -// Del remove a wallet based on its ID. It assumes that no two wallets have the -// same ID. -func (ws *Wallets) Del(id WalletID) bool { - for i, w := range *ws { - if w.ID == id { - *ws = append((*ws)[:i], (*ws)[i+1:]...) - return true - } - } - - return false -} diff --git a/ledger/financial/state/wallet_test.go b/ledger/financial/state/wallet_test.go deleted file mode 100644 index 5dc65e0d..00000000 --- a/ledger/financial/state/wallet_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package state - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestWallet(t *testing.T) { - wallets := Wallets{} - - w1 := Wallet{ - ID: "aa", - Balance: 10, - State: WalletOK, - } - - w2 := Wallet{ - ID: "bb", - Balance: 20, - State: WalletBlacklisted, - } - - wallets.Set(w1) - require.Len(t, wallets, 1) - - wallets.Set(w1) - require.Len(t, wallets, 1) - - wallets.Set(w2) - require.Len(t, wallets, 2) - - wallets.Set(w2) - require.Len(t, wallets, 2) - - wallets.Del(w1.ID) - require.Len(t, wallets, 1) - - wallets.Del(w1.ID) - require.Len(t, wallets, 1) - - _, found := wallets.Get(w1.ID) - require.False(t, found) - - w, found := wallets.Get(w2.ID) - require.True(t, found) - require.Equal(t, w2, w) - - wallets.Del(w2.ID) - require.Len(t, wallets, 0) - - _, found = wallets.Get(w2.ID) - require.False(t, found) -} diff --git a/ledger/go.mod b/ledger/go.mod deleted file mode 100644 index f81b7828..00000000 --- a/ledger/go.mod +++ /dev/null @@ -1,24 +0,0 @@ -module ledger - -go 1.18 - -require ( - github.com/hyperledger/sawtooth-sdk-go v0.1.4 - github.com/jessevdk/go-flags v1.4.0 - github.com/stretchr/testify v1.7.2 - go.dedis.ch/kyber/v3 v3.0.13 - google.golang.org/protobuf v1.25.0 -) - -require ( - github.com/btcsuite/btcd v0.23.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.4.3 // indirect - github.com/pebbe/zmq4 v1.2.5 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/satori/go.uuid v1.2.0 // indirect - go.dedis.ch/fixbuf v1.0.3 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/sys v0.1.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/ledger/go.sum b/ledger/go.sum deleted file mode 100644 index 4fceeb56..00000000 --- a/ledger/go.sum +++ /dev/null @@ -1,151 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/brianolson/cbor_go v1.0.0/go.mod h1:oGF4+yGIBUbkxYYGKSJRGIZ4Z91crezxGZAnnslEtT0= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M= -github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hyperledger/sawtooth-sdk-go v0.1.4 h1:/IXflJfK8W83/iZwEYFtqt1hv1hUdbH+6+fOziSwu7o= -github.com/hyperledger/sawtooth-sdk-go v0.1.4/go.mod h1:KWpiRKRQ+VFBSxLxYziMES90DwtXNdWPKp29A8JDA/8= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pebbe/zmq4 v1.2.5 h1:ygTu6F/sMp7TIo7JN/ObpotHudy7+Rnun1LLSybyCFs= -github.com/pebbe/zmq4 v1.2.5/go.mod h1:3+LG+02U+ToKtxF9avLo17NGTVDhWtRhsdU3spikK8o= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= -go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= -go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= -go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg= -go.dedis.ch/kyber/v3 v3.0.13 h1:s5Lm8p2/CsTMueQHCN24gPpZ4couBBeKU7r2Yl6r32o= -go.dedis.ch/kyber/v3 v3.0.13/go.mod h1:kXy7p3STAurkADD+/aZcsznZGKVHEqbtmdIzvPfrs1U= -go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= -go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4= -go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= -go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/ledger/sawtooth-default.yml b/ledger/sawtooth-default.yml deleted file mode 100644 index 2edb52d6..00000000 --- a/ledger/sawtooth-default.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -version: "2.1" - -services: - - settings-tp: - image: hyperledger/sawtooth-settings-tp:chime - container_name: sawtooth-settings-tp-default - depends_on: - - validator - entrypoint: settings-tp -vv -C tcp://validator:4004 - - intkey-tp-python: - image: hyperledger/sawtooth-intkey-tp-python:chime - container_name: sawtooth-intkey-tp-python-default - depends_on: - - validator - entrypoint: intkey-tp-python -vv -C tcp://validator:4004 - - xo-tp-python: - image: hyperledger/sawtooth-xo-tp-python:chime - container_name: sawtooth-xo-tp-python-default - depends_on: - - validator - entrypoint: xo-tp-python -vv -C tcp://validator:4004 - - validator: - image: hyperledger/sawtooth-validator:chime - container_name: sawtooth-validator-default - expose: - - 4004 - ports: - - "4004:4004" - # volumes: - # - ./config:/root/.sawtooth - # start the validator with an empty genesis batch - entrypoint: "bash -c \"\ - sawadm keygen && \ - sawtooth keygen my_key --force && \ - sawset genesis -k /root/.sawtooth/keys/my_key.priv && \ - sawset proposal create \ - -k /root/.sawtooth/keys/my_key.priv \ - sawtooth.consensus.algorithm.name=Devmode \ - sawtooth.consensus.algorithm.version=0.1 \ - -o config.batch && \ - sawadm genesis config-genesis.batch config.batch && \ - sawtooth-validator -vv \ - --endpoint tcp://validator:8800 \ - --bind component:tcp://eth0:4004 \ - --bind network:tcp://eth0:8800 \ - --bind consensus:tcp://eth0:5050 \ - \"" - - devmode-engine: - image: hyperledger/sawtooth-devmode-engine-rust:chime - container_name: sawtooth-devmode-engine-rust-default - depends_on: - - validator - entrypoint: devmode-engine-rust -C tcp://validator:5050 - - rest-api: - image: hyperledger/sawtooth-rest-api:chime - container_name: sawtooth-rest-api-default - ports: - - "8008:8008" - depends_on: - - validator - entrypoint: sawtooth-rest-api -C tcp://validator:4004 --bind rest-api:8008 - - shell: - image: hyperledger/sawtooth-shell:chime - container_name: sawtooth-shell-default - depends_on: - - rest-api - entrypoint: "bash -c \"\ - sawtooth keygen && \ - tail -f /dev/null \ - \"" diff --git a/ledger/sonar-project.properties b/ledger/sonar-project.properties deleted file mode 100644 index 7340a351..00000000 --- a/ledger/sonar-project.properties +++ /dev/null @@ -1,15 +0,0 @@ -sonar.organization=dedis -sonar.projectKey=hbt-go - -# Path of the test and coverage reports -sonar.go.tests.reportPaths=./report.json -sonar.go.coverage.reportPaths=./coverage.out - -# Path patterns of the source files -sonar.sources=. - -# Path patterns of the test files -sonar.tests=. -sonar.test.inclusions=**/*_test.go - -sonar.projectName=HBT - Ledger (go) \ No newline at end of file