Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve timestamp updates #783

Merged
merged 10 commits into from
May 7, 2020
35 changes: 21 additions & 14 deletions web3.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module WEB3
</blockchain>
<defaultGasPrice> 20000000000 </defaultGasPrice>
<defaultGasLimit> 90000 </defaultGasLimit>
<lastTime> #time() </lastTime> // Need to be updated with #time() every time <timestamp> is updated
<accountKeys> .Map </accountKeys>
<nextFilterSlot> 0 </nextFilterSlot>
<txReceipts>
Expand Down Expand Up @@ -512,8 +513,9 @@ WEB3 JSON RPC
syntax KItem ::= "#evm_revert"
// ------------------------------
rule <k> #evm_revert => #popNetworkState ~> #rpcResponseSuccess(true) ... </k>
<params> [ DATA:Int, .JSONs ] </params>
<snapshots> SNAPSHOTS </snapshots>
<params> [ DATA:Int, .JSONs ] </params>
<snapshots> SNAPSHOTS </snapshots>
<lastTime> _ => #time() </lastTime>
requires DATA ==Int size(SNAPSHOTS)

rule <k> #evm_revert ... </k>
Expand All @@ -535,8 +537,9 @@ WEB3 JSON RPC
<params> [ (null => 0), .JSONs ] </params>

rule <k> #evm_increaseTime => #rpcResponseSuccess(Int2String(TS +Int DATA)) ... </k>
<params> [ DATA:Int, .JSONs ] </params>
<timestamp> ( TS:Int => ( TS +Int DATA ) ) </timestamp>
<params> [ DATA:Int, .JSONs ] </params>
<timestamp> ( TS:Int => ( TS +Int DATA ) ) </timestamp>
<lastTime> _ => #time() </lastTime>

syntax KItem ::= "#eth_newBlockFilter"
// --------------------------------------
Expand Down Expand Up @@ -1727,8 +1730,9 @@ Timestamp Calls
syntax KItem ::= "#firefly_setTime"
// -----------------------------------
rule <k> #firefly_setTime => #rpcResponseSuccess(true) ... </k>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseHexWord( TIME ) </timestamp>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseHexWord( TIME ) </timestamp>
<lastTime> _ => #time() </lastTime>

rule <k> #firefly_setTime => #rpcResponseSuccess(false) ... </k> [owise]
```
Expand Down Expand Up @@ -1789,11 +1793,12 @@ Mining
```k
syntax KItem ::= "#evm_mine"
// ----------------------------
rule <k> #evm_mine => #mineBlock ~> #rpcResponseSuccess("0x0") ... </k> [owise]
rule <k> #evm_mine => #updateTimestamp ~> #mineBlock ~> #rpcResponseSuccess("0x0") ... </k> [owise]

rule <k> #evm_mine => #mineBlock ~> #rpcResponseSuccess("0x0") ... </k>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseWord( TIME ) </timestamp>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseWord( TIME ) </timestamp>
<lastTime> _ => #time() </lastTime>

rule <k> #evm_mine => #rpcResponseError(-32000, "Incorrect number of arguments. Method 'evm_mine' requires between 0 and 1 arguments.") ... </k>
<params> [ _ , _ , _:JSONs ] </params>
Expand All @@ -1804,10 +1809,11 @@ Mining
<params> [ .JSONs => #unparseQuantity(#time()), .JSONs ] </params>

rule <k> #firefly_genesisBlock => #updateTrieRoots ~> #pushBlockchainState ~> #incrementBlockNumber ~> #rpcResponseSuccess(true) ... </k>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseWord( TIME ) </timestamp>
<logsBloom> _ => #padToWidth( 256, .ByteArray ) </logsBloom>
<ommersHash> _ => 13478047122767188135818125966132228187941283477090363246179690878162135454535 </ommersHash>
<params> [ TIME:String, .JSONs ] </params>
<timestamp> _ => #parseWord( TIME ) </timestamp>
<logsBloom> _ => #padToWidth( 256, .ByteArray ) </logsBloom>
<ommersHash> _ => 13478047122767188135818125966132228187941283477090363246179690878162135454535 </ommersHash>
<lastTime> _ => #time() </lastTime>

syntax KItem ::= "#mineBlock"
// -----------------------------
Expand Down Expand Up @@ -1869,7 +1875,8 @@ Mining
syntax KItem ::= "#updateTimestamp"
// -----------------------------------
rule <k> #updateTimestamp => . ... </k>
<timestamp> PREV => #if PREV <=Int #time() #then #time() #else PREV #fi </timestamp>
<timestamp> PREV => PREV +Int #time() -Int LASTTIME </timestamp>
<lastTime> LASTTIME => #time() </lastTime>
```

Retrieving logs
Expand Down