Open ineiti opened 11 months ago
I believe this is because the whole Dela software doesn't treat one's own node differently from the other nodes. As such, when something needs to be processed by all nodes, it'll be sent for all nodes to process.
In this particular case, I suspect the leader executes the contract once, when building a block and before proposing it to all the nodes (incl. itself), then a second time once the block is sent to all the nodes (incl. the leader itself) for validation/integration in the blockchain.
So there should be a cache to avoid executing the contract twice.
I'm not sure if my calculations are exact. But even for the worst case (meaning my calculations were right), voting time would go down from 100ms to 80ms. So I don't think it's worth it. But I keep it around in case we do need this small speedup.
is this still an issue?
It is an issue, but currently "premature optimization" :) If there are very slow smart contracts, it can double the transactions per second.
Currently the leader executes each smartcontract twice. Probably once to know if the contract is legit, and then once with the
doPBFT
method.It should execute the contract only once. Either use the result of this run, or only run it in the
doPBFT
method.