How corrupt is your private Steem Engine node?

in #steem-engine5 years ago

Here's a script to check if your Steem Engine node is corrupt. It checks the block sequence as well as transaction organization.

First, install ruby. I like to use the Ruby Version Manager for this part.

Next, install Radiator:

gem install radiator

Then create a file called verify_steem_engine.rb (note: we assume the node is on http://127.0.0.1:5000):

block_agent = Radiator::SSC::Blockchain.new(root_url: 'http://127.0.0.1:5000')
block_num = 0
previous_hash = nil
trx_ids = {}

while !!(block = block_agent.block_info(block_num))
  block_num % 1000 == 0 and print '.'
  
  if !!previous_hash && previous_hash != block.previousHash
    puts "\nprevious_hash:      #{previous_hash}"
    puts "block.previousHash: #{block.previousHash}"
    abort("Problem detected at block_num: #{block_num}")
  end
  
  block.transactions.each do |trx|
    (trx_id = trx.transactionId) == 0 and next
    trx_id, idx = trx_id.split('-')
    
    if trx_ids.keys.include?(trx_id) && trx_ids[trx_id] != block_num
      puts "\nFound duplicate transaction id (#{trx_id}) already seen in block: #{trx_ids[trx_id]}"
      abort("Problem detected at block_num: #{block_num}")
    end
    
    trx_ids[trx_id] = block_num
  end
  
  block_num += 1
  previous_hash = block['hash']
end

puts "\nVerify complete, ending with block: #{block_num}"

Finally, run it:

ruby -r radiator verify_steem_engine.rb

If everything is fine, you'll see a result like this:

........................................................................................
Verify complete, ending with block: 95497

Otherwise, if there's something amiss, I recommend you delete the data directory, download the latest blocks.log file, and replay it.

Sort:  

Having a problem installing gem install radiator, maybe error in the ruby installation?

Usually, rvm.io documentation is pretty good about guiding you through the ruby install process. It does depend on your specific operating system. But on ubuntu, it boils down to:

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable 
source /home/tender/.rvm/scripts/rvm
rvm install ruby-2.6.0
gem install radiator

Thanks a million, I will definitely check that out

Wow, thanks @inertia for the scripts, it’s help Steemers a great deal!

Posted using Partiko iOS

Hi, @inertia!

You just got a 0.93% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hi @inertia!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 6.607 which ranks you at #144 across all Steem accounts.
Your rank has not changed in the last three days.

In our last Algorithmic Curation Round, consisting of 206 contributions, your post is ranked at #9.

Evaluation of your UA score:
  • You've built up a nice network.
  • The readers appreciate your great work!
  • Good user engagement!

Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.27
TRX 0.11
JST 0.031
BTC 71168.96
ETH 3851.55
USDT 1.00
SBD 3.52