Fix chain anchor: handle already-registered hashes and gas limit override - #79
Merged
Merged
Conversation
Add pre-check in anchor()/anchor_for() to detect already-registered hashes before sending transactions, preventing wasted gas and unhelpful revert errors. Includes DataAlreadyRegisteredError exception, CLI error handling with human-readable and JSON output, and non-fatal handling in chain protect --anchor-new.
RPC gas estimation can return values exceeding block limits. Add --gas CLI option and CHAIN_GAS_LIMIT env var to set an explicit gas limit, bypassing estimation. Applied to all chain write commands: anchor, access, status, transfer, delegate, transform, protect.
Anchors a hash, waits for propagation, then verifies a second anchor attempt raises DataAlreadyRegisteredError with correct attributes.
Verifies that setting an explicit gas limit too low for a contract call raises ChainTransactionError gracefully rather than an unhandled crash. Node rejects pre-broadcast, so no gas is wasted.
This was referenced Mar 2, 2026
dependencies was placed after [project.urls] section header, causing setuptools to parse it as a URL entry rather than a project dependency list. CI failed with "project.urls.dependencies must be string".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chain anchornow pre-checks if a hash is already registered before sending a transaction, preventing wasted gas and unhelpful revert errors. Shows owner, type, and timestamp in both human-readable and JSON output.chain protect --anchor-newtreats already-registered new hash as non-fatal.--gasoption to all chain write commands (anchor,access,status,transfer,delegate,transform,protect) andCHAIN_GAS_LIMITenv var, bypassing RPC estimation that can return values exceeding block limits.Closes #76
Closes #75
Changes
exceptions.pyDataAlreadyRegisteredErrorwithdata_hash,owner,timestamp,data_typecore/chain_client.pyanchor()/anchor_for(),gas_limitparam, skip estimation when explicitcli.py--gason 7 write commands,gas_limitin_chain_configconfig.pyCHAIN_GAS_LIMITenv var.env.exampleCHAIN_GAS_LIMITREADME.mdCLAUDE.mdCHANGELOG.md[0.8.1]and[0.8.2]entries__init__.py/pyproject.toml0.8.0→0.8.2tests/test_chain_client.pytests/test_cli.pytests/test_integration.pyTest plan
pytest --ignore=tests/test_integration.py— 545 passedpytest tests/test_chain_client.py— 85 passedpytest tests/test_cli.py -k chain— 74 passed