Asset consensus rules.

+1 vote
We have been testing Multichain since 2016 and know the front end very well and are using it in our beta platform this year. But now we are getting into some custom applications that will require us to add some consesus mining rules by changing the source code. I want to add a consensus rule for assets. The source code is not well documented pretty much no comments which makes us have to really dig to find things. Lets say we want to add a consensus rule that sets a maximum amount per transaction for any asset. Where in the source do we start? I already see you have outlined a paramlist.h file which will define and lock in general consensus rules when creating the Genesis block. Where can we add some simple consensus/validation rules for assets?
asked Feb 6, 2018 by dtarsio

1 Answer

0 votes

The place to look for creating extra transaction rules is AcceptMultiChainTransaction().

If you're willing to work with MultiChain 2.0 (in alpha but stable as far as we know) you could take a look at the custom source code directly which allows you to add your rules in a predefined place using C/C++ compiled into the binary. (We can also help with this on a commercial basis.) Once filters are implemented you should be able to write these rules at the application level in a high-level language like Javascript.

answered Feb 7, 2018 by MultiChain
Ok not sure if I understand exactly. Are you referring that I make the rules in a front end API? But these rules will not actually be enforced by mining / overall consesus rules? I see where you have allocated custom code but I am not sure is this going to evaluate consesus during block creation or only check if the current transaction on one specific node has valid inputs based on a set of custom rules.

I could modify any front end, RPC call or your wallet source code to achieve custom transaction input rules that would be easy, but this will not carry through when mining blocks because any new miner node could just take out of the source code I modified and spam the network. Maybe I am not understanding something but I would like to modify overall consensus rules for the entire chain? And other question is can these rules be modified after a chain is well underway. I assume if I have enough miners with the same new set of rules it will bump the chain into the new rule set.
If you modify the code in the way suggested in this answer, it affects the consensus rules applied by every node in the chain (not just miners).
Not really because say for example in order for a single transaction to be valid and accepted by miners a user must enter a max amount of an asset per transaction. If they enter beyond that amount then the transaction will not be accepted by miners and not added to the chain.  

If I write a front end API I can easily set a max asset rule and not even create a transaction if the users input was above the max. But in multichain there is no rule for max asset so if another connected node does not use my API they can build a transaction without my max asset rule.

If I go into your source code and add a little code to check for maximum asset say in the wallet functions that works but if another miner joins the network and comments out this code change they can easily ignore the rule and post a transaction above the max asset rule. Maybe I am confusing where you have implemented consusus vs. basic transaction checking.
The basis of any blockchain is a basic agreement on the protocol rules as expressed in the use of a particular code base. Of course if some of your network don't apply these rules, you'll end up with a fork, with those not applying the rules being off the main chain. That's true of any blockchain. So in terms of workflow you would simply say "use this node if you want to connect to our chain". Anyone using a different node will just be in their own isolated fork.
I think I am understanding now I would have to set up say 100 miners with the max asset per transaction rule that I added in your source code. Then if miner 101-110 changed that source code back they are essentially starting a fork. There is really no way to implement a rule and make it stick unless there are more miners using the source code with my new rule than there are with source code that does not have my rules. The only way we could keep miners complying with the rules is to kick them off the chain which is a feature you make possible. Am I understanding this correctly?
Yes, and this is true of any consensus system. There's nothing you can do if the majority decide to change the rules.
...