ProposalResponsePayloads do not match - ERC-1155 Chaincode / fabric-samples - hyperledger-fabric

I follow ERC-1155 chaincode example for Fabric. When I run the BatchTransferFrom part. It sometimes gives error and sometimes runs successfully. I cannot understand why it fails sometimes. Is this error normal when invoking chaincode functions on Fabric?
The error is:
Error: could not assemble transaction: ProposalResponsePayloads do not match - proposal response: version:1 response:<status:200 > payload: ...
When I call the command using Fabric Node SDK API, it gives the following error:
2021-08-30T09:59:41.794Z - error: [DiscoveryHandler]: compareProposalResponseResults[undefined] - read/writes result sets do not match index=1
2021-08-30T09:59:41.794Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
peer=undefined, status=grpc, message=Peer endorsements do not match

When you perform a transaction, all the responses from different endorsements in the transaction must match.
For any reason, this is not happening with your proposals. Different peers return different responses.
I don't know about that specific chaincode, but common causes are:
Using pseudo-random values.
Using current timestamps instead of the ones from transaction or block.
Serializing a JSON in an undeterministic way, so that it results in different strings, as elements have been serialized in different order.
Etc.

I found the cause of the problem. Iterating maps in Go is not deterministic and the function BatchTransferFrom uses maps. The map is iterated in different orders in different peers and as a result, this causes the proposals to be different.

Related

How to create custom retry logic for aiobotocore?

I'm trying to upload a lot of files to S3. This cannot be done with the standard AWS CLI because of the translation required between file names on disk and object names in S3. Indeed may of the objects don't exist at all on disk.
I keep getting an error:
botocore.exceptions.ClientError: An error occurred (SlowDown) when calling the PutObject operation (reached max retries: 0): Please reduce your request rate
It doesn't seem to make a difference wether I use boto3 / botocore / aioboto3 / aiobotocore. I've tried various configurations of retry logic as described here. Nothing seems to fix the problem. That includes all three retry modes and retry counts ranging everything from 0 to 50.
I could add custom retry logic to every method that calls the client but that's going to be a lot of work and feels like the wrong approach.
Is it possible to customize the retry logic used by boto3 or aiobotocore?

Given transaction number 5 does not match any in-progress transactions. The active transaction number is 4

What is that mean ? What the reason of this issue ? How to fix it ?
I'm facing with this issue: Given transaction number 5 does not match any in-progress transactions. The active transaction number is 4 if use session of Mongo
Mongo Driver: Mongoose
I'm find out on google and someone tell it happen cause multiple session update on same record. But I always await session.commitTransaction() to make sure session is commit success before run next session.
Please explain Why this issue happen ?
and How to fix it ? I don't want use withTransaction() because some processes I need to check, if it's fail I have to abort transaction.

Estimate tx size

I need to know transaction size to calculate fee user is going to spend by sending BTC. I use bitcoind wallet with many accounts and use sendtoaddress call to send BTC. Is there any way to know how many outputs bitcoind will use to create transaction? Or maybe other way to know transaction size before bitcoind executes it...
In this case you need to create the transaction by yourself
Is there any way to know how many outputs bitcoind will use to create transaction?
The outputs are defined by you, I guess, what you are looking for here are the inputs (UTXOs), for sample sendtoaddress is defined to create a transaction with one output, while sendmany will create a transaction with multiple outputs as you provide in the parameters.
Using RPC, you can skip the input selection by doing as the following example:
// creates a rawtransaction with no inputs
bitcoin-cli createrawtransaction "[]" "{\"btc01...receiveraddress\":0.01}"
// fund the transaction with the missing inputs and calculate the fee
bitcoin-cli fundrawtransaction ...hash_response_from_createrawtransaction
fundrawtransaction will add any missing inputs and calculate the fee as you will see in the response.
If you still want the transaction size, you can get it by calling decoderawtransaction with the hash you have generated, or just calculating it by the hash itself, just divide the hash size by two.
For more control while creating your transactions, I'd suggest you to use listunspent and select the inputs by yourself
Docs:
createrawtransaction
Worth to give a look to this transaction size calculator to understand how to calculate the transaction size based in the (in/out)puts.

Storing Time on chaincode

Currently developing a chaincode and I have a doubt regarding storing dates.
If I have something like this:
result := XX{
Timestamp: time.Now().Format(time.RFC3339Nano),
ChangeSource: sourceOfChange,
}
stub.putState("result", result)
And by having a consensus, will that work?
Will the Timestamp be equal between all the peers? Will this pass a consensus?
No, it will not work reason is once the chaincode is executed the response is sent back to client where client evaluates whether all the responses are Same if they are different which in your case will be then the transactions are not sent for ordering

Geth 'sendTransaction' not working for some transactions while making much transactions in a loop

We are making 200 transactions in a loop for sending ether from one address to another address, all transaction should execute and return either success or fail.
But Some transactions are not executing i.e. we are not getting any results for those transactions neither success nor fail.
Steps to reproduce the behavior
Make 200 transactions in a loop to send ether from one address to another address
eth.sendTransaction({
from: privateWeb3.eth.coinbase,
to: result,
value: privateWeb3.toWei(2, 'ether')
}
check total no of results.
Total no of results will be less than total no. of transactions given
A common cause of this is duplicated nonces. Each transaction includes a consecutive increasing number called nonce. If you generate transactions too fast and geth didn't update fast enough, it will reuse the last one. So you will generate two transaction with the same nonce, in such case geth will reject one.

Resources