I'm building a consensus engine. Already built a prototype of it, and now interested in improving it (mostly simplifying the implementation so it fits better with existing Ethereum codebase with least possible additions to it). In it, validators have to make a contract call during validation of a block, or, check if a certain transaction was made and succeeded. I'm currently doing the latter (since I assumed contract calls on non-canon blocks was not possible with standard interfaces such as BlockChainAPI.Call in internal/ethapi in Go-Ethereum. ) But, I would prefer to use a contract call. So I wanted to ask, does anyone know if it is easy to do contract calls during validation?
Also, long term, the functionality would be moved to headers and a custom trie (the functionality is a RNG relying on validators revealing a layer in pre-committed hash onion each block, thus generating the random number for the next validator). But my first prototypes use an on-chain contract instead.
Edit:
Hm, it looks like Finalize is called from Processor during insertChain (in Go-Ethereum) with statedb for block being validated. That means I can use StateDB.GetState to access contract data directly instead, directly in Finalize. And not leave a mess everywhere else.