Search code examples
eos

EOS. Unexpected amount descreasing after generate raw (unsigned) transaction, sign it and broadcast


Account on jungle testnet.

I. Here is attempt to send 95 EOS and also powerup and buy ram while balance is 102 EOS at attempt moment. As result: got error which is about enough amount.

Picture with balance

Transaction content:

{"transaction":{"expiration":"2022-05-16T09:42:23.349+00:00","ref_block_num":140806677,"ref_block_prefix":3316434404,"max_net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"powerup","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio","getData":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getName":"powerup"},{"account":"eosio.token","name":"transfer","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a203256b96a4e6bd6f07e0e000000000004454f530000000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio.token","getData":"10420835aa96949a203256b96a4e6bd6f07e0e000000000004454f530000000000","getName":"transfer"}],"transaction_extensions":[],"signatures":[],"context_free_data":[],"getRefBlockPrefix":3316434404,"getMaxNetUsageWords":0,"getMaxCpuUsageMs":0,"getDelaySec":0,"getContextFreeActions":[],"getActions":[{"account":"eosio","name":"powerup","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio","getData":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getName":"powerup"},{"account":"eosio.token","name":"transfer","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a203256b96a4e6bd6f07e0e000000000004454f530000000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio.token","getData":"10420835aa96949a203256b96a4e6bd6f07e0e000000000004454f530000000000","getName":"transfer"}],"getTransactionExtensions":[],"getExpiration":1652694143349,"getRefBlockNum":140806677},"chainId":"2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840"}

When I tried send, I have got error:

Can't broadcast transaction #hex {"signatures":["SIG_K1_Jw6ws6tJWRpy93ySXzv6B8QTotgLadfoaLULPMrSwG8m4skYCi5nVnMBm1RC6qEmUT2fAWqKka37CALgbYVnzEJpF5hdep"],"compression":"none","packed_context_free_data":"","packed_trx":"7f1c8262158ae4c5acc500000000040000000000ea3055000000a0eaab38ad0210420835aa96949a00000000a8ed323210420835aa96949a00000000a8ed32323410420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f530000000000a6823403ea3055000000572d3ccdcd0210420835aa96949a00000000a8ed323210420835aa96949a00000000a8ed32322110420835aa96949a203256b96a4e6bd6f07e0e000000000004454f5300000000000000000000ea3055000000a0eaab38ad0210420835aa96949a00000000a8ed323210420835aa96949a00000000a8ed32323410420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f530000000000a6823403ea3055000000572d3ccdcd0210420835aa96949a00000000a8ed323210420835aa96949a00000000a8ed32322110420835aa96949a203256b96a4e6bd6f07e0e000000000004454f53000000000000"}. com.unitedtraders.luna.crypto.spi.exception.BlockchainDataProviderException: Cannot send eos transaction. Response: ChainError(code=500, message=Internal Service Error, error=Error(code=3050003, name=eosio_assert_message_exception, what=eosio_assert_message assertion failure, details=[Details(message=assertion failure with message: overdrawn balance, method=eosio_assert), Details(message=pending console output: , method=exec_one)])).

II. Here is attempt to send 30 EOS and also powerup and buy ram while balance is 102 EOS at attempt moment. As result: decreasing amount is about 60 EOS. This attempt is successful.

But balance decreased in unexpected amount:

  • before sending it was 102 EOS
  • after sending it was 41.9996 EOS.

Seems like x2 decreasing (transferring is 30, powerup fee is 0.0002).

Transaction content:

{"transaction":{"expiration":"2022-05-16T11:02:44.414+00:00","ref_block_num":140816318,"ref_block_prefix":1732454216,"max_net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"powerup","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio","getData":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getName":"powerup"},{"account":"eosio.token","name":"transfer","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a203256b96a4e6bd6e09304000000000004454f530000000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio.token","getData":"10420835aa96949a203256b96a4e6bd6e09304000000000004454f530000000000","getName":"transfer"}],"transaction_extensions":[],"signatures":[],"context_free_data":[],"getRefBlockPrefix":1732454216,"getMaxNetUsageWords":0,"getMaxCpuUsageMs":0,"getDelaySec":0,"getContextFreeActions":[],"getActions":[{"account":"eosio","name":"powerup","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio","getData":"10420835aa96949a10420835aa96949a010000005825450000000000267d000000000000102700000000000004454f5300000000","getName":"powerup"},{"account":"eosio.token","name":"transfer","authorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"data":"10420835aa96949a203256b96a4e6bd6e09304000000000004454f530000000000","getAuthorization":[{"actor":"needhelp1111","permission":"active","getActor":"needhelp1111","getPermission":"active"}],"getAccount":"eosio.token","getData":"10420835aa96949a203256b96a4e6bd6e09304000000000004454f530000000000","getName":"transfer"}],"getTransactionExtensions":[],"getExpiration":1652698964414,"getRefBlockNum":140816318},"chainId":"2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840"}

Can anybody explain what's going wrong and why sending amount is 30, but decreasing amount is 60?

Thx in advance)


Solution

  • Problem was in serialization/deserialization part. Used library creates in DTOs separated field with getter naming pattern (for example, there is field 'account' and also there is field 'getAccount' near).

    When raw (unsigned) transaction was serialized, it had created json field also for "getter" field. And when raw transaction was deserialized, jackson library had merged field data and "getter" data, thus there were duplicates.

    You can see duplicates in raw transactions in topic start post ("account" and "getAccount", "data" and "getData", etc.).

    On mainnet this entailed double sending, but on testnet it was just, something like, "double spending and one sending".

    We have used next fix on deserialization step:

        val objectMapper: ObjectMapper = objectMapper
            .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
            .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)