6

With a truffle version of 4.1.0, using truffle debug on a call of my contract function below:

function Deposit (uint256 timeout, bytes32 hash, address recipient)
        public payable returns (uint256)
    {
        require( timeout >= now );
        require( timeout < (now + MAX_TIMEOUT) );
        require( msg.value > 0 );

        var lock_id = m_ctr;
        m_ctr += 1;
        m_locks[lock_id] = LockState(timeout, hash, recipient, msg.sender, msg.value);

        OnDeposit(lock_id, recipient);

        return lock_id;
    }

as (via geth):

Deposit(1521568000, '0xffcec51439a3a7195c8f5c32732bfc2bf66688a13c1d52fc9d5e548f4733b5c1,', "0x0e0060f625534293d280547bd8a782da45333b95", {from: "0x4a7268f1982acd8e405e2d8d26075480e0d6fe8f", gas:900000, value: 1})

the debug console reveals that the second argument hash is null.

5: function Deposit (uint256 timeout, bytes32 hash, address recipient)
6:     public payable returns (uint256)
                                ^^^^^^^ 

debug(testnet1:0x2b899125...)> v

      lock_id: undefined
      timeout: 1521568000
         hash: null
    recipient: '0x0e0060f625534293d280547bd8a782da45333b95'
             : 117
  MAX_TIMEOUT: 0
      m_locks: null
        m_ctr: 0

Considering that there is no such thing as null in Solidity, I am confused at the reported value of the hash argument. More importantly, passing a value for this parameter has resulted in it being reported back as null by truffle debug.

It has received the first argument timeout and third argument recipient correctly as expected so the call itself seems to be well-formed.

Another variable also seems to be reported back as null whilst another is undefined. What are the differences between them and why have they been assigned different 'values'?

Why is my hash argument being interpreted as null when being passed appropriate values?

  • 2
    Did you ever figure this out? I have the same issue; variables that are not null and are in use appear null. – Inn0vative1 Apr 22 '18 at 5:30
  • Unfortunately not. I abandoned the problem... If you ever find anything, please do let me know. – Shiri Apr 23 '18 at 15:28
2

I believe this was a bug before which is fixed now.

Current version i'm using is:

$ truffle version
Truffle v5.0.20 (core: 5.0.20)
Solidity v0.5.0 (solc-js)
Node v10.15.3
Web3.js v1.0.0-beta.37
  1. Simple smart contract to reproduce the issue
pragma solidity ^0.5.6;

contract TruffleDebug {

  function Deposit (uint256 timeout, bytes32 hash, address recipient) public payable returns (uint256)  {
       emit AcceptCommitted(timeout, hash, recipient);
       return 1;
   }

   event AcceptCommitted(uint256 indexed timeout, bytes32 indexed hash, address indexed recipient);

}
  1. Run the transaction
Deposit(1521568000, '0xffcec51439a3a7195c8f5c32732bfc2bf66688a13c1d52fc9d5e548f4733b5c1,', "0x0e0060f625534293d280547bd8a782da45333b95", {from: "0x00cB2D7146Cc41BeACf4f1Ce42F99619A671708E", gas:900000, value: 1})

tx hash: 0x81076d6629f37dd9d3a0e06617968151e68161c48582a4c83273fc15c436c69b
  1. Debug the transaction with Truffle
$ truffle debug 0x81076d6629f37dd9d3a0e06617968151e68161c48582a4c83273fc15c436c69b
Starting Truffle Debugger...
✔ Compiling your contracts...
✔ Gathering information about your project and the transaction...

(...)

6:   function Deposit (uint256 timeout, bytes32 hash, address recipient) public payable returns (uint256)  {
                                                                                                 ^^^^^^^    

debug(development:0x81076d66...)> v

    timeout: 1521568000
       hash: '0xffcec51439a3a7195c8f5c32732bfc2bf66688a13c1d52fc9d5e548f4733b5c1'
  recipient: '0x0e0060f625534293d280547bd8A782DA45333b95'
        msg: { data:
                '0x03de16ab000000000000000000000000000000000000000000000000000000005ab14900ffcec51439a3a7195c8f5c32732bfc2bf66688a13c1d52fc9d5e548f4733b5c10000000000000000000000000e0060f625534293d280547bd8a782da45333b95',
               sig: '0x03de16ab',
               sender:
                '0x00cB2D7146Cc41BeACf4f1Ce42F99619A671708E',
               value: 1 }
         tx: { origin:
                '0x00cB2D7146Cc41BeACf4f1Ce42F99619A671708E',
               gasprice: 20000000000 }
      block: { coinbase:
                '0x0000000000000000000000000000000000000000',
               difficulty: 0,
               gaslimit: 6721975,
               number: 41,
               timestamp: 1560166415 }
       this: 'TruffleDebug(0xae5986Fe6A1639e44A1Dd835A1B42c39D0343f42)'
        now: 1560166415

debug(development:0x81076d66...)> 

As expected, Truffle debug correctly finds the function arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.