Files
dshackle/foundation
Vadim Filin 5414e06e46 Add support for Algorand Virtual Machine (AVM) blockchain (#813)
* add AVM blockchain type support for Algorand

Introduce a new blockchain type `avm` (Algorand Virtual Machine) so
Algorand-based chains (Mainnet, Testnet, Betanet) declared in chains.yaml
can be parsed and driven through dshackle's generic polling pipeline.

Key additions:
- BlockchainType.AVM (JSON_RPC) and `avm` mapping in chain codegen
- AvmChainSpecific: polls `algod_getBlock` for latest block and uses
  `algod_status` / `algod_genesis` for health and settings validation
- DefaultAvmMethods: allowed algod_* RPC surface with send-transaction
  broadcast quorum and hardcoded `algod_chainId` / `algod_genesisId`
- AvmLowerBoundService / AvmLowerBoundStateDetector for lower-bound tracking
- Registration in ChainSpecificRegistry and CallTargetsHolder
- Unit tests for block parsing, sync validation and method policies

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* inline DummyChainReader in AVM test

Match the Starknet test pattern and drop the dedicated DummyChainReader
file; instead pass an anonymous ChainReader directly where needed.

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* fix AVM network validation logic

Validation used AND across all conditions, so when netVersion was 0
(typical for non-EVM chains) the check short-circuited and allowed a
mismatching chain.chainId through. Simplify to the Cosmos pattern:
reject when chain.chainId is set and doesn't match genesis.network.

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* switch AVM to REST transport for native algod nodes

Native Algorand algod nodes expose a REST API (/v2/status, /v2/blocks,
/v2/transactions, ...) rather than JSON-RPC, so drive AVM upstreams
through dshackle's REST reader instead:

- BlockchainType.AVM is now ApiType.REST
- AvmChainSpecific polls GET#/v2/status for latest block info and uses
  GET#/v2/genesis for chain-id validation, both via RestParams
- DefaultAvmMethods exposes the algod /v2 endpoints with VERB#/path
  identifiers (POST#/v2/transactions uses BroadcastQuorum for sends)
- Tests updated to match the REST-based method names

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* align AVM endpoints with algod OpenAPI spec

Validated the AVM method surface against the official algod spec
(algorand/go-algorand algod.oas3.yml) and corrected mismatches:

Wrong paths removed:
- GET /v2/genesis, /v2/versions, /v2/health, /v2/ready, /v2/metrics
  (these exist at root level, not under /v2/)
- GET /v2/blocks/{round}/header (use header-only query on /v2/blocks/{round})
- GET /v2/blocks/{round}/transactions (no such path)
- GET /v2/lightheader/{round} (real path is /v2/blocks/{round}/lightheader/proof)
- POST /v2/transactions/dryrun (real path is /v2/teal/dryrun, already listed)

Added real endpoints:
- Root: GET /genesis, /health, /ready, /metrics, /versions, /swagger.json
- /v2/blocks/*/txids, /v2/blocks/*/logs, /v2/blocks/*/lightheader/proof
- /v2/accounts/*/transactions/pending
- /v2/deltas/*, /v2/deltas/*/txn/group, /v2/deltas/txn/group/*

Also fixed AvmChainSpecific settings validator: use GET#/genesis (root)
instead of the non-existent GET#/v2/genesis.

Added regression test asserting the spurious paths are NOT callable.

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* fetch real AVM block data via chained api.read

parseBlock now uses the ChainReader passed through AbstractPollChainSpecific
to fetch GET#/v2/blocks/{lastRound}?header-only=true after /v2/status,
so BlockContainer.timestamp comes from block.ts and hash/parentHash
decode from block.seed/block.prev (base64 -> 32 raw bytes) instead of
being synthesized from the round number.

Also differentiate quorum per method in DefaultAvmMethods: single-
resource lookups (/v2/blocks/{round}, /v2/accounts/{addr}, etc.) now
use NotNullQuorum so a single replica returning empty/404 doesn't
shadow a valid response from another upstream. List and status
endpoints keep AlwaysQuorum; send endpoints keep BroadcastQuorum.

https://claude.ai/code/session_01TZ64DZis9YaJSU3oMwtRLe

* Update submodules

* Update chains

* Fix settings validation

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-23 13:10:56 +02:00
..
2026-01-06 16:32:03 +04:00
2026-01-06 16:32:03 +04:00