Dr. Saurabh Joshi
Principal Researcher
Supra Research
Execution trace of a deterministic state machine
x=x+1
x=x+1
x=x+1
Without deterministic operational semantics, given the same sequence of transactions, output state may be different when executed on a different hardware, or on the same hardware at a different time
Execution trace of a deterministic state machine agreed upon by a network of distributed, possibly heterogenous and decentralized computers
function multiClaim(uint256[] memory _tickets) external {
uint256 totalReward = 0;
for (uint i = 0; i < _tickets.length; i++) {
require (msg.sender == lotteryNFT.ownerOf(_tickets[i]), “not from owner”);
require (!lotteryNFT.getClaimStatus(_tickets[i]), “claimed”);
uint256 reward = getRewardView(_tickets[i]);
if(reward>0) {
totalReward = reward.add(totalReward);
}
}
lotteryNFT.multiClaimReward(_tickets);
if(totalReward>0) {
cake.safeTransfer(address(msg.sender), totalReward);
}
emit MultiClaim(msg.sender, totalReward);
}
“If we want to be serious about quality, it is time to get tired of finding bugs and start preventing their happening in the first place.”— Alan Page