Skip to content

Instantly share code, notes, and snippets.

@MrChico
Created April 2, 2019 12:20
Show Gist options
  • Save MrChico/f2a875e1e8d38d82550e8e0404d7a883 to your computer and use it in GitHub Desktop.
Save MrChico/f2a875e1e8d38d82550e8e0404d7a883 to your computer and use it in GitHub Desktop.
requires "../rules.k"
module SAFEADD_ADD_PASS
imports ETHEREUM-SIMULATION
imports EVM
imports RULES
// SafeAdd_add
rule
<k> #execute ~> CONTINUATION => #halt ~> CONTINUATION </k>
<exit-code> 1 </exit-code>
<mode> NORMAL </mode>
<schedule> PETERSBURG </schedule>
<analysis> .Map </analysis>
<ethereum>
<evm>
<output> _ => _ </output>
<statusCode> _ => EVMC_SUCCESS </statusCode>
<callStack> VCallStack </callStack>
<interimStates> _ </interimStates>
<touchedAccounts> _ => _ </touchedAccounts>
<callState>
<program> #asMapOpCodes(#dasmOpCodes(#parseByteStack("57005b600160010100"), PETERSBURG)) </program>
<programBytes> #parseByteStack("57005b600160010100") </programBytes>
<id> ACCT_ID </id>
<caller> CALLER_ID </caller>
<callData> _ </callData>
<callValue> VCallValue </callValue>
<wordStack> 2 : X : .WordStack => _ </wordStack>
<localMem> .Map => _ </localMem>
<pc> 0 => _ </pc>
<gas> VGas => #if (X ==Int 0) #then VGas -Int 10 #else VGas -Int 20 #fi </gas>
<memoryUsed> 0 => _ </memoryUsed>
<previousGas> _ => _ </previousGas>
<static> false </static>
<callDepth> VCallDepth => _ </callDepth>
</callState>
<substate>
<selfDestruct> VSelfDestruct </selfDestruct>
<log> _ => VLog </log>
<refund> _ => VRefund </refund>
</substate>
<gasPrice> _ </gasPrice>
<origin> ORIGIN_ID </origin>
<previousHash> _ </previousHash>
<ommersHash> _ </ommersHash>
<coinbase> _ </coinbase>
<stateRoot> _ </stateRoot>
<transactionsRoot> _ </transactionsRoot>
<receiptsRoot> _ </receiptsRoot>
<logsBloom> _ </logsBloom>
<difficulty> _ </difficulty>
<number> _ </number>
<gasLimit> _ </gasLimit>
<gasUsed> _ </gasUsed>
<timestamp> TIME </timestamp>
<extraData> _ </extraData>
<mixHash> _ </mixHash>
<blockNonce> _ </blockNonce>
<ommerBlockHeaders> _ </ommerBlockHeaders>
<blockhash> _ </blockhash>
</evm>
<network>
<activeAccounts> SetItem(ACCT_ID) _ </activeAccounts>
<accounts>
<account>
<acctID> ACCT_ID </acctID>
<balance> ACCT_ID_balance </balance>
<code> #parseByteStack("57005b600160010100") </code>
<storage> .Map
_:Map </storage>
<origStorage> _ </origStorage>
<nonce> _ </nonce>
</account>
...
</accounts>
<txOrder> _ </txOrder>
<txPending> _ </txPending>
<messages> _ </messages>
</network>
</ethereum>
requires #rangeAddress(ACCT_ID)
andBool #notPrecompileAddress(ACCT_ID)
andBool #rangeAddress(CALLER_ID)
andBool #rangeAddress(ORIGIN_ID)
andBool #rangeUInt(48, TIME)
andBool #rangeUInt(256, ACCT_ID_balance)
andBool VCallDepth <=Int 1024
andBool #rangeUInt(256, VCallValue)
andBool (#rangeUInt(256, ABI_X)
andBool (#rangeUInt(256, ABI_Y)
andBool (#sizeWordStack(CD) <=Int 1250000000
andBool (VGas >=Int 325
andBool (#rangeUInt(256, ABI_X +Int ABI_Y)
andBool (VCallValue ==Int 0))))))
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment