NEAR-Edu / near-certification-tools

2 stars 2 forks source link

Out of bounds, please use a smaller from_index #60

Closed ryancwalsh closed 2 years ago

ryancwalsh commented 2 years ago

Basically, to update what we were thinking in https://github.com/NEAR-Edu/near-certification-tools/issues/52 now that we know about the burning event, we're now thinking:

So then you did some commits like https://github.com/NEAR-Edu/near-certification-tools/commit/c8e40e1c90d9f81ab2052d28b6362a518b123d0b

And now it's possible to delete certs. 🎉

But here is a new issue:

NEAR_ENV=mainnet near view certificates.unv.near nft_tokens_for_owner '{"account_id": "ryancwalsh.near"}'                
View call: certificates.unv.near.nft_tokens_for_owner({"account_id": "ryancwalsh.near"})
An error occured
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "EdyRCoMpeVmTJDB9qA7kxGGBv6qjB3dsPhwYhebhtJV5",
  "block_height": 65034888,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)
TypedError: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "EdyRCoMpeVmTJDB9qA7kxGGBv6qjB3dsPhwYhebhtJV5",
  "block_height": 65034888,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'UntypedError',
  context: undefined
}
encody commented 2 years ago

@ryancwalsh Rebuild, redeploy (no migration necessary). The accounts from which all certificates were deleted will be in an invalid state. To recover them to a valid, empty state, mint them new certificates and delete them again, and it will reset to the correct empty state.

encody commented 2 years ago

Test case: https://stats.gallery/testnet/dev-1651868096177-76634945131771/contract?t=week

ryancwalsh commented 2 years ago

@encody I don't know if I'm doing something wrong, but I pulled the latest main, rebuilt, redeployed, minted a new cert for ryancwalsh.near, and then tried to delete it:

 ~/code/NCD/near-certification-tools/web-app/ [main*] NEAR_ENV=mainnet near call certificates.unv.near cert_delete '{ "token_id": "30282726f76540ff848cd3ea5ef76f4a"}' --account-id certificates.unv.near --depositYocto 1 --gas 300000000000000
Scheduling a call: certificates.unv.near.cert_delete({ "token_id": "30282726f76540ff848cd3ea5ef76f4a"}) with attached 0.000000000000000000000001 NEAR
Doing account.functionCall()
Receipts: BAPJdH5A2QSB1fsjRXzWGJ3WqoidZf8bHDAsg4G1a2N3, 3HTAyXbGLheqkZDS6HUxneWrA9XSajCCF7bHfPFCYWKu
    Failure [certificates.unv.near]: Error: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'called `Option::unwrap()` on a `None` value', src/contract/invalidate.rs:83:63"}}
ServerTransactionError: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'called `Option::unwrap()` on a `None` value', src/contract/invalidate.rs:83:63"}}
    at Object.parseResultError (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:31:29)
    at Account.signAndSendTransactionV2 (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:160:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async scheduleFunctionCall (/usr/local/lib/node_modules/near-cli/commands/call.js:57:38)
    at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'FunctionCallError',
  context: undefined,
  index: 0,
  kind: {
    ExecutionError: "Smart contract panicked: panicked at 'called `Option::unwrap()` on a `None` value', src/contract/invalidate.rs:83:63"
  },
  transaction_outcome: {
    block_hash: 'F5TBQ4UQKdBJzZnAqYaMDtENjF8NYkoHQoqKaT84d9D4',
    id: '49JXHPbvMJVqe3btsBkZdQuDCExF4ZcEn9vfKcoVTba1',
    outcome: {
      executor_id: 'certificates.unv.near',
      gas_burnt: 2428050684172,
      logs: [],
      metadata: [Object],
      receipt_ids: [Array],
      status: [Object],
      tokens_burnt: '242805068417200000000'
    },
    proof: [ [Object], [Object], [Object], [Object] ]
  }
}
 ~/code/NCD/near-certification-tools/web-app/ [main*] NEAR_ENV=mainnet near view certificates.unv.near nft_tokens_for_owner '{"account_id": "ryancwalsh.near"}'
View call: certificates.unv.near.nft_tokens_for_owner({"account_id": "ryancwalsh.near"})
An error occured
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "HdSjWXm4vDGorhvbCzmT8HmKiwHdDtErh15VTLPSWVSZ",
  "block_height": 65039561,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)
TypedError: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "HdSjWXm4vDGorhvbCzmT8HmKiwHdDtErh15VTLPSWVSZ",
  "block_height": 65039561,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/usr/local/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'UntypedError',
  context: undefined
}
encody commented 2 years ago

@ryancwalsh a certificate with that ID doesn't exist

ryancwalsh commented 2 years ago

@encody You are right; my mistake! I think in my attempt above I must have issued the new cert on testnet. Trying again just now on mainnet and then deleting, everything worked! Thanks!