hyperledger-labs / weaver-dlt-interoperability

A platform, a protocol suite, and a set of tools, to enable interoperation for data sharing and asset movements between independent networks built on heterogeneous blockchain, or more generally, distributed ledger, technologies, in a manner that preserves the core blockchain tenets of decentralization and security.
Apache License 2.0
55 stars 45 forks source link

Panic: Arithmetic overflow on claiming tokens using AssetExchangeContract #385

Closed anjalisn4 closed 1 year ago

anjalisn4 commented 1 year ago

I am following the simple asset from samples for besu.After network setup and contract deployments, on running node app/AssetExchangeERC20.js, I am getting this error

'Error: Returned error: VM Exception while processing transaction: revert -- Reason given: Panic: Arithmetic overflow.\n'

Detailed error logs

➜  simpleasset git:(main) ✗ node app/AssetExchangeERC20.js
Alice address in Network 1 0x021FA2b81c3D08234B23D481D9f465ff1214762c
Bob address in Network 1 0x0f17A459b2483212AcbE810F9bD4a17381E18F5C
Alice address in Network 2 0xFd83C1e4a4171FBf97CF69AfAC3E0478bB1843DE
Bob address in Network 2 0x1C960AEb3CE1274E076abcfC9f5FFe43884176A5

 Balances after init():
Alice balance of AliceERC20 in Network 1 3
Bob balance of AliceERC20 in Network 1 0
Alice balance of BobERC20 in Network 2 0
Bob balance of BobERC20 in Network 2 50
Hash:  <Buffer 05 90 ad e2 e7 b6 34 75 7e 1d 22 15 15 87 de 10 92 f4 cd e1 aa 38 96 77 8b 80 e2 7a fb bf f1 6f>

 Balances after Alice locks her tokens in Network 1:
Alice balance of AliceERC20 in Network 1 2
Bob balance of AliceERC20 in Network 1 0
Alice balance of BobERC20 in Network 2 0
Bob balance of BobERC20 in Network 2 50

 Balances after creating Bob locks his tokens in Network 2:
Alice balance of AliceERC20 in Network 1 2
Bob balance of AliceERC20 in Network 1 0
Alice balance of BobERC20 in Network 2 0
Bob balance of BobERC20 in Network 2 40

 Claiming 0x56d1d5f14cc53f2e1f62aee8c7e2990efe45e844b2c03b5cf6317a9b13d5e83d using preimage: <Buffer 8b 73 d6 07 a8 bc 2b e4 90 b2 9e cd ee 6d db b4 46 01 ea e1 f8 32 66 f5 af 22 7d b8 8d 4c 0c c6>
Error: Returned error: VM Exception while processing transaction: revert -- Reason given: Panic: Arithmetic overflow.
    at claimToken (/home/anjalisn4/Anjali/learning/weaver-dlt-interoperability/samples/besu/simpleasset/app/AssetExchangeERC20.js:108:6)
    at main (/home/anjalisn4/Anjali/learning/weaver-dlt-interoperability/samples/besu/simpleasset/app/AssetExchangeERC20.js:318:29)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  data: {
    hash: null,
    programCounter: 7437,
    result: '0x4e487b710000000000000000000000000000000000000000000000000000000000000011',
    reason: null,
    message: 'revert'
  },
  reason: 'Panic: Arithmetic overflow',
  hijackedStack: 'Error: Returned error: VM Exception while processing transaction: revert -- Reason given: Panic: Arithmetic overflow.\n' +
    '    at Object.ErrorResponse (/home/anjalisn4/Anjali/learning/weaver-dlt-interoperability/samples/besu/simpleasset/node_modules/web3-core-helpers/lib/errors.js:28:19)\n' +
    '    at /home/anjalisn4/Anjali/learning/weaver-dlt-interoperability/samples/besu/simpleasset/node_modules/web3-core-requestmanager/lib/index.js:300:36\n' +
    '    at /home/anjalisn4/Anjali/learning/weaver-dlt-interoperability/samples/besu/simpleasset/node_modules/web3-providers-http/lib/index.js:127:13\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:96:5)'
}
claimAsset threw an error

 Balances after Alice's attempt to claim in Network 2:
Alice balance of AliceERC20 in Network 1 2
Bob balance of AliceERC20 in Network 1 0
Alice balance of BobERC20 in Network 2 0
Bob balance of BobERC20 in Network 2 40

 !!! Claim by Alice not successfull !!! 
 Unlocking and refunding tokens to Alice and Bob
unlockAsset threw an error
unlockAsset threw an error

 !!! Unlocking Bob's tokens not successfull !!!

 !!! Unlocking Alice's tokens not successfull !!!

 Balances after Bob's attempt to claim in Network 1:
Alice balance of AliceERC20 in Network 1 2
Bob balance of AliceERC20 in Network 1 0
Alice balance of BobERC20 in Network 2 0
Bob balance of BobERC20 in Network 2 40
VRamakrishna commented 1 year ago

Did you run the instructions in the right sequence? And did all commands prior to this claim command succeed?

sandeepnRES commented 1 year ago

Hi @anjalisn4, I'd suggest to not use app/AssetExchangeERC20.js for testing, instead I'd suggest to use besu-cli to test the asset exchange whose instructions are available in our documentation: https://labs.hyperledger.org/weaver-dlt-interoperability/docs/external/getting-started/guide

sandeepnRES commented 1 year ago

Closing this, as didn't receive any response, hence assuming it is resolved.