How to Review an EOSIO Set Code multisig Transaction by lukestokes

View this thread on steempeak.com
· @lukestokes ·
$13.60
How to Review an EOSIO Set Code multisig Transaction
Blockchains represent a powerful tool for transparency, interoperability, and global non-violent consensus. When we add the ability to write software and create programs directly on a blockchain, a whole new set of opportunities opens up to us. Chains like Ethereum, Cardano, EOS, and more are testing these smart contract realities while chains like Steem are staying focused to do just one thing (tokenizing the web by enabling social media applications) and do it well. The jury is still out as to which approach is best, but I see value both ways. What we're doing with @eosdac and the <a href="https://steemit.com/eosdac/@eosdac/the-dac-chain-initiative-announcing-an-exploratory-into-how-usage-of-eos-side-chains-and-separate-chains-may-create-benefits-for">DAC Chain Initiative</a> in the future may involve using EOSIO as a base and then include DAC enabling functionality on a system-contract level for the whole chain.

Exciting stuff, but one thing I believe isn't talked about enough is who is actually managing and verifying these smart contracts? How do we know the code we run on a blockchain actually matches the code we think we're running? One of the great benefits of a DAC (Decentralized Autonomous Community) is how multisignature permissions can be used to distribute the management according to the will of the token holders in the community. As such, all changes to the code are done as multisignature requests so the elected custodians can approve or deny them according to the intentions of the voters.

This is also how changes are made to EOSIO system contracts today by the block producers. Unfortunately, many are not familiar with how to verify proposed system contract updates. That's what this post is about.

It's totally geeky and only for a small subset of people who want to know how to validate a blockchain smart contracts on EOSIO proposed as a multisignature transaction.

Here's the video I put together walking through the process. It's about 12 minutes long.

<iframe width="560" height="315" src="https://www.youtube.com/embed/fVMwojWciQ0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Here are some of my notes to go along with the video:

First off, environment set up. I use this little script so I don't have to specify the url from my cleos each time.

```
➜  mainnet cat cleos.sh 
#!/bin/bash

/Users/lukestokes/Documents/workspace/eosDAC/chains/mainnet/bin/cleos/cleos --url https://eu.eosdac.io "$@"
```

Make sure you have the abi_from_hex binary:

Using this patch: https://gist.github.com/elmato/4fce5bd325ca56bf037f4f906d0a67ae

The patch may not apply cleanly, but the key is to add these lines to the CMakeLists.txt file:

 ```
+add_executable( abi_from_hex abi_from_hex.cpp )
+target_include_directories( abi_from_hex PRIVATE ${Boost_INCLUDE_DIR} )
+target_link_libraries( abi_from_hex PRIVATE eosio_chain fc ${Boost_LIBRARIES} )
```

Have JQ installed: https://stedolan.github.io/jq/

* Get the exact version of compiler used to compile the contract.

	In this example, we're using cdt 1.3.2

	git clone https://github.com/EOSIO/eosio.cdt.git
	cd eosio.cdt
	git checkout v1.3.2
	./build.sh

* Compile the source code involved

	git clone https://github.com/eosdac/dacmultisigs.git
	cd dacmultisigs
	eosio-cpp --abigen dacmultisigs.cpp -o dacmultisigs.wasm

* get the hash of the compiled code

	sha256sum dacmultisigs.wasm

	Example:

	d6337efc0f19baef5c282dbc5163baabd9cb583cfa4eb19191c031758952b72c  dacmultisigs.wasm

* get the hash of the code in the multisig transaction:

	./cleos.sh multisig review mryeateshere multisigcode | jq -r '.transaction.actions[0].data.code' | xxd -r -p | sha256sum
	d6337efc0f19baef5c282dbc5163baabd9cb583cfa4eb19191c031758952b72c  -

	Hurray! They match. :)

* compare the ABIs by extracting the abi from the multisig:

	./cleos.sh multisig review mryeateshere multisigcode | jq -r '.transaction.actions[1].data.abi' | ./eos/abi_from_hex | jq '' > multisigcode-abi.json 

* Compare it with what is on github:

	diff -w multisigcode-abi.json ../../github/dacmultisigs/dacmultisigs.abi
```
	1a2
	>     "____comment": "This file was generated with eosio-abigen. DO NOT EDIT Mon Nov 19 14:00:39 2018",
	3d3
	<   "types": [],
	127a128
	>     "types": [],
	162a164
	>             "type": "storedproposal",
	165,166c167
	<       "key_types": [],
	<       "type": "storedproposal"
	---
	>             "key_types": []
	170,172c171
	<   "error_messages": [],
	<   "abi_extensions": [],
	<   "variants": []
	---
	>     "abi_extensions": []
```

Note, some of the keys may be out of order and in some cases you may see extra empty keys like error_messages and variants above, but that should make no difference.

With that, you've verified that the code in the github you compiled yourself matches what is being proposed as a multisignature transaction.

Stuff like this is currently way to geeky and difficult for most people to care about. At the same time, as our world becomes more and more defined by the software that runs it, we all have to take some responsibility to ensure the code we're trusting in can actually be trusted.

-----

<img src="https://steemitimages.com/DQmR3hhPtgcqhNDZyArucp2dZv2pG62WDKiWam8jrppCXNB/on_a_log_cropped.png">

<p>
    <div class="pull-right">
        <a href="https://steemit.com/introduceyourself/@lukestokes/my-name-is-luke-let-s-create-the-world-we-want-to-live-in"><img src="https://steemitimages.com/DQmRh7DLpp1hDKugxyWxdDof7rkj5fpBus6tECvv7vcmL6d/smile.png" /></a>
    </div>
    <em><a href="https://steemit.com/introduceyourself/@lukestokes/my-name-is-luke-let-s-create-the-world-we-want-to-live-in">Luke Stokes</a> is a father, <a href="https://steemit.com/@corinnestokes">husband</a>, programmer, STEEM witness, <a href="https://steemit.com/eosdac/@lukestokes/a-big-step-towards-our-decentralized-future-i-ve-joined-the-eosdac-launch-team">DAC launcher</a>, and voluntaryist who wants to help create a world we all want to live in. Learn about cryptocurrency at <a href="http://understandingblockchainfreedom.com/">UnderstandingBlockchainFreedom.com</a></em>
</p>

<center><a href="http://steemitboard.com/board.html?user=lukestokes"><img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/commented.png?v=20180909"> <img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/votes.png?v=20180909"> <img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/posts.png?v=20180909"><img src="https://steemitimages.com/80x65/http://steemitboard.com/@lukestokes/level.png?v=20180909"> <img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/comments.png?v=20180909"> <img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/voted.png?v=20180909"> <img src="https://steemitimages.com/50x55/http://steemitboard.com/@lukestokes/payout.png?v=20180909"></a></center>

<center><sub><a href="https://steemit.com/witness-category/@lukestokes/vote-luke-stokes-for-witness-as-lukestokes-mhth">I'm a Witness</a>! Please <a href="https://steemit.com/~witnesses">vote for @lukestokes.mhth</a></sub></center><center><a href="https://steemit.com/~witnesses" alt="Please vote for @lukestokes.mhth"><img src="https://cdn.steemitimages.com/DQmPoSccBq1L7fD7AJGLJamZRgxGH1K1ZXzCc6iZNFBqZT5/image.png"></a></center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 144 others
properties (23)
post_id66,570,677
authorlukestokes
permlinkhow-to-review-an-eosio-set-code-multisig-transaction
categoryeos
json_metadata{"format":"markdown","app":"steemit\/0.1","links":["https:\/\/steemit.com\/eosdac\/@eosdac\/the-dac-chain-initiative-announcing-an-exploratory-into-how-usage-of-eos-side-chains-and-separate-chains-may-create-benefits-for","https:\/\/www.youtube.com\/embed\/fVMwojWciQ0","https:\/\/gist.github.com\/elmato\/4fce5bd325ca56bf037f4f906d0a67ae","https:\/\/stedolan.github.io\/jq\/","https:\/\/github.com\/EOSIO\/eosio.cdt.git","https:\/\/github.com\/eosdac\/dacmultisigs.git","https:\/\/steemit.com\/introduceyourself\/@lukestokes\/my-name-is-luke-let-s-create-the-world-we-want-to-live-in","https:\/\/steemit.com\/@corinnestokes","https:\/\/steemit.com\/eosdac\/@lukestokes\/a-big-step-towards-our-decentralized-future-i-ve-joined-the-eosdac-launch-team","http:\/\/understandingblockchainfreedom.com\/","http:\/\/steemitboard.com\/board.html?user=lukestokes","https:\/\/steemit.com\/witness-category\/@lukestokes\/vote-luke-stokes-for-witness-as-lukestokes-mhth","https:\/\/steemit.com\/~witnesses"],"image":["https:\/\/img.youtube.com\/vi\/fVMwojWciQ0\/0.jpg"],"users":["eosdac"],"tags":["eos","programming","multisignature","dac","smart-contracts"]}
created2018-11-25 17:37:36
last_update2018-11-25 17:37:36
depth0
children4
net_rshares22,346,126,782,310
last_payout2018-12-02 17:37:36
cashout_time1969-12-31 23:59:59
total_payout_value10.549 SBD
curator_payout_value3.051 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length7,406
author_reputation395,063,281,398,324
root_title"How to Review an EOSIO Set Code multisig Transaction"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (208)
@clumsysilverdad ·
hey, i'm not a coding geek, so i know little, but do u feel the EOS will hold-up strong if our steem dapps come on strong ?   thanks man, peace from WI  (-:
properties (22)
post_id66,571,410
authorclumsysilverdad
permlinkre-lukestokes-how-to-review-an-eosio-set-code-multisig-transaction-20181125t175701134z
categoryeos
json_metadata{"app":"steemit\/0.1","tags":["eos"]}
created2018-11-25 17:57:03
last_update2018-11-25 17:57:03
depth1
children2
net_rshares0
last_payout2018-12-02 17:57:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length156
author_reputation24,049,780,175,854
root_title"How to Review an EOSIO Set Code multisig Transaction"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@lukestokes · (edited)
Language like "hold up strong" is too vague for me. I think there's room for all kinds of applications and blockchains and distributed ledgers. Much of what is done now in centralized, hierarchy systems can find some benefit from the transparency available through globally distributed, cryptographically secure, verifiable ledgers. I'm less interested in finding a winner than in finding a combination of tools which will improve humanity.
👍  
properties (23)
post_id66,571,789
authorlukestokes
permlinkre-clumsysilverdad-re-lukestokes-how-to-review-an-eosio-set-code-multisig-transaction-20181125t180816985z
categoryeos
json_metadata{"app":"steemit\/0.1","tags":["eos"]}
created2018-11-25 18:08:18
last_update2018-11-25 18:08:36
depth2
children1
net_rshares11,207,618,824
last_payout2018-12-02 18:08:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length440
author_reputation395,063,281,398,324
root_title"How to Review an EOSIO Set Code multisig Transaction"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@clumsysilverdad ·
very cool , ty ... i'm learning slowly but surely (-:
properties (22)
post_id66,576,184
authorclumsysilverdad
permlinkre-lukestokes-re-clumsysilverdad-re-lukestokes-how-to-review-an-eosio-set-code-multisig-transaction-20181125t202245628z
categoryeos
json_metadata{"tags":["eos"],"app":"steemit\/0.1"}
created2018-11-25 20:22:48
last_update2018-11-25 20:22:48
depth3
children0
net_rshares0
last_payout2018-12-02 20:22:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length53
author_reputation24,049,780,175,854
root_title"How to Review an EOSIO Set Code multisig Transaction"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@amahovac93 ·
If everything goes according to paln Steem could tokenize every social media.
And we all know how big the social media is, i am bullish on Steem long term!

Posted using [Partiko Android](https://steemit.com/@partiko-android)
properties (22)
post_id66,572,110
authoramahovac93
permlinkamahovac93-re-lukestokes-how-to-review-an-eosio-set-code-multisig-transaction-20181125t181827277z
categoryeos
json_metadata{"app":"partiko"}
created2018-11-25 18:18:27
last_update2018-11-25 18:18:27
depth1
children0
net_rshares0
last_payout2018-12-02 18:18:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length225
author_reputation21,379,620,895,022
root_title"How to Review an EOSIO Set Code multisig Transaction"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000