Skip to content

Instantly share code, notes, and snippets.

@MrChico
Created June 15, 2018 22:59
Show Gist options
  • Save MrChico/83a3d9f43c699c472bc66a39c3549313 to your computer and use it in GitHub Desktop.
Save MrChico/83a3d9f43c699c472bc66a39c3549313 to your computer and use it in GitHub Desktop.
requires "abstract-semantics.k"
requires "verification.k"
module PROOF-SPEC
imports ETHEREUM-SIMULATION
imports ABSTRACT-SEMANTICS
imports VERIFICATION
// updateVal
rule
<k> #execute => #halt </k>
<exit-code> 1 </exit-code>
<mode> NORMAL </mode>
<schedule> BYZANTIUM </schedule>
<analysis> .Map </analysis> // not part of evm
<ethereum>
<evm>
<output> _ => _ </output>
<statusCode> _ => EVMC_SUCCESS </statusCode>
<callStack> _ </callStack>
<interimStates> _ </interimStates>
<touchedAccounts> _ => _ </touchedAccounts>
<callState>
<program> #asMapOpCodes(#dasmOpCodes(#parseByteStack("0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806375657f15146044575b600080fd5b348015604f57600080fd5b50606c60048036038101908080359060200190929190505050606e565b005b8060005401600081905550505600a165627a7a72305820822d71c47dc6fd96a4e12c816425e0081df9f207a0fd1165237063fc774f9e180029"), BYZANTIUM)) </program>
<programBytes> #parseByteStack("0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806375657f15146044575b600080fd5b348015604f57600080fd5b50606c60048036038101908080359060200190929190505050606e565b005b8060005401600081905550505600a165627a7a72305820822d71c47dc6fd96a4e12c816425e0081df9f207a0fd1165237063fc774f9e180029") </programBytes>
<id> ACCT_ID </id> // contract owner
<caller> CALLER_ID </caller> // who called this contract; in the begining, origin // msg.sender
<callData> #abiCallData("tempDelta", #uint256(X)) </callData>
<callValue> 0 </callValue>
<wordStack> .WordStack => _ </wordStack>
<localMem> .Map => _ </localMem>
<pc> 0 => _ </pc>
<gas> G => _ </gas>
<memoryUsed> 0 => _ </memoryUsed>
<previousGas> _ => _ </previousGas>
<static> false </static> // NOTE: non-static call
<callDepth> CALL_DEPTH </callDepth>
</callState>
<substate>
<selfDestruct> _ </selfDestruct>
<log> _ </log>
<refund> _ </refund> // TODO: more detail
</substate>
<gasPrice> _ </gasPrice>
<origin> ORIGIN_ID </origin> // who fires tx
<previousHash> _ </previousHash>
<ommersHash> _ </ommersHash>
<coinbase> _ </coinbase>
<stateRoot> _ </stateRoot>
<transactionsRoot> _ </transactionsRoot>
<receiptsRoot> _ </receiptsRoot>
<logsBloom> _ </logsBloom>
<difficulty> _ </difficulty>
<number> _ </number>
<gasLimit> _ </gasLimit>
<gasUsed> _ </gasUsed>
<timestamp> _ </timestamp>
<extraData> _ </extraData>
<mixHash> _ </mixHash>
<blockNonce> _ </blockNonce>
<ommerBlockHeaders> _ </ommerBlockHeaders>
<blockhash> _ </blockhash>
</evm>
<network>
<activeAccounts> SetItem(ACCT_ID) _:Set
</activeAccounts>
<accounts>
<account>
<acctID> ACCT_ID </acctID>
<balance> BAL </balance>
<code> #parseByteStack("0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806375657f15146044575b600080fd5b348015604f57600080fd5b50606c60048036038101908080359060200190929190505050606e565b005b8060005401600081905550505600a165627a7a72305820822d71c47dc6fd96a4e12c816425e0081df9f207a0fd1165237063fc774f9e180029") </code>
<storage>
#hashedLocation("Solidity", 0, .IntList) |-> (0 => X)
</storage>
<nonce> _ </nonce>
</account>
...
</accounts>
<txOrder> _ </txOrder>
<txPending> _ </txPending>
<messages> _ </messages>
</network>
</ethereum>
requires 0 <=Int ACCT_ID andBool ACCT_ID <Int (2 ^Int 160)
andBool 0 <=Int CALLER_ID andBool CALLER_ID <Int (2 ^Int 160)
andBool 0 <=Int ORIGIN_ID andBool ORIGIN_ID <Int (2 ^Int 160)
andBool 0 <=Int CALL_DEPTH andBool CALL_DEPTH <Int 1024
andBool 0 <=Int X
andBool X <Int pow256
andBool G >Int 33000
andBool CALL_DEPTH <Int 250
andBool 0 <=Int BAL
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment