Issues when applying tx filters

+2 votes

Hi team (possible this is a duplication, as previous one I asked w/o being a member, sr for any inconvenience),

I've been trying to test the latest tx filters by using this script to limit asset for USD, but I had some issues, as below:

  • The filter actually filtered out the tx in the strange behaviour, as given, if value > 1000 it will be error, but even when I put 100 or 500, it also rejected the tx
  • When I approved the tx filters, the blockchain stopped producing new blocks (check with block height), all attempts to start again the chain are not successful
Here are the commands I've used:

multichain-cli test1 issuefrom 1Cr6VxbSQ5TMfegbUSgY4t1F2ing2QH2yVLgAd 1Cr6VxbSQ5TMfegbUSgY4t1F2ing2QH2yVLgAd '{"name":"USD","open":true}' 50000 0.01 0 '{"origin":"us", "stage":"01", "purpose":"parts prepayment"}'

multichain-cli test1 sendasset 1bND5DeePFNmrWBoeaVn4z6WJiYSQv9jMwSwY7 USD 3000

multichain-cli test1 create txfilter testfilter '{"for":"USD"}' 'function outputtoaddressbalancechange(output, spent, addressbalancechange) { if (output.assets) { for (var assetnum=0; assetnum<output.assets.length; assetnum++) { if (output.assets[assetnum].name=="USD") { for (var addressnum=0; addressnum<output.scriptPubKey.addresses.length; addressnum++) { var address=output.scriptPubKey.addresses[addressnum]; if (!addressbalancechange.hasOwnProperty(address)) addressbalancechange[address]=0; var rawchange=spent ? -output.assets[assetnum].raw : output.assets[assetnum].raw; addressbalancechange[address]+=rawchange; } } } } } function filtertransaction() { var tx=getfiltertransaction(); var addressbalancechange={}; for (var inputnum=0; inputnum<tx.vin.length; inputnum++) { outputtoaddressbalancechange(getfiltertxinput(inputnum), true, addressbalancechange); } for (var outputnum=0; outputnum<tx.vout.length; outputnum++) { outputtoaddressbalancechange(tx.vout[outputnum], false, addressbalancechange); } for (var address in addressbalancechange) if (addressbalancechange[address]>1000) return "Address "+address+" is receiving too much USD"; }'

multichain-cli test1 approvefrom 1bND5DeePFNmrWBoeaVn4z6WJiYSQv9jMwSwY7 testfilter true

Do you have any reasons for the strange behavior from the chain?

Thank you for your support,

Best,

 

asked Oct 15, 2018 by adle

1 Answer

+1 vote
First you should note that the limit set in the filter is in raw units of the asset, not display units. So if your USD asset is divisible into units of $0.01, the limit of 1000 actually means $10.

Second there's an issue in MultiChain 2.0 alpha 5 where transaction filters are applied to the coinbase transactions that identify the miner of each block, and this can lead to unexpected consequences. This will be fixed in MultiChain 2.0 alpha 6 (or more precisely, in the protocol version it introduces).
answered Oct 16, 2018 by MultiChain
Thanks for the reply.
Ok so for the limit asset, it will always be raw units.
As the chain stops creating new blocks after tx filter is apply, do you have any way to bring it back, or the only way is to create new chain and test again?
Best,
You could try disabling the txfilter using the approvefrom command, passing false as the final parameter. Depending on the exact circumstances that may help.
...