Skip to content

Commit

Permalink
Simple Hash is removed. (#265)
Browse files Browse the repository at this point in the history
* Simple Hash is removed.

The proof mechanism is now not specified anywhere and accepts and uses
whatever the backend supples.

The customer can still specify the proof mechanism as MERKLE_LOG but
cannot specify any other value.

AB#9189
  • Loading branch information
eccles authored May 29, 2024
1 parent 718d598 commit 683f62a
Show file tree
Hide file tree
Showing 40 changed files with 132 additions and 518 deletions.
22 changes: 6 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ You can then use the examples code to create assets (see examples directory):
from os import getenv
from archivist.archivist import Archivist
from archivist.proof_mechanism import ProofMechanism
def create_asset(arch):
Expand Down Expand Up @@ -85,21 +84,13 @@ You can then use the examples code to create assets (see examples directory):
# it does not start with arc_
}
#
# Select the mechanism used to prove evidence for the asset. If the selected proof
# mechanism is not enabled for your tenant then an error will occur.
# If unspecified then SIMPLE_HASH is used.
props = {
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
}
# The first argument are the properties of the asset
# The second argument are the attributes of the asset
# The third argument is wait for confirmation:
# The first argument are the attributes of the asset
# The second argument is wait for confirmation:
# If @confirm@ is True then this function will not
# return until the asset is confirmed on the blockchain and ready
# return until the asset is confirmed and ready
# to accept events (or an error occurs)
#
return arch.assets.create(props=props, attrs=attrs, confirm=True)
return arch.assets.create(attrs=attrs, confirm=True)
# alternatively if some work can be done whilst the asset is confirmed then this call can be
# replaced by a two-step alternative:
Expand Down Expand Up @@ -131,9 +122,8 @@ You can then use the examples code to create assets (see examples directory):
client_secret = tokenfile.read().strip()
# Initialize connection to Archivist. max_time is the time to wait for confirmation
# of an asset or event creation - the default is 1200 seconds but one can optionally
# specify a different value here particularly when creating assets on SIMPLE_HASH
# as confirmation times are much shorter in this case.
# of an asset or event creation - the default is 300 seconds but one can optionally
# specify a different value.
with arch = Archivist(
"https://app.datatrails.ai",
(client_id, client_secret),
Expand Down
2 changes: 1 addition & 1 deletion archivist/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def create(
Creates asset with defined properties and attributes.
Args:
props (dict): Properties - usually only the proof_mechanism setting
props (dict): Properties
attrs (dict): attributes of created asset.
confirm (bool): if True wait for asset to be confirmed.
Expand Down
1 change: 0 additions & 1 deletion archivist/confirmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def _wait_for_confirmation(self: Managers, identity: str) -> ReturnTypes:
f"confirmation for {identity} FAILED - this is unusable"
)

# Simple hash and merkleLog
if status in (
ConfirmationStatus.CONFIRMED.name,
ConfirmationStatus.COMMITTED.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"from archivist.archivist import Archivist\n",
"from archivist.compliance_policy_requests import CompliancePolicyCurrentOutstanding\n",
"from archivist.constants import ASSET_BEHAVIOURS\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger\n",
"\n",
"filterwarnings(\"ignore\", message=\"Unverified HTTPS request\")"
Expand Down Expand Up @@ -164,7 +163,6 @@
" },\n",
" ],\n",
" \"behaviours\": ASSET_BEHAVIOURS,\n",
" \"proof_mechanism\": ProofMechanism.SIMPLE_HASH.name,\n",
" \"attributes\": {\n",
" \"arc_display_name\": \"Gringott's Vault 2\",\n",
" \"arc_description\": \"Main door to the second level security vault in Gringott's Wizarding Bank\",\n",
Expand Down Expand Up @@ -355,7 +353,6 @@
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
" \"at_time\": \"2023-01-16T11:51:30Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"827586838445807967\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
Expand All @@ -377,7 +374,6 @@
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
" \"at_time\": \"2023-01-16T11:51:30Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"827586838445807967\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
" \"at_time\": \"2023-01-16T11:52:27Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"827586838445807967\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
Expand All @@ -322,7 +321,6 @@
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
" \"at_time\": \"2023-01-16T11:52:27Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"827586838445807967\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
Expand Down
1 change: 0 additions & 1 deletion archivist/notebooks/Checking the Dog's Weight.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from archivist.compliance_policy_requests import (\n",
" CompliancePolicyRichness,\n",
")\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down Expand Up @@ -207,7 +206,6 @@
" \"owner\": \"0x5284e740A744F075E402f7fB0c4485532ddf4Af8\",\n",
" \"at_time\": \"2023-06-02T20:57:01Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"8275868384\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/0a62f7c9-fd7b-4791-8041-01218d839ec1\"\n",
Expand Down
6 changes: 1 addition & 5 deletions archivist/notebooks/Create Event with Verified Domain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,8 @@
" # The first argument is the attributes of the asset\n",
" # The second argument is wait for confirmation:\n",
" # If @confirm@ is True then this function will not\n",
" # return until the asset is confirmed on the blockchain and ready\n",
" # return until the asset is confirmed and ready\n",
" # to accept events (or an error occurs)\n",
" # After an asset is submitted to the blockchain (submitted),\n",
" # it will be in the \"Pending\" status.\n",
" # Once it is added to the blockchain, the status will be changed to \"Confirmed\"\n",
" return arch.assets.create(attrs=attrs, confirm=True)"
]
},
Expand Down Expand Up @@ -276,7 +273,6 @@
" \"confirmation_status\": \"CONFIRMED\",\n",
" \"identity\": \"assets/0047715f-368e-4a62-aa04-48e6fa974e85\",\n",
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"public\": false,\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\",\n",
Expand Down
1 change: 0 additions & 1 deletion archivist/notebooks/Feeding the Dog Hourly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from archivist.compliance_policy_requests import (\n",
" CompliancePolicyPeriodOutstanding,\n",
")\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from archivist.compliance_policy_requests import (\n",
" CompliancePolicyDynamicTolerance,\n",
")\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down
1 change: 0 additions & 1 deletion archivist/notebooks/Feeding the Dog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from archivist.compliance_policy_requests import (\n",
" CompliancePolicyCurrentOutstanding,\n",
")\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down Expand Up @@ -208,7 +207,6 @@
" \"owner\": \"0x5284e740A744F075E402f7fB0c4485532ddf4Af8\",\n",
" \"at_time\": \"2023-06-02T21:33:34Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"8275868384\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/0a62f7c9-fd7b-4791-8041-01218d839ec1\"\n",
Expand Down
2 changes: 0 additions & 2 deletions archivist/notebooks/Find Artist and Create Cover Art.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down Expand Up @@ -235,7 +234,6 @@
" \"owner\": \"0x5284e740A744F075E402f7fB0c4485532ddf4Af8\",\n",
" \"at_time\": \"2023-06-02T21:01:56Z\",\n",
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
" \"chain_id\": \"8275868384\",\n",
" \"public\": false,\n",
" \"tenant_identity\": \"tenant/0a62f7c9-fd7b-4791-8041-01218d839ec1\"\n",
Expand Down
1 change: 0 additions & 1 deletion archivist/notebooks/Playing Fetch Every 5 Minutes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from archivist.compliance_policy_requests import (\n",
" CompliancePolicySince,\n",
")\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger\n",
"from archivist.constants import ASSET_BEHAVIOURS"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger\n",
"from archivist.constants import ASSET_BEHAVIOURS"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger\n",
"from archivist.constants import ASSET_BEHAVIOURS"
]
Expand Down
1 change: 0 additions & 1 deletion archivist/notebooks/Sharing Artist Asset with User.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"from dotenv import load_dotenv\n",
"\n",
"from archivist.archivist import Archivist\n",
"from archivist.proof_mechanism import ProofMechanism\n",
"from archivist.logger import set_logger\n",
"from archivist.constants import ASSET_BEHAVIOURS"
]
Expand Down
17 changes: 0 additions & 17 deletions archivist/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .archivist import Archivist
from .dictmerge import _deepmerge
from .logger import set_logger
from .proof_mechanism import ProofMechanism
from .utils import get_auth

filterwarnings("ignore", message="Unverified HTTPS request")
Expand Down Expand Up @@ -81,15 +80,6 @@ def common_parser(description: str):
default="https://app.datatrails.ai",
help="url of Archivist service",
)
parser.add_argument(
"-p",
"--proof-mechanism",
type=ProofMechanism,
action=EnumAction,
dest="proof_mechanism",
default=None,
help="mechanism for proving the evidence for events on the Asset",
)
parser.add_argument(
"--auth-token",
type=str,
Expand Down Expand Up @@ -152,13 +142,6 @@ def endpoint(args):
arch = None
LOGGER.info("Initializing connection to DATATRAILS...")
fixtures = {}
if args.proof_mechanism is not None:
fixtures = {
"assets": {
"proof_mechanism": args.proof_mechanism.name,
},
}

if args.namespace is not None:
fixtures = _deepmerge(
fixtures,
Expand Down
7 changes: 4 additions & 3 deletions archivist/proof_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Enumerated type that allows user to select the proof_mechanism option when
creating an asset.
Currently there is only one proof mechanism so this code is here only for
compatibility.
"""

# pylint: disable=unused-private-member
Expand All @@ -14,8 +16,7 @@ class ProofMechanism(Enum):
"""Enumerate proof mechanism options"""

# previously used but now removed
__RESERVED = 1
#: Assets and events are proven using a hash of the originator's evidence
SIMPLE_HASH = 2
__RESERVED1 = 1
__RESERVED2 = 2
#: Assets and events are proven using a merkle log hash of the originator's evidence
MERKLE_LOG = 3
1 change: 0 additions & 1 deletion docs/code/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ Shows all code

timestamp
errors
proof_mechanism
10 changes: 0 additions & 10 deletions docs/code/proof_mechanism.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/fixtures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ and locations.
from archivist.archivist import Archivist
from archivist.errors import ArchivistError
from archivist.proof_mechanism import ProofMechanism
# Oauth2 token that grants access
with open(".auth_token", mode='r', encoding="utf-8") as tokenfile:
Expand All @@ -22,11 +21,6 @@ and locations.
ledger = Archivist(
"https://app.datatrails.ai",
authtoken,
fixtures = {
"assets": {
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
}
},
)
# lets define doors in our namespace that reside on the ledger...
Expand Down
4 changes: 0 additions & 4 deletions examples/applications_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from warnings import filterwarnings

from archivist.archivist import Archivist
from archivist.proof_mechanism import ProofMechanism

filterwarnings("ignore", message="Unverified HTTPS request")

Expand Down Expand Up @@ -101,9 +100,6 @@ def main():
) as arch1:
# create an asset
asset = arch1.assets.create(
props={
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
},
attrs={
"arc_display_name": "display_name",
"arc_description": "display_description",
Expand Down
Loading

0 comments on commit 683f62a

Please sign in to comment.