Archival Node Configuration - Behaviour of algod REST API

Hi Algorand Community

I have a VM running an archival node and I am using the algod REST API to retrieve blocks and transactions. Since my disk space is limited, my idea was to run the node in archival node for a while and then switch to non-archival.

I assumed thereby I would still be able to access the archived data through the REST API, without filling up more disk space. However, once archival is set to be false, I get the following error from the REST API with any round number:

GET  /v2/blocks/0?format=json

500 Internal Server Error
{
    "message": "failed to retrieve information from the ledger"
}

Does the archival configuration have an influence on the behaviour of the algod REST API? From what I can see in the data directory, the archived data still remains after switching.

Once you switch the configuration from archival into a non-archival, the node would delete the old information on the subsequent restart.

The archival/non-archival doesn’t directly change the way the REST API works. The REST API would give you the information that the ledger currently maintain. In your case, round 0 was deleted once you switched to non-archival.

I don’t know why you’re writing

From what I can see in the data directory, the archived data still remains after switching.

As far as I know, that is not correct. The old blocks are expected to be removed from the mainnet-v1.0/ledger.block.sqlite database.

Ah thanks for the clarification. You are right, I checked the sqlite and realised the blocks get deleted.