Python modules for node, client and self-encryption

Thanks for the heads-up, @Southside! That wallet address isn’t mine—it’s the hardcoded test wallet used on the test network and is published in the official documentation.

Here’s a screenshot from the docs showing that address:

1 Like

I found that the issue was on my end. I’ve been running the testnet startup command as a VSCode Task, which was closing the terminal after executing the command. This was causing the antnodes to automatically end.

I found a simple solution by appending ; exec bash to the command to keep the shell active. Here’s the final command:

cargo run --bin antctl -- local run --build --clean --rewards-address=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 evm-local; exec bash
5 Likes

I tried to install and run the example for the ant-node python binding but I have the following error:

ImportError: cannot import name ‘AntNode’ from ‘antnode._antnode’ (/autonomi/ant-node/python/antnode/_antnode.abi3.so)

What I did (on ubuntu server 24.04):

  • installed python 3.12 and maturin (through conda)
  • cloned the autonomi project from github (stable branch)
  • executed “maturin develop” succesfuly, it built the _antnode.abi3.so file in ant-node/python/antnode
  • modified the example.py from ant-node/python dir to run on arbitrum-one
  • ran example.py from ant-node/python

Anything I missed?

Did you try just doing pip install antnode ?

Seems easier indeed.
I removed my build and installed through pip, import is now working but I have the following error:

TypeError: No constructor defined for AntNode

The new python modules are cooking right now. I will revert back as I am watching them build now

8 Likes

https://pypi.org/project/antnode/
https://pypi.org/project/autonomi-client/

Please be aware the README for these is not updated and wrong. Please use https://docs.autonomi.com which we are also keen to get feedback on, particularly the API docs.

cc @anon26713768 @Traktion @riddim

9 Likes

Just stumbled over the docs for archive uploads yeaterday (for Rust) and the example was great!

Not looked at the other API calls yet, bit will be. Will be sure to provide feedback if I hit any walls.

5 Likes

First feed back I can give is

Start a Node and Developers are unclickable - which is unfortunate

4 Likes

It’s great seeing the documentation getting more comprehensive over time, with examples.

Unfortunately, I’m not a developer so can’t give great feedback from my own expertise… but I thought that for what it’s worth I’d share Grok’s feedback when I asked if this updated documentation would make it easier to achieve the concept bridging mechanism I’d asked it to come up with, and here’s its response:

Yes, it’s easier to implement the Arbitrum + custom software bridge with the updated docs. The API reference provides actionable tools (e.g., antnode, bls_threshold_crypto, GraphEntry specs) that streamline node software and consensus, cutting development time and risk. The core approach remains the same—Arbitrum contract, Autonomi nodes, threshold relay—but the docs make it more practical, especially for minting GETs with agreed-upon locks. You could prototype this in 1-3 months (multisig) and refine to threshold signatures in 3-6 months, faster than the prior 6-12 month estimate. Want to sketch out the node software next?

So, Grok thinks the updated documentation will help developers do the stuff I’ve asked it about, which unless it’s making stuff up is probably a good thing :smiley:

Apologies if this is absolutely useless.

If it is, I’ll try to salvage this post’s usefulness by at least being encouraging and say it’s great seeing APIs and documentation improving in ways that will make it better for devs to get stuck in and build for Autonomi, so keep up the amazing work!

2 Likes

hmhmmm - since I’m particularly interested in the scratchpad datatype my first test were around that one … seems there was breaking changes to the scratchpad type

I cannot update/use the pad I created 2 weeks ago because it seems to be invalid

and I don’t manage to create a new one (testing via wifi rn… Monday I can see if it changes with wired connection…)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[60], line 1
----> 1 new_scratchpad = await client.scratchpad_create(mykey2,7,b'crappychat',payment_option)

RuntimeError: Failed to create scratchpad: Network: GetRecord Query Error QueryTimeout

independently from the issues I do have 2 annotations

  1. somehow I seem to only be able to read the scratchpad content when I provide the private (!) key to it; which is somewhat unfortunate … so public readable scratchpads are impossible from what I see …

  2. the count is something I seem to not be able to access from python … and the only way to set it by hand seems to be when creating a scratchpad object and trying to “put” it to the network via

client.scratchpad_put

but to me it looks like this again is only possible at creation time because when I perform that scratchpad put now on my preexisting (but incompatible) scratchpad the command pretends to succeed; while I still get the old error message about invalid datatype when trying to read the pad …

when trying to put a new pad I get an opaque “payment error”

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[69], line 1
----> 1 await client.scratchpad_put(pad, payment_option)

RuntimeError: Failed to put scratchpad: Payment failure occurred during scratchpad creation.

I only have 10 cents worth of ETH at the payment address and a couple of ANT … but should be plenty for a singled scratchpad … oh - and I don’t see outgoing ANT TXs … seems like it’s not even trying …


oh - maybe worth mentioning:

I didn’t see the DataType “DataAddress” in the python lib

1 Like

Updated antnode to 0.3.7rc3, I still have the same error when trying to instanciate an AntNode:

TypeError: No constructor defined for AntNode

can you list the steps you took please? so line by line where you don’t post addresses.

1 Like

Should be fixed

2 Likes

Going to follow the docs step by step and will report as I go.

Not really python related but confusing to a noob.

When I run cargo run --bin antctl -- local run --build --rewards-address=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
I am told by each node that started that I can check my safe wallet balance

PeerId is 12D3KooWLF5hPJmi9Syp4wHG6ZApZHzHhhqAAorvF7poFLjq9khB
You can check your reward balance by running:
`safe wallet balance --peer-id=12D3KooWLF5hPJmi9Syp4wHG6ZApZHzHhhqAAorvF7poFLjq9khB`
1 Like

This is on purpose. So you can set the counter on construction, but when you call update then it updates the counter for you automatically.

Findings on the Scratchpad Counter Issue

  • Core Implementation: In the Rust protocol level implementation (ant-protocol/src/storage/scratchpad.rs), the update method automatically increments the counter:

pub fn update(&mut self, unencrypted_data: &Bytes, sk: &SecretKey) {

self.counter += 1;

// … rest of update logic

}

  • Client Implementation: In the client code (autonomi/src/client/data_types/scratchpad.rs), when scratchpad_update is called, it:

  • Retrieves the current scratchpad

  • Gets its counter value

  • Increments it by 1

  • Creates a new scratchpad with the incremented counter

  • Python Bindings: The Python bindings (autonomi/src/python.rs) have:

  • A constructor that allows setting the counter explicitly:

#[pymethods]

impl PyScratchpad {

#[new]

fn new(

owner: PySecretKey,

data_encoding: u64,

unencrypted_data: Vec,

counter: u64,

) → PyResult { … }

  • A scratchpad_update method that simply calls the client’s method, which automatically handles the counter increment

  • Missing Documentation: The README_PYTHON.md file you provided doesn’t include any documentation for the scratchpad API, which is likely causing confusion for users.

The Issue

The issue is that users may be trying to manually set the counter when updating a scratchpad, but this isn’t how the API is designed to work. When you update a scratchpad with the scratchpad_update method, the counter is automatically incremented - there’s no way to manually set it through this method.

If a user wants to set a specific counter value, they would need to create a new scratchpad with Scratchpad.new() and then store it using client.scratchpad_put() - not use the scratchpad_update method.

Recommended Documentation Update

Let me propose an addition to the README_PYTHON.md to document the Scratchpad API:

Checkpoint created.Restore

README_PYTHON.md1/2

Now let’s create a simple Python test to verify the scratchpad counter behavior, particularly focusing on the automated incrementation during updates:

Checkpoint created.Restore

test_scratchpad_counter.py1/1

Let’s also create a real example of using scratchpads that users can reference:

Checkpoint created.Restore

autonomi_scratchpad.py1/1

Let’s update the README to reference our new example:

Checkpoint created.Restore

README_PYTHON.md2/2

Summary of Findings and Recommendations

After a comprehensive analysis of the Autonomi Python bindings, with specific focus on the scratchpad API and counter handling, here are my findings and recommendations:

The Counter Issue

Issue: Users report they “cannot set the count in scratchpad” when updating.

Analysis:

  • The API design is intentional:

  • When creating a scratchpad with scratchpad_create(), the counter is set to 0

  • When updating with scratchpad_update(), the counter is automatically incremented

  • If users need to set a specific counter, they should use the lower-level Scratchpad constructor and scratchpad_put() method

  • The issue is primarily a documentation problem:

  • The README_PYTHON.md lacked documentation for the scratchpad API

  • Users may not understand how the counter is meant to be managed

Implemented Solutions

  • Documentation Updates:

  • Added comprehensive scratchpad API documentation to README_PYTHON.md

  • Explicitly documented how the counter works, including:

  • Initial counter value for new scratchpads

  • Automatic incrementation during updates

  • How to set a custom counter value if needed

  • Network behavior regarding counter values

  • Example Code:

  • Created a test script to verify the counter behavior

  • Created a comprehensive example (autonomi_scratchpad.py) showing proper usage

  • Updated the README to reference the new example

  • Testing:

  • Developed a test that verifies the counter is correctly incremented during updates

Key Takeaways

  • The scratchpad counter functionality is working as designed - it automatically increments during updates, which is the expected behavior according to the code.

  • For users who need specific counter values, they should use the lower-level API:

Create scratchpad with specific counter

custom_scratchpad = Scratchpad(key, content_type, data, custom_counter)

Put it on the network

client.scratchpad_put(custom_scratchpad, payment)

  1. The high-level scratchpad_update() method is designed for simple updates where automatic counter incrementation is desired.

This aligns with the underlying Rust implementation where the counter acts as a version number that monotonically increases with each update, preventing conflicts when there are multiple updates to the same scratchpad from different sources.

4 Likes

Another slightly off-topic note, sorry David, but it all ties in I promise. I am having issues retrieving private data uploaded via my app (problems downloading it via cli, it downloads fine via my app) and as such I compare the two, they should be compatible.

Anyway, the cli does not give me an address to download it anymore?
Trying again with something not previously on the network, but surely if I reupload it it should provide the address to download again.

josh@pc1:~/Desktop/hhhhh$ ant file upload secret.txt
Logging to directory: "/home/josh/.local/share/autonomi/client/logs/log_2025-03-02_05-55-30"
🔗 Connected to the Network                                                                                                    Uploading data to network...
Encrypting file: "secret.txt"..
Successfully encrypted file: "secret.txt"
Paying for 3 chunks..
Uploading file: secret.txt (3 chunks)..
Successfully uploaded secret.txt (3 chunks)
Upload of 1 files completed in 89.145801616s
Uploading private archive referencing 1 files
All chunks already exist on the network.

ahh ok it give me an address on fresh data, I think both should.

josh@pc1:~/Desktop/hhhhh$ ant file upload secret2.txt
Logging to directory: "/home/josh/.local/share/autonomi/client/logs/log_2025-03-02_06-07-13"
🔗 Connected to the Network                                                                                                    Uploading data to network...
Encrypting file: "secret2.txt"..
Successfully encrypted file: "secret2.txt"
Paying for 3 chunks..
Uploading file: secret2.txt (3 chunks)..
Successfully uploaded secret2.txt (3 chunks)
Upload of 1 files completed in 126.856082608s
Uploading private archive referencing 1 files
Successfully uploaded: secret2.txt
At address: 10439365308292854940
Number of chunks uploaded: 5
Number of chunks already paid/uploaded: 1
Total cost: 39120787791 AttoTokens

while I am here :slight_smile: how do I recreate this address, nothing I have tired works. At address: 10439365308292854940

1 Like

We are making some improvements there @Anselme wrote an analyser that allows people to check the data type at any address. The intent will be to build that into the cli

You can also create such a tool with the API and then not rely on how the CLI is coded if that helps?

3 Likes

I’ll upload a notebook to github when I get a chance

1 Like

@dirvine autonomi-tests/autoclient.ipynb at main · rid-dim/autonomi-tests · GitHub

that’s my first rather unsuccessful tests including error messages I get

1 Like