wemixarchive / go-wemix

Go implementation of the Wemix project.
https://www.wemix.com/
GNU Lesser General Public License v3.0
28 stars 25 forks source link

Feat/update snapshot pending state #111

Closed jennwiederholen closed 4 months ago

jennwiederholen commented 4 months ago

pr is for issue#109

the issue was about estimateGas function fails when it 'call' contract to simulate tx data in below condition :

  1. estimateGas function is sent to mining node
  2. tx data executed by estimate Gas needs latest block state(the current block state) to success
  3. mining node gets mining token at the time when tx requests estimateGas

it is due to 2 factors :

  1. estimateGas use PendingBlock to estimate gas of tx and it refers to snapshot db
  2. when mining node acquire mining token snapshot update is delayed due to blockCreationTime. ( thus the case is more frequent when blockCreationTime is long)

so the work is done as below :

  1. fix estimateGas function to use LatestBlock instead of PendingBlock
  2. however, it is logical for mining node to update pending state properly, updateSnapshot before time.Sleep
  3. additionally, non-mining node is entering commitWork which is useless; just updateSnapshot if the node is not miner member