Creation of ContractTx (Java-SDK)

so now we can create a valid CreateContractTx but for some reason the transaction doesn’t get mined. what could be the reason for that, any suggestions?

the tx-hash looks like that:

tx_+QToCwH4QrhAiDOY3A3vsLRWCyf9zcVPVbvZvPcgih4aZsUCFGic6+hgYpSKl3pPUq+TKbPR/kuStYHkZJqEWD225zzmYHOyCrkEn/kEnCoBoQF17pglrWMJY0grsZOaISoOU1iDxrTXgE5AKH4fVW2icgO5A/j5A/VGAqClWrUhvava6D5SS0e99ZJDw/fkclAczqqKSoG7UPCC1PkC+/kBKqBo8mdjOP9QiDmrpHdJ7/qL6H7yhPIH+z2ZmHAc1TiHxYRtYWluuMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD5AcuguclW8osxSan1mHqlBfPaGyIJzFc5I0AGK7bBvZ+fmeqEaW5pdLhgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///////////////////////////////////////////uQFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQD//////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////////////////////////////////+4zGIAAGRiAACEkYCAgFF/uclW8osxSan1mHqlBfPaGyIJzFc5I0AGK7bBvZ+fmeoUYgAAwFdQgFF/aPJnYzj/UIg5q6R3Se/6i+h+8oTyB/s9mZhwHNU4h8UUYgAAr1dQYAEZUQBbYAAZWWAgAZCBUmAgkANgA4FSkFlgAFFZUmAAUmAA81tgAIBSYADzW1lZYCABkIFSYCCQA2AAGVlgIAGQgVJgIJADYAOBUoFSkFZbYCABUVFZUICRUFCAkFCQVltQUIKRUFBiAACMVoUzLjAuMIMEAAGGWqiO/cAAhDuaygAAAIID6IQ7msoAuGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAILnJVvKLMUmp9Zh6pQXz2hsiCcxXOSNABiu2wb2fn5nqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACHZkck

@noandrea @hanssv do you have any ideas?

also two other questions:

  • how are or should the parameters gas and gasPrice be estimated and defined?
  • do or should they have any influence on the fee that is used?

edit:

  • also I faced this strange signature_check_failed error when I set TTL to zero. I always thought the tx will not expire when setting the TTL to zero. when providing a “valid” value for TTL the transaction gets accepted by the node without this signature_check_failed

Firstly, gasPrice is the price you pay for each gas. There is no estimate involved. The protocol defines 1M (1000000) to be the minimum gasPrice. Also the miners can demand a (higher!) minimum gasPrice, the default is 1G (1000000000).

The gas can be estimated by dry-running the call (or by program analysis or some other mechanism), this is the maximum amount of gas you are willing to pay. It should be enough to cover the execution (unless you want it to fail with an out of gas :slight_smile: )

Yes, a TTL value 0 means a transaction that is valid “forever”. It should not be a problem to use this in a transaction AFAIK. Perhaps there is an issue with the RLP encoding of 0? I have a vague memory of someone having issues with different encodings of 0 in some RLP-implementation… :thinking:

and this is totally independent from the “regular” fee of the transaction, right? or must that somehow be included in the fee calculation?

this is a good point. I will contact the developer of the library we are using for RLP encoding :smiley:

Yes, the fee is completely independent - the fee covers the base cost of the transaction (size of Tx, and startup cost for VM, etc) and the gas ( x gasPrice) covers the execution…

1 Like

hey folks, I am the maintainer of the lib you’re using for RLP encoding/decoding.
The tx signing of RLP bytes is well tested under the transaction tests of Ethereum, we use those to test the behaviors. Some of those tests are enforcing interesting behaviors such as representing zero with additional zero bytes.
To make sure we validate those transactions, we use a strict mode in our RLP reader which will report issues in superfluous zero bytes are reported.
We don’t use bigInteger to represent balance or gas prices in our transaction code. We use UInt256 so we can have safety.

The problem seems to arise specifically in the way we serialize one vs the other:
For a UInt256, we serialize with writeValue(value.toMinimalBytes());

For a BigInteger, we serialize with writeByteArray(byteArray);

So it looks like you may get additional zero bytes in there.

Hopefully this gives you a few ways to work around the issue. If you have time for a patch, the code is now at https://github.com/apache/incubator-tuweni/blob/master/rlp/src/main/java/org/apache/tuweni/rlp/RLP.java

Cheers!

2 Likes

thank you very much for your response!

@hanssv we have definitely an issue with the RLP encoding regarding BigInteger.ZERO which leads to the signature_check_failed error. but this only occurs when we have included a value with BigInteger.ZERO. when we fill the params with >0 the node seems to accept our transaction (as already mentioned above).

still there seems to be another issue (IMO). our nodes do not mine the ContractCreateTx. after submitting the transactions to the network and calling http://localhost/v2/transactions/th_q1YMnUXNMx9GmvQb1pWXXUtyDNpCMBAFaRS8duU8FRCkQ6MLT to see it I get the following response:

{"block_hash":"none","block_height":-1,"hash":"th_q1YMnUXNMx9GmvQb1pWXXUtyDNpCMBAFaRS8duU8FRCkQ6MLT","signatures":["sg_KNHt1S8FiViRguaY7HcBBFawvNivq1LsMnQGP3PCaeL1bZUQvGYU2zeEke1tdPd8icF5m6ozZn8H4hi7am4eeeQX4oCFg"],"tx":{"abi_version":"0x0001","amount":100,"call_data":"cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACC5yVbyizFJqfWYeqUF89obIgnMVzkjQAYrtsG9n5+Z6gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnHQYrA==","code":"cb_+QP1RgKgpVq1Ib2r2ug+UktHvfWSQ8P35HJQHM6qikqBu1DwgtT5Avv5ASqgaPJnYzj/UIg5q6R3Se/6i+h+8oTyB/s9mZhwHNU4h8WEbWFpbrjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKD//////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAuEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+QHLoLnJVvKLMUmp9Zh6pQXz2hsiCcxXOSNABiu2wb2fn5nqhGluaXS4YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////////////////////////7kBQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA//////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///////////////////////////////////////////uMxiAABkYgAAhJGAgIBRf7nJVvKLMUmp9Zh6pQXz2hsiCcxXOSNABiu2wb2fn5nqFGIAAMBXUIBRf2jyZ2M4/1CIOaukd0nv+ovofvKE8gf7PZmYcBzVOIfFFGIAAK9XUGABGVEAW2AAGVlgIAGQgVJgIJADYAOBUpBZYABRWVJgAFJgAPNbYACAUmAA81tZWWAgAZCBUmAgkANgABlZYCABkIFSYCCQA2ADgVKBUpBWW2AgAVFRWVCAkVBQgJBQkFZbUFCCkVBQYgAAjFaFMy4wLjDZUhWH","deposit":100,"fee":1098660000000000,"gas":1000000,"gas_price":2000000000,"nonce":9,"owner_id":"ak_twR4h7dEcUtc2iSEDv8kB7UFJJDGiEDQCXr85C3fYF8FdVdyo","ttl":20000,"type":"ContractCreateTx","version":1,"vm_version":"0x0004"}}

do you see any reason why this transaction doesn’t get mined on our local nodes???

the tx looks as follows and is (according to goggles) valid:

tx_+QToCwH4QrhAjGP9296exlthMHfui9t3pGSQEH4lSBvsSnv2/i4TSrupdy7leFV1QlQd/FWoOseYckyxWO+Lig16uk8PECGCBrkEn/kEnCoBoQF17pglrWMJY0grsZOaISoOU1iDxrTXgE5AKH4fVW2icgm5A/j5A/VGAqClWrUhvava6D5SS0e99ZJDw/fkclAczqqKSoG7UPCC1PkC+/kBKqBo8mdjOP9QiDmrpHdJ7/qL6H7yhPIH+z2ZmHAc1TiHxYRtYWluuMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD5AcuguclW8osxSan1mHqlBfPaGyIJzFc5I0AGK7bBvZ+fmeqEaW5pdLhgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///////////////////////////////////////////uQFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQD//////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////////////////////////////////+4zGIAAGRiAACEkYCAgFF/uclW8osxSan1mHqlBfPaGyIJzFc5I0AGK7bBvZ+fmeoUYgAAwFdQgFF/aPJnYzj/UIg5q6R3Se/6i+h+8oTyB/s9mZhwHNU4h8UUYgAAr1dQYAEZUQBbYAAZWWAgAZCBUmAgkANgA4FSkFlgAFFZUmAAUmAA81tgAIBSYADzW1lZYCABkIFSYCCQA2AAGVlgIAGQgVJgIJADYAOBUoFSkFZbYCABUVFZUICRUFCAkFCQVltQUIKRUFBiAACMVoUzLjAuMIMEAAGHA+c5twdoAIJOIGRkgw9CQIR3NZQAuGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAILnJVvKLMUmp9Zh6pQXz2hsiCcxXOSNABiu2wb2fn5nqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACne71A

No, I don’t see anything that is obviously wrong, but it all depends on the local node you are talking to, it could be that the nonce is wrong, or that this local network is not yet at fortuna height, etc. Regardless it should be visible in the logs (why the transaction can’t be applied), you need debug loglevel for this.

logging:
  level: debug

in your .yaml configuration.

1 Like

We finally got it working and are currently working on dryRun for ContractCallTx in our java-sdk and still don’t understand how to use it or if we are doing something wrong.

We create a ContractCallTx and then call the debug endpoint, correct?

  • what do we have to specify as gas and gasPrice?
  • what data of the response do we need to use?

As we analyzed it for now, we need to take the gas from the answer and multiple it with 1,3333. I guess this isn’t the way to go?!

And what must be specified for the “top”-param if we want to execute the dryRun at a certain block height? The encoded hash from the keyblock or something else?

And just for the record:

  • do the official aeternity nodes have debug-mode enabled so that the dryRun can be performed there?
  • if not -> is there an alternative how to calculate gas and gasPrice correctly?