Creation of ContractTx (Java-SDK)

Ok so as above mentioned the API says Bad Request with Reason invalid Tx and when we check the logs of the node we get a signature_check_failed

node_1      | 16:24:44.221 [info] Failed signature check on tx: {error,signature_check_failed}, <<91,163,4,185,255,160,75,16,65,201,152,243,191,221,168,76,229,0,180,127,106,70,230,194,114,14,80,85,53,211,129,111>>

we think the network_id cannot be the reason. maybe we are handling the RLP-array wrong? this is being built like this:

@Override
	protected Bytes createRLPEncodedList() {
		Bytes encodedRlp = RLP.encodeList(rlpWriter -> {
			rlpWriter.writeInt(SerializationTags.OBJECT_TAG_CONTRACT_CREATE_TRANSACTION);
			rlpWriter.writeInt(SerializationTags.VSN);
			byte[] ownerWithTag = EncodingUtils.decodeCheckAndTag(this.ownerId, SerializationTags.ID_TAG_ACCOUNT);
			rlpWriter.writeByteArray(ownerWithTag);
			rlpWriter.writeBigInteger(this.nonce);
            rlpWriter.writeByteArray(EncodingUtils.decodeCheckWithIdentifier(this.contractByteCode));
			rlpWriter.writeBigInteger(calculateVersion()); // abi + vm
			rlpWriter.writeBigInteger(this.fee);
			rlpWriter.writeBigInteger(this.ttl);
			rlpWriter.writeBigInteger(this.deposit);
			rlpWriter.writeBigInteger(this.amount);
			rlpWriter.writeBigInteger(this.gas);
			rlpWriter.writeBigInteger(this.gasPrice);
			rlpWriter.writeByteArray(EncodingUtils.decodeCheckWithIdentifier(this.callData));
		});
		return encodedRlp;
	}

I’m just using the plain Erlang-functions in an Erlang shell. This is very similar to what the node does, so it isn’t very surprising that the node comes to the same conclusion {error,signature_check_failed}

I can’t see anything obviously wrong in the RLP code or in signTransaction - what I can provide is the correct serialization of the unsigned transaction, i.e. binaryTx in signTransaction.

For the first transaction (ae_devnet) -

[249,4,155,42,1,161,1,117,238,152,37,173,99,9,99,72,43,
  177,147,154,33,42,14,83,88,131,198,180,215,128,78,64,40,
  126,31,85,109,162,114,1,185,3,248,249,3,245,70,2,160,
  165,90,181,33,189,171,218,232,62,82,75,71,189,245,146,
  67,195,247,228,114,80,28,206,170,138,74,129,187,80,240,
  130,212,249,2,251,249,1,42,160,104,242,103,99,56,255,80,
  136,57,171,164,119,73,239,250,139,232,126,242,132,242,7,
  251,61,153,152,112,28,213,56,135,197,132,109,97,105,110,
  184,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,184,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,249,1,203,160,
  185,201,86,242,139,49,73,169,245,152,122,165,5,243,218,
  27,34,9,204,87,57,35,64,6,43,182,193,189,159,159,153,
  234,132,105,110,105,116,184,96,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,185,1,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,184,204,98,0,0,100,98,0,0,132,145,128,
  128,128,81,127,185,201,86,242,139,49,73,169,245,152,122,
  165,5,243,218,27,34,9,204,87,57,35,64,6,43,182,193,189, 
  159,159,153,234,20,98,0,0,192,87,80,128,81,127,104,242,
  103,99,56,255,80,136,57,171,164,119,73,239,250,139,232,
  126,242,132,242,7,251,61,153,152,112,28,213,56,135,197,
  20,98,0,0,175,87,80,96,1,25,81,0,91,96,0,25,89,96,32,1,
  144,129,82,96,32,144,3,96,3,129,82,144,89,96,0,81,89,82,
  96,0,82,96,0,243,91,96,0,128,82,96,0,243,91,89,89,96,32,
  1,144,129,82,96,32,144,3,96,0,25,89,96,32,1,144,129,82,
  96,32,144,3,96,3,129,82,129,82,144,86,91,96,32,1,81,81,
  89,80,128,145,80,80,128,144,80,144,86,91,80,80,130,145,
  80,80,98,0,0,140,86,133,51,46,48,46,48,131,4,0,1,135,3,
  231,57,183,7,104,0,130,78,32,0,0,130,3,232,132,65,144,
  171,0,184,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,32,185,201,86,242,139,49,73,169,245,
  152,122,165,5,243,218,27,34,9,204,87,57,35,64,6,43,182,
  193,189,159,159,153,234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

And for the testnet transaction -

[249,4,156,42,1,161,1,11,180,237,121,39,249,123,81,225,
  188,181,225,52,13,18,51,91,42,43,18,200,188,82,33,214,
  60,75,203,57,212,30,97,130,50,130,185,3,248,249,3,245,
  70,2,160,120,221,57,250,210,92,118,162,173,175,58,106, 
  41,161,159,237,238,240,73,205,192,69,159,225,53,40,30,
  184,119,40,92,185,249,2,251,249,1,42,160,104,242,103,99,
  56,255,80,136,57,171,164,119,73,239,250,139,232,126,242,
  132,242,7,251,61,153,152,112,28,213,56,135,197,132,109,
  97,105,110,184,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  160,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,64,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  249,1,203,160,185,201,86,242,139,49,73,169,245,152,122,
  165,5,243,218,27,34,9,204,87,57,35,64,6,43,182,193,189,
  159,159,153,234,132,105,110,105,116,184,96,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,3,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,185,1,64,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,3,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,184,204,98,0,0,100,98,0,0,
  132,145,128,128,128,81,127,185,201,86,242,139,49,73,169,
  245,152,122,165,5,243,218,27,34,9,204,87,57,35,64,6,43,
  182,193,189,159,159,153,234,20,98,0,0,192,87,80,128,81,
  127,104,242,103,99,56,255,80,136,57,171,164,119,73,239,
  250,139,232,126,242,132,242,7,251,61,153,152,112,28,213,
  56,135,197,20,98,0,0,175,87,80,96,1,25,81,0,91,96,0,25,
  89,96,32,1,144,129,82,96,32,144,3,96,3,129,82,144,89,96,
  0,81,89,82,96,0,82,96,0,243,91,96,0,128,82,96,0,243,91,
  89,89,96,32,1,144,129,82,96,32,144,3,96,0,25,89,96,32,1,
  144,129,82,96,32,144,3,96,3,129,82,129,82,144,86,91,96,
  32,1,81,81,89,80,128,145,80,80,128,144,80,144,86,91,80,
  80,130,145,80,80,98,0,0,140,86,133,50,46,49,46,48,131,4,
  0,1,135,3,231,57,183,7,104,0,0,0,0,131,15,66,64,132,59,
  154,202,0,184,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,32,185,201,86,242,139,49,73,169,
  245,152,122,165,5,243,218,27,34,9,204,87,57,35,64,6,43,
  182,193,189,159,159,153,234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
2 Likes

we will check whether the UnsignedTx is being serialized correctly. thanks!

1 Like

Thanks @hanssv.chain - after decoding your binary tx we found the issue - we’ve written deposit and amount as integer instead of byte in our RLP array. After changing this in our RLP array generation we’re finally able to deploy a contract tx. Many thanks :smiley:

1 Like

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.chain 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 incubator-tuweni/RLP.java at main · apache/incubator-tuweni · GitHub

Cheers!

2 Likes

thank you very much for your response!

@hanssv.chain 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?

we need info here to finish the contract-feature in our SDK. can anyone of the team help out? :slight_smile:

The dry-run endpoint takes a list of transactions to be performed in sequence on top of top (top is optional and if left out it will default to current top of chain). top can be either a key-block hash or a micro-block hash - the hash should be properly encoded (kh_... or mh_...)

The gasPrice is not very interesting for a dry-run (but for the sake of simplicity the dry-run endpoint takes full transactions including this parameter). It must be larger than minimum gasPrice under consensus (1M) or else the transaction is invalid and won’t be accepted even by for dry-run :slight_smile:

As for the response, you don’t need to use it at all, so it is a strange question. But in general there are two interesting bits of information in the resulting call object - the result of the call (i.e. the result of calling the function in the contract), and the gas used by the call. There is no need to multiply anything, the gas used is the gas used.

Lastly, I am not familiar with how the aeternity nodes are setup, sorry.

1 Like

ok thank you for the detailed explanation :slight_smile: I think now we got everything to finish the feature.

@hanssv.chain unfortunately we have 1 last topic here. it is still regarding the gas that is being used for the ContractCallTx.

we perform a dryRun against the debug api and get as answer the returnType ok the response object includes the values:

  • gasUsed = 192
  • gasPrice = 1000000000

we take exactly these values and create our “real” transaction. when we try to publish it we always encounter an error and the transaction is rejected.

if we increase the gas we are able to create a valid ContractCallTx. as you mentioned above we should be able to use exactly these values that are being returned from the dryRun.

any idea why this is not working?

The gas used “dry-running” the transaction should be the same as the gas used for the real transaction. (Unless there is something in the contract that depends on the chain, and there is a change between the dry-run and the actual execution.)

Why is the transaction rejected, what is the error message?

Hi @hanssv.chain,
if we use exactly the “gas used” value of the dry run (192) the locale node logs the following error
“[error] CRASH REPORT Process <0.25103.7> with 0 neighbours crashed with reason: {illegal_field,gas,int,<<0,192>>,int,<<0,192>>} in aeserialization:decode_fields/2 line 91”

I’m wondering why “illegal_field” occurs… any ideas?

Thanks and greets,
Mitch