Ante Historical Test with ZK

Ante
2 min readSep 29, 2023

Hello Anteans! Today we’re going to talk about a new type of Ante test that implements Axiom!

Axiom is a ZK coprocessor that allows anybody to query all historical Ethereum data of the entire blockchain, resulting in a trustless ZK-verified result onchain.

Ante tests previously have been able to only check and test conditions onchain that are happening now. For example, if the price of USDC gets depegged for 1 hour, the Ante test would only fail during that hour. If USDC gets back to being pegged to the USD, then the test will no longer fail. Axiom changes all that as it allows us to test conditions that existed in the past!

To demonstrate, we created AnteTUSDHistoricalPriceTest.sol, which uses the query capabilities of Axiom to be able to check the test condition. And because we use Axiom’s query, we can check the test condition at any block in the history of the Ethereum blockchain.

To do this, let’s first leave the Axiom query portion to the experts. Given that we have their query answer already, we will have the following:

  • keccakBlockResponse
  • keccakAccountResponse
  • keccakStorageResponse
  • blockResponses
  • accountResponses
  • storageResponses

The keccak outputs are used to verify the information is valid onchain with Axiom’s AxiomV1Query contract. The other outputs correspond to the individual blocks, addresses, and storage slots queried. The first step in checking if this test passes is to make sure that the responses received are valid using AxiomV1Query’s areResponsesValid view function.

These are the outputs from the Axiom query that we can use to check and verify the True USD being pegged or not. How we do that is by using the Chainlink Aggregator price feed contract. The Chainlink Aggregator contract’s latestRoundData will give us the answer which represents the current value of TUSD.

To use this feature historically though, we’ll have to pick out the information that creates latestRoundData, which in this case are s_hotVars and s_transmissions. Grabbing those, we’ll be able to check the answers just like we do in latestRoundData!

This is probably one of the more simple Ante tests we can write that can check historical data! The use of Axiom to access historical data on mainnet can be extended to many other types of Ante tests. What other historical tests can we create? Want to contribute? Come and discuss with us via Discord or Twitter!

--

--

Ante

Building a Smart Tests Community for @AnteFinance