Ledger system to persist info between workflows #28

Open
opened 2025-01-02 00:38:45 +00:00 by ryan · 1 comment
Owner

We need a way to save, sign, and load values to and from a ledger. We also need a way to store encrypted values.

- workflows:
  # Solana propose transfer token
  - name: propose-transfer-token
    inputs:
    - nonce_address
    - from_address
    - to_address
    - token_name
    - token_amount
    - cluster
    steps:
    # Get the nonce value, to be used as the nonce for the ledger and for the
    # transaction.
    - type: sol-get-nonce-account-data
      inputs:
        nonce_address: "nonce_address"
        cluster: "cluster"
      outputs:
        authority: "nonce_authority"
        durable_nonce: "nonce_data"

    # Compress the metadata for the ledger into a specific value. This means
    # we only need one specific value for the ledger, but we can support
    # multiple ledger types with arbitrary metadata.
    - type: internal-compress
      values:
        type: "git"
        name: "example_ledger"
        signature_type: "openpgp"
      outputs:
        value: "ledger_config"

    # Save the signed data to the ledger
    - type: internal-save-ledger
      values:
        # This will be used to filter the ledger 
        type: "propose"
      inputs:
        ledger_config: "ledger_config"
        # All these values will then be signed and added to the ledger
        nonce_address: "nonce_address"
        nonce_data: "nonce_data"
        nonce_authority: "nonce_authority"
        from_address: "from_address"
        to_address: "to_address"
        token_name: "token_name"
        token_amount: "token_amount"

    # Print out the ledger nonce
    - type: internal-cat
      inputs:
        ledger_nonce: "nonce_data"
      outputs:
        ledger_nonce: "ledger_nonce"

  # Approve the transfer of a token by adding a new entry to the ledger
  # with the same nonce.
  - name: approve-transfer-token
    inputs: ["ledger_nonce"]
    steps:
    # Build a filter for the ledger based on the provided nonce
    - type: internal-compress
      inputs:
        nonce_data: "ledger_nonce"
      outputs:
        value: "ledger_filter"

    # Load the values from the ledger
    - type: internal-load-ledger
      values:
        type: "git"
        name: "example_ledger"
      inputs:
        filter_equals: "ledger_filter"
      # TODO: Implement `output_compressed` in Icepick Workflow to assign all
      # values from a ledger entry into a single value to be validated or
      # otherwise worked on.
      output_compressed: "validated_data"

    # Prompt the signer to verify the given inputs
    # TODO: this operation needs to be implemented as well
    - type: internal-validate-values
      inputs:
        values: "validated_data"

    # Build the metadata to add an approval to the ledger
    - type: internal-compress
      values:
        type: "git"
        name: "example_ledger"
        signature_type: "openpgp"
      outputs:
        value: "ledger_config"

    # Save an approval to the ledger. This will prompt a signature. Later,
    # loading all values in the ledger by `nonce` = ledger_nonce will return
    # the proposer and the approver blobs
    - type: internal-save-ledger
      values:
        # Not strictly necessary, but can later be used to filter inputs on the
        # nonce based on whether it's marked "approved" or some other,
        # currently unknown, value.
        approved: "approved"
      inputs:
        nonce_data: "ledger_nonce"
      inputs:
        ledger_config: "ledger_config"
        nonce: "ledger_nonce"
We need a way to save, sign, and load values to and from a ledger. We also need a way to store encrypted values. ```yaml - workflows: # Solana propose transfer token - name: propose-transfer-token inputs: - nonce_address - from_address - to_address - token_name - token_amount - cluster steps: # Get the nonce value, to be used as the nonce for the ledger and for the # transaction. - type: sol-get-nonce-account-data inputs: nonce_address: "nonce_address" cluster: "cluster" outputs: authority: "nonce_authority" durable_nonce: "nonce_data" # Compress the metadata for the ledger into a specific value. This means # we only need one specific value for the ledger, but we can support # multiple ledger types with arbitrary metadata. - type: internal-compress values: type: "git" name: "example_ledger" signature_type: "openpgp" outputs: value: "ledger_config" # Save the signed data to the ledger - type: internal-save-ledger values: # This will be used to filter the ledger type: "propose" inputs: ledger_config: "ledger_config" # All these values will then be signed and added to the ledger nonce_address: "nonce_address" nonce_data: "nonce_data" nonce_authority: "nonce_authority" from_address: "from_address" to_address: "to_address" token_name: "token_name" token_amount: "token_amount" # Print out the ledger nonce - type: internal-cat inputs: ledger_nonce: "nonce_data" outputs: ledger_nonce: "ledger_nonce" # Approve the transfer of a token by adding a new entry to the ledger # with the same nonce. - name: approve-transfer-token inputs: ["ledger_nonce"] steps: # Build a filter for the ledger based on the provided nonce - type: internal-compress inputs: nonce_data: "ledger_nonce" outputs: value: "ledger_filter" # Load the values from the ledger - type: internal-load-ledger values: type: "git" name: "example_ledger" inputs: filter_equals: "ledger_filter" # TODO: Implement `output_compressed` in Icepick Workflow to assign all # values from a ledger entry into a single value to be validated or # otherwise worked on. output_compressed: "validated_data" # Prompt the signer to verify the given inputs # TODO: this operation needs to be implemented as well - type: internal-validate-values inputs: values: "validated_data" # Build the metadata to add an approval to the ledger - type: internal-compress values: type: "git" name: "example_ledger" signature_type: "openpgp" outputs: value: "ledger_config" # Save an approval to the ledger. This will prompt a signature. Later, # loading all values in the ledger by `nonce` = ledger_nonce will return # the proposer and the approver blobs - type: internal-save-ledger values: # Not strictly necessary, but can later be used to filter inputs on the # nonce based on whether it's marked "approved" or some other, # currently unknown, value. approved: "approved" inputs: nonce_data: "ledger_nonce" inputs: ledger_config: "ledger_config" nonce: "ledger_nonce" ```
Author
Owner

The ledger state would look like:

Proposer:

{
  "values": {
    "nonce_address": "CNDJiUVK92Vx1XQAatvfaPvspdXrQvGZficdb22AJNv5",
    "nonce_data": "8NWmZpX2rYSQiPjHjFRAKWVWSsLqW2cnoVyKvnapqonb",
    "nonce_authority": "2Z72E62atYfpatQeqPvHZMaabmuz664xq5MRWv9xM5NX",
    "from_address": "2Z72E62atYfpatQeqPvHZMaabmuz664xq5MRWv9xM5NX",
    "to_address": "BNQr6T2UAuEPux1fuiygM6chrT5GkHKaMWeTTaRLmR7g",
    "token_name": "IPDBG",
    "token_amount": "10"
  },
  "signature": "<OpenPGP encoded signature>"
}

Approver:

{
  "values": { "approved": "approved", "nonce_data": "8NWmZpX2rYSQiPjHjFRAKWVWSsLqW2cnoVyKvnapqonb" },
  "signature": "<OpenPGP encoded signature>"
}
The ledger state would look like: Proposer: ```json { "values": { "nonce_address": "CNDJiUVK92Vx1XQAatvfaPvspdXrQvGZficdb22AJNv5", "nonce_data": "8NWmZpX2rYSQiPjHjFRAKWVWSsLqW2cnoVyKvnapqonb", "nonce_authority": "2Z72E62atYfpatQeqPvHZMaabmuz664xq5MRWv9xM5NX", "from_address": "2Z72E62atYfpatQeqPvHZMaabmuz664xq5MRWv9xM5NX", "to_address": "BNQr6T2UAuEPux1fuiygM6chrT5GkHKaMWeTTaRLmR7g", "token_name": "IPDBG", "token_amount": "10" }, "signature": "<OpenPGP encoded signature>" } ``` Approver: ```json { "values": { "approved": "approved", "nonce_data": "8NWmZpX2rYSQiPjHjFRAKWVWSsLqW2cnoVyKvnapqonb" }, "signature": "<OpenPGP encoded signature>" } ```
ryan closed this issue 2025-01-02 00:46:53 +00:00
ryan reopened this issue 2025-01-02 00:46:56 +00:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: public/icepick#28
No description provided.