From 721456831888dff813b16be642fa8d18dcfc22ab Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 12 Nov 2023 19:37:24 -0800 Subject: [PATCH 1/4] fix(fetch.tx): increase returned blocks from bestChain gql request --- src/lib/fetch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 8723d5ba1e..7907858f76 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -482,7 +482,7 @@ type LastBlockQueryFailureCheckResponse = { }; const lastBlockQueryFailureCheck = `{ - bestChain(maxLength: 1) { + bestChain(maxLength: 20) { transactions { zkappCommands { hash From 57b688e10b01b53bdb9721700383f0d7369fd7ce Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 12 Nov 2023 20:29:58 -0800 Subject: [PATCH 2/4] feat(fetch.ts): add length parameter to fetchLatestBlockZkappStatus query --- src/lib/fetch.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 7907858f76..48e081662d 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -481,8 +481,8 @@ type LastBlockQueryFailureCheckResponse = { }[]; }; -const lastBlockQueryFailureCheck = `{ - bestChain(maxLength: 20) { +const lastBlockQueryFailureCheck = (length: number) => `{ + bestChain(maxLength: ${length}) { transactions { zkappCommands { hash @@ -496,10 +496,11 @@ const lastBlockQueryFailureCheck = `{ }`; async function fetchLatestBlockZkappStatus( + blockLength: number, graphqlEndpoint = networkConfig.minaEndpoint ) { let [resp, error] = await makeGraphqlRequest( - lastBlockQueryFailureCheck, + lastBlockQueryFailureCheck(blockLength), graphqlEndpoint, networkConfig.minaFallbackEndpoints ); @@ -513,9 +514,8 @@ async function fetchLatestBlockZkappStatus( return bestChain; } -async function checkZkappTransaction(txnId: string) { - let bestChainBlocks = await fetchLatestBlockZkappStatus(); - +async function checkZkappTransaction(txnId: string, blockLength = 20) { + let bestChainBlocks = await fetchLatestBlockZkappStatus(blockLength); for (let block of bestChainBlocks.bestChain) { for (let zkappCommand of block.transactions.zkappCommands) { if (zkappCommand.hash === txnId) { @@ -542,7 +542,7 @@ async function checkZkappTransaction(txnId: string) { } return { success: false, - failureReason: null, + failureReason: `Transaction ${txnId} not found in the latest ${blockLength} blocks.`, }; } From ec4ff81733454bdcbf7a6c2395b31b9a8cd3f1b8 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 12 Nov 2023 20:46:14 -0800 Subject: [PATCH 3/4] feat(CHANGELOG): add entry for checkZkappTransaction fix --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ff71d070..f6d00daa08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased](https://github.com/o1-labs/o1js/compare/26363465d...HEAD) -> No unreleased changes yet +### Fixed + +- Add a parameter to `checkZkappTransaction` for block length to check for transaction inclusion. This fixes a case where `Transaction.wait()` only checked the latest block, which led to an error once the transaction was included in a block that was not the latest. https://github.com/o1-labs/o1js/pull/1239 ## [0.14.1](https://github.com/o1-labs/o1js/compare/e8e7510e1...26363465d) From e830e098da57775fdef67b4e1b0e6b1cb246a1ff Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 12 Nov 2023 22:07:09 -0800 Subject: [PATCH 4/4] fix(fetch.ts): revert failureReason message on transaction not found --- src/lib/fetch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 48e081662d..768410c1b5 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -542,7 +542,7 @@ async function checkZkappTransaction(txnId: string, blockLength = 20) { } return { success: false, - failureReason: `Transaction ${txnId} not found in the latest ${blockLength} blocks.`, + failureReason: null, }; }