generated from midnightntwrk/midnight-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Context & versions:
MacOS. Using standalone local network for testing smart contract.
% compact --version && compact list -i
compact 0.2.0
compact: installed versions
→ 0.26.0Used ts packages:
"@midnight-ntwrk/compact-runtime": "^0.9.0",
"@midnight-ntwrk/ledger": "^4.0.0",
"@midnight-ntwrk/midnight-js-contracts": "^2.0.2",
"@midnight-ntwrk/midnight-js-http-client-proof-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-indexer-public-data-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-level-private-state-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-network-id": "^2.0.2",
"@midnight-ntwrk/midnight-js-node-zk-config-provider": "^2.0.2",
"@midnight-ntwrk/midnight-js-types": "^2.0.2",
"@midnight-ntwrk/wallet": "^5.0.0",
"@midnight-ntwrk/wallet-api": "^5.0.0",
"@midnight-ntwrk/zswap": "^4.0.0",
Steps to reproduce:
- Created this smart contract
pragma language_version >= 0.18.0 && < 0.19.0;
import CompactStandardLibrary;
constructor() {
}
export circuit blockTimeWithinBounds(lower: Uint<64>, upper: Uint<64>): [Boolean, [Boolean, Boolean]] {
const withinLowerBound = !kernel.blockTimeLessThan(disclose(lower));
const withinUpperBound = !kernel.blockTimeGreaterThan(disclose(upper));
return [withinLowerBound && withinUpperBound, [withinLowerBound, withinUpperBound]];
}
- I deployed this to the local standalone network
- Called the
blockTimeWithinBoundswith arguments:[0, 18446744073709551615]Got result[true, [true, true]] - Went to Epoch Converter and copied the current Unix epoch time.
- Called the circuit with arguments
[<copied unix epoch time>, 18446744073709551615]=> Transaction failed with error:
{
"circuitId": "timeBlockWithinBounds",
"tx": {
"__wbg_ptr": 1398672
},
"status": "FailEntirely",
"txId": "000000000f62bcd4e401da0e1186eaadba3c072e84ab4632d2ee8d265eb6f343813aa0dd",
"txHash": "db57b7000d27161d6aec92cbf11a5fdb96d9b04d3d3410c50cf41df56f9804bd",
"blockHeight": 4978,
"blockHash": "35bfb99de7e231b871ebfddbebfb2b184e91695b26656f8259b1b82a939ded00"
}
at submitCallTx (./node_modules/@midnight-ntwrk/midnight-js-contracts/src/submit-call-tx.ts:67:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async main (./main.ts:41:14)
- Called the
blockTimeWithinBoundswith arguments:[0, 18446744073709551615]again. Got error:
Unexpected length of input
at __wbindgen_error_new (./node_modules/@midnight-ntwrk/ledger/midnight_ledger_wasm_bg.js:7821:17)
at wasm://wasm/0152566a:wasm-function[4615]:0x4fea6e
at wasm://wasm/0152566a:wasm-function[2684]:0x421cc8
at wasm://wasm/0152566a:wasm-function[4285]:0x4c1604
at ZswapChainState.deserialize (./node_modules/@midnight-ntwrk/ledger/midnight_ledger_wasm_bg.js:7183:26)
at deserializeZswapState (./node_modules/@midnight-ntwrk/midnight-js-indexer-public-data-provider/src/indexer-public-data-provider.ts:93:19)
at Object.queryZSwapAndContractState (./node_modules/@midnight-ntwrk/midnight-js-indexer-public-data-provider/src/indexer-public-data-provider.ts:385:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getPublicStates (./node_modules/@midnight-ntwrk/midnight-js-contracts/src/get-states.ts:48:5)
at async getStates (./node_modules/@midnight-ntwrk/midnight-js-contracts/src/get-states.ts:73:32)
Note
If contract contain multiple circuits, if the transaction fail happens, all of them would fail onwards with same error, not just the one that triggered it.
Actual behavior:
Calling circuit bricks deployed contract.
Expected behavior:
Circuit returns value true or false, or in worst case fails. Do not bricks contract.
Reactions are currently unavailable