fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

`fluree/server` should store raw transaction, especially when signed #105

Closed Jackamus29 closed 1 month ago

Jackamus29 commented 1 month ago

Description

When using fluree/server the raw, signed transaction sent to Fluree is not what is stored in the txn file on disk. The signed transaction is required for validating that a particular transaction/data change originated from a did.

Note about testing

@dpetran mentioned that we won't be able to write a test for this until there's an API that enables retrieving the contents of the txn file. We'll want this in the future not only for testing this works correctly, but also to support audit-ability and automated proving of provenance of data state changes.

Steps to reproduce

  1. Create transaction
    {
    "ledger": "crypto-test",
    "@context": {
    "f": "https://ns.flur.ee/ledger#",
    "ex": "https://example.org/"
    },
    "insert": [
    {
      "@id": "did:fluree:TfBEiM6J5Jwv9JJR6YLPCvTwjNKamrvDC9L",
      "f:role": {
        "@id": "ex:userRole"
      },
      "ex:user": {
        "@id": "ex:Jack"
      }
    },
    {
      "@id": "ReadWriteAllPolicy",
      "@type": "f:Policy",
      "schema:name": "Read and Write All Policy",
      "schema:description": "Policy that allows read and write access to all nodes.",
      "f:allow": {
        "@id": "globalViewModifyAllow",
        "f:action": [
          {
            "@id": "f:view"
          },
          {
            "@id": "f:modify"
          }
        ],
        "f:targetRole": {
          "@id": "ex:userRole"
        }
      },
      "f:targetNode": {
        "@id": "f:allNodes"
      }
    }
    ]
    }
  2. Transact signed transaction
    eyJhbGciOiJFUzI1NkstUiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19.eyJsZWRnZXIiOiJjcnlwdG8tdGVzdCIsIkBjb250ZXh0Ijp7ImYiOiJodHRwczovL25zLmZsdXIuZWUvbGVkZ2VyIyIsImV4IjoiaHR0cHM6Ly9leGFtcGxlLm9yZy8ifSwiaW5zZXJ0IjpbeyJAaWQiOiJleDpmcmVkZHkiLCJleDpuYW1lIjoiRnJlZGR5In1dfQ.MWMzMDQ1MDIyMTAwY2JkMzJlNDYzNTY3ZmVmYzJmMTIwNDI1YjAyMjRkOWQyNjMwMDg5MTE2NTNmNTBlODM5NTNmNDdjZmJlZjNiYzAyMjA2NzlkNmNjYWZlOGFjMDVjMTZlMTFkY2Q4ZTE1ODJkMWE5NDY5MGE0ZmI0MjYwY2QyZmZkNmE5NTMyZjk2YjEx
  3. Check the appropriate txn file on disk.
    Expected:
    eyJhbGciOiJFUzI1NkstUiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19.eyJsZWRnZXIiOiJjcnlwdG8tdGVzdCIsIkBjb250ZXh0Ijp7ImYiOiJodHRwczovL25zLmZsdXIuZWUvbGVkZ2VyIyIsImV4IjoiaHR0cHM6Ly9leGFtcGxlLm9yZy8ifSwiaW5zZXJ0IjpbeyJAaWQiOiJleDpmcmVkZHkiLCJleDpuYW1lIjoiRnJlZGR5In1dfQ.MWMzMDQ1MDIyMTAwY2JkMzJlNDYzNTY3ZmVmYzJmMTIwNDI1YjAyMjRkOWQyNjMwMDg5MTE2NTNmNTBlODM5NTNmNDdjZmJlZjNiYzAyMjA2NzlkNmNjYWZlOGFjMDVjMTZlMTFkY2Q4ZTE1ODJkMWE5NDY5MGE0ZmI0MjYwY2QyZmZkNmE5NTMyZjk2YjEx

Actual:

{
  "ledger": "crypto-test",
  "@context": {
    "f": "https://ns.flur.ee/ledger#",
    "ex": "https://example.org/"
  },
  "insert": [
    {
      "@id": "ex:freddy",
      "ex:name": "Freddy"
    }
  ]
}