When Rosetta CLI assign signature to transaction?

Hi @patrick.ogrady,
I wonder when the signature is assigned to a transaction ?

when I run construction check, I see the flow as below:

At ConstructionParse , I haven’t seen the signature assigned to transactions yet
So, the Transaction.From is still empty
That’s the reason Rossetta CLI throw an error to me said that sender not match (because from in my tx is empty)

My transaction detail at the beginning of ConstructionParse

ENDPOINT: ConstructionPayloads metadata 0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037
2020/11/06 15:07:45 POST /network/status 994.954988ms

	TX(acfd8c9bcbbf5083a648302ae1537d5773543dc3076926506c53fe643e33af50)
	Contract: false
	From:     [invalid sender: invalid sig]
	To:       3e2ead41200c971a3904438e1820fe4e6d7fb7f6
	Nonce:    271
	GasPrice: 0xee6b280
	GasLimit  0x989680
	Value:    0x401373fe525a6d19a1b8e8000
	Data:     0x
	V:        0x0
	R:        0x0
	S:        0x0
	Hex:      f382010f840ee6b28083989680943e2ead41200c971a3904438e1820fe4e6d7fb7f68d0401373fe525a6d19a1b8e800080808080

Rosetta CLI log: (account.sender is not match 0x000 (cannot derive sender without signature) vs 0x17..)

expected 

[{"operation_identifier":{"index":0},"type":"transfer","status":"","account":{"address":"0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037"},"amount":{"value":"-317288927723063409071492758742","currency":{"symbol":"TOMO","decimals":18}}},{"operation_identifier":{"index":1},"type":"transfer","status":"","account":{"address":"0x3e2ead41200C971a3904438e1820FE4E6D7fB7f6"},"amount":{"value":"317288927723063409071492758742","currency":{"symbol":"TOMO","decimals":18}}}], 

observed 

[{"operation_identifier":{"index":0},"type":"transfer","status":"","account":{"address":"0x0000000000000000000000000000000000000000"},"amount":{"value":"-317288927723063400000000000000","currency":{"symbol":"TOMO","decimals":18}}},{"operation_identifier":{"index":1},"related_operations":[{"index":0}],"type":"transfer","status":"","account":{"address":"0x3e2ead41200C971a3904438e1820FE4E6D7fB7f6"},"amount":{"value":"317288927723063400000000000000","currency":{"symbol":"TOMO","decimals":18}}}]

Error: could not intent match [0 1]: unsigned parsed ops do not match intent: unable to create transaction


Could you please give me an advice on this situation ?

Thank you so much !

If you’ve made it this far, you’re probably very close to completion! :rocket:

Ahhh, this is a pitfall a few teams have encountered while working on their implementations. If the only way to extract the from address for a transaction is to parse the signature (which is not accessible until /construction/combine), you may need to store some metadata in the unsigned transaction object being passed between endpoint invocations (the response from /construction/payloads). In rosetta-ethereum, we keep quite a few things in the unsigned_transaction object to ensure we construct the transaction correctly and that we can parse the transaction from address before signing:

@juliankoh and I wrote a little about this here:

Hi @patrick.ogrady , thank you for your tip .
After running construction check, the transaction has been created and broadcast to the network. I can see the transaction success in explorer.
But in Rosetta CLI I got this error


[MEMORY] Heap: 1108.225525MB Stack: 0.750000MB System: 1260.569473MB GCs: 4
[STATS] Transactions Confirmed: 0 (Created: 1, In Progress: 1, Stale: 0, Failed: 0) Addresses Created: 1
2020/11/11 15:06:04 Syncing 94946
2020/11/11 15:06:06 Syncing 94947
2020/11/11 15:06:07 check:construction status server shutting down
[MEMORY] Heap: 1108.772339MB Stack: 0.687500MB System: 1260.819473MB GCs: 4



Error: unable to process blocks: 

unable to process block: 

unable to handle block: 

unable to handle confirmed transaction 0xe24e2d2b84803b88acd31c84e24734950fe47c66f28581b9b86560610dbae3c2: 

could not intent match [0]: confirmed transaction did not match intent: unable to add block to storage 0xd657e73d70bb7a02a4c5cd5d089932e7a75fac56e0a2e0d55d45be8218b878a3:94947:

 unable to sync to 94947

94947 is the block include the transaction which CLI just created and broadcasted
Can you help to explain this error ?

So, good news! This means that the tx landed on-chain and that rosetta-cli was able to recognize it as the transactions it broadcasted (i.e. the tx hash is correct). :rocket:

This error is raised when the Transaction.Operations that appear on-chain (not including Operation.Status) are not a superset of the Operations returned in /construction/parse. TL;DR the operations we saw on-chain don’t look like the ones we saw in /construction/parse.

I can help you debug this if you paste the operations in the on-chain transaction (retrieved using /block) and the operations from /construction/parse).

Hi @patrick.ogrady,

This is operations of that on-chain transaction getting from /block enpoint

                "operations": [
                    {
                        "operation_identifier": {
                            "index": 0
                        },
                        "type": "transfer",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037"
                        },
                        "amount": {
                            "value": "-41076962765819738439467936932",
                            "currency": {
                                "symbol": "TOMO",
                                "decimals": 18
                            }
                        },
                        "metadata": {
                            "new_balance": "-41076962765819738439467936932"
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 1
                        },
                        "related_operations": [
                            {
                                "index": 0
                            }
                        ],
                        "type": "gas_fee",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0xCc53324BE54915f32521aBB5A3648bF811AbBC8A"
                        },
                        "amount": {
                            "value": "5250000000000",
                            "currency": {
                                "symbol": "TOMO",
                                "decimals": 18
                            }
                        },
                        "metadata": {
                            "new_balance": "1000000000206979539413854077500"
                        }
                    },
                    {
                        "operation_identifier": {
                            "index": 2
                        },
                        "related_operations": [
                            {
                                "index": 0
                            }
                        ],
                        "type": "transfer",
                        "status": "SUCCESS",
                        "account": {
                            "address": "0x0367Ab8Dea9E32F94BAD4eAbd0209f363814c8Ab"
                        },
                        "amount": {
                            "value": "41076962765819733189467936932",
                            "currency": {
                                "symbol": "TOMO",
                                "decimals": 18
                            }
                        },
                        "metadata": {
                            "new_balance": "41076962765819733189467936932"
                        }
                    }
                ]

Operations from /construction/parse

[
{
"operation_identifier":{
"index":0
},
"type":"transfer",
"status":"",
"account":{
"address":"0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037"
},
"amount":{
"value":"-41076962765819733189467936932",
"currency":{
"symbol":"TOMO",
"decimals":18
}
}
},
{
"operation_identifier":{
"index":1
},
"related_operations":[
{
"index":0
}
],
"type":"transfer",
"status":"",
"account":{
"address":"0x0367Ab8Dea9E32F94BAD4eAbd0209f363814c8Ab"
},
"amount":{
"value":"41076962765819733189467936932",
"currency":{
"symbol":"TOMO",
"decimals":18
}
}
}
]

yea, I see 2 differences here

1.  status is empty (in construction/parse) comparing to 'SUCCESS' from on-chain transaction

2.  my on-chain transaction have 3 operations: include 'gas_fee' as well . Should I  add 'gas_fee'  operation to 'construction/parse' ?
 ( Note: At this point, I don't know how much gas used for this transaction so It's difficult to have 'gas_fee' operation here)

So this is a sneaky one! The Operation.Amount.Value in your first operation is different between the intent and what ends up on-chain:

on-chain value: -41076962765819738439467936932
parse value: -41076962765819733189467936932
difference (`on-chain - parse`): 5250000000000

It looks like the on-chain value includes the fee paid whereas the parsed value does not. I’d recommend breaking out the fee payment into its own operation instead of changing the value sent by 0x17F2beD710ba50Ed27aEa52fc4bD7Bda5ED4a037!

If you are curious, this is the matching logic to confirm intent on-chain (note how we don’t care about operation index or the inclusion of extra ops, however, all ops provided during intent must appear):

awesome, thank you so much
it works well

another small issue.
Rosseta CLI make transaction with very large amount. Sometimes, it tell me insufficient fund :slight_smile: .

How can I configure transaction amount (or maximum amount) for each testing transaction ?

Ah, I think I need to update *.ros file .

    // Set the recipient_amount as some value <= sender.balance-max_fee
    max_fee = "84000000000000";
    available_amount = {{sender.balance.value}} - {{max_fee}};

I would like to send maximum 1/1000 balance.

available_amount = {{sender.balance.value}} / 1000  - {{max_fee}};

Not sure what is the correct syntax
I’m not familiar with ros file syntax

:rocket: :rocket:

The best way to account for this “insufficient funds” problem due to fee payment is to reduce the “sendable balance” by some max fee amount (it looks like you found reference to this in your other message).

If this seems a little too “coarse”, you can do a transaction construction “dry run” and adjust the fee based on what is suggested by the /construction/metadata endpoint. We do this for rosetta-bitcoin:

Unfortunately, we don’t support division or some %amount function in the DSL. However, I think it is a great idea! You should create an issue describing what you’d like to see!

You can find info about the existing supported “functions” here:

ok, thank you so much for your support

I’ll comment on this thread once we’ve added support!