Commit Graph

393 Commits

Author SHA1 Message Date
andri lim 51edbe6390 fix shr and shl gasCost 2019-05-13 10:26:28 +03:00
andri lim 5f2be4231e implement EIP1014: Create2 opcode 2019-05-13 10:26:28 +03:00
andri lim 4a7f58c7dc implement constantinople bitwise opcode 2019-05-13 10:26:28 +03:00
andri lim 2f08a6bc0e fix byzantium contract creation OOG 2019-05-13 10:26:28 +03:00
andri lim fd8a649df3 fix RevertInCreateInInit problem 2019-05-13 10:26:28 +03:00
andri lim b34ad8b507 fix collectTouchedAccounts 2019-05-13 10:26:28 +03:00
andri lim f809a864b1 fix calcMemSize bug 2019-05-13 10:26:28 +03:00
andri lim 213fb3b971 constantinople's skeletal implementation 2019-05-13 10:26:28 +03:00
Ștefan Talpalaru 631f3ca29f
fix for Nim HEAD 2019-05-01 19:56:23 +02:00
andri lim cee0a38278
add some comment 2019-04-26 07:31:18 +07:00
andri lim 376957bea4
clean up unused code 2019-04-26 07:31:18 +07:00
andri lim 3ccd1b1ee9
fix rangeToPadded, GST +5 2019-04-26 07:31:17 +07:00
andri lim fd7c447f18
fix modexp output, GST +53 2019-04-26 07:31:16 +07:00
andri lim 89402af114
fix modexp gasCost, GST +6 2019-04-26 07:31:16 +07:00
andri lim 03ea1c5a85
fix ecRecover precompiles, GST +1 2019-04-26 07:31:15 +07:00
andri lim ba47d3c997
fix returnDataCopy gasCost, GST +11 2019-04-26 07:31:14 +07:00
andri lim 7b47cb6b24
various fixes, GST +6 2019-04-26 07:31:14 +07:00
andri lim 90e3a4320a
fix revert opcode at first level computation 2019-04-26 07:31:13 +07:00
andri lim c57295da0b
fix precompiles error handling, GST +262 2019-04-26 07:31:13 +07:00
andri lim ceb159f5fe
fix static context check in Call and Create, GST +52 2019-04-26 07:31:12 +07:00
andri lim 605618d9ee
add static context check, GST +94 -28 2019-04-26 07:31:12 +07:00
andri lim be5cce6c71
fix static call addr, GST +93 -16 2019-04-26 07:31:11 +07:00
andri lim 7940d443e9
implement EIP214: staticCall opcode 2019-04-26 07:31:10 +07:00
andri lim 52caf0c248
implement EIP211: returnDataCopy and returnDataSize opcode 2019-04-26 07:31:10 +07:00
andri lim d8284f9330
fix revert opcode 2019-04-26 07:31:09 +07:00
andri lim 13cd54a382
implement byzantium opcode dispatch 2019-04-26 07:31:03 +07:00
Ștefan Talpalaru 29a226da1e
more gcsafe pragmas for Nim HEAD 2019-04-26 00:18:51 +02:00
andri lim ec918602bc
fix accountsForDeletion iterator, GST +2 2019-04-18 13:23:04 +07:00
andri lim 1883472104
fix evm msg contract creation, GST +3 2019-04-18 12:42:37 +07:00
andri lim f7338b7d76
include miner address in touchedAccounts, GST +7 2019-04-18 11:12:21 +07:00
andri lim c07f01a74d
fix collectTouchedAccounts: msg.destination -> msg.storageAddress, GST +4 2019-04-18 10:22:48 +07:00
andri lim 6cf0cdf23a
implement EIP161 nonce incrementation, GST +65 2019-04-17 12:15:15 +07:00
andri lim 85d9bd3958
implement EIP158, GST -4 +81 2019-04-17 11:03:52 +07:00
andri lim 23d084da68
add SpuriousGasCosts table into forkToSchedule 2019-04-17 09:46:33 +07:00
Ștefan Talpalaru 8800cb5fe5
Merge branch 'fix_244' of github.com:jangko/nimbus into jangko-fix_244 2019-04-15 14:05:18 +02:00
andri lim 79630611c0
fixes #244 2019-04-15 11:34:41 +07:00
andri lim 69c1d9e357
fix block 2.463.413 problem 2019-04-15 11:10:40 +07:00
andri lim 34fd831d6f
fix block 2283416 problem 2019-04-15 10:11:09 +07:00
andri lim d039b88f48
activates Tangerine GST, GST +12 2019-04-08 08:06:40 +07:00
andri lim 7eafd75d17
separate tangerine whistle and spurious dragon opcode dispatcher 2019-04-08 08:06:40 +07:00
andri lim 6f51cf9103
implement EIP150 and EIP161 SelfDestruct OpCode 2019-04-08 08:06:39 +07:00
andri lim 77e9c18f91
implement Tangerine fork gas cost changes 2019-04-08 08:06:34 +07:00
andri lim a8d0a13856
fix fork comparison at postExecuteVM bug 2019-04-07 06:53:40 +07:00
andri lim d37d7fa6a5
remove computedGoto pragma 2019-04-04 17:23:28 +07:00
andri lim fb97d8d0ce
move exception handler to executeOpcodes 2019-04-04 15:26:12 +07:00
andri lim 039256de6a
more on continuation passsing 2019-04-04 15:21:24 +07:00
andri lim 60df7ea5e2
update test data 2019-04-04 12:13:33 +07:00
andri lim e5cca19e7f
tail call recursion with continuation passing 2019-04-04 11:44:35 +07:00
andri lim 4c0ba876ef
move exception handler deeper in the EVM 2019-04-04 10:50:25 +07:00
andri lim 07ac4620d9
remove 'var' modifier from 'computation: var BaseComputation' 2019-04-04 10:20:00 +07:00
andri lim 26b40f41e3
fix precompiles selection, GST +5 2019-04-02 13:11:00 +07:00
andri lim 112d2219df
reduce indirect call in EVM 2019-04-02 13:11:00 +07:00
andri lim 0f8affb7c9
remove explicit return value from VM 2019-04-02 13:11:00 +07:00
Ștefan Talpalaru 54b0242169
Merge branch 'fix_evm' of github.com:jangko/nimbus into jangko-fix_evm 2019-03-28 15:21:28 +01:00
Ștefan Talpalaru b16aba391a
Merge branch 'fix_maxcalldepth' of github.com:jangko/nimbus into jangko-fix_maxcalldepth 2019-03-28 15:09:51 +01:00
andri lim da88d498e3
fix MaxCallDepth comparison 2019-03-28 19:08:54 +07:00
andri lim 1ad4e256b2
fix self destruct refund gas problem 2019-03-28 19:07:30 +07:00
andri lim d9a9459d95
reduce stack usage 2019-03-28 19:06:38 +07:00
andri lim 527891cdb8
integrate snapshot with computation 2019-03-28 19:06:31 +07:00
andri lim a02cbdd91b
turn getAccountsForDeletion into interator 2019-03-21 09:50:51 +07:00
andri lim b6587bddfd
execComputation and applyMessage unification 2019-03-21 09:47:46 +07:00
andri lim be79bc8740
remove opCodeExec, use executeOpcodes 2019-03-21 09:32:48 +07:00
andri lim 4aaa6e6c94
computation simplification 2019-03-21 09:31:55 +07:00
andri lim b73a1238e0
interpreter dispatch simplification 2019-03-21 09:27:14 +07:00
Ștefan Talpalaru f62601e844
Merge branch 'non_recursive_evm' of github.com:jangko/nimbus into jangko-non_recursive_evm 2019-03-20 14:43:50 +01:00
andri lim 268695003b
fix writePaddedResult regression 2019-03-19 16:43:38 +07:00
andri lim 7198ce2d05
fix ecrecover bad V, GST +1 2019-03-18 19:28:42 +07:00
andri lim aed0db2d03
fix DelegateCall sender address, GST +37 2019-03-18 18:45:43 +07:00
andri lim 36fb75d042
fix DelegateCall gasCost, GST +6 2019-03-18 17:24:25 +07:00
andri lim 739e20253a
fix invalid opcodes bug, GST +1 2019-03-18 13:44:22 +07:00
andri lim 4f6f564626
fix regression 2019-03-18 13:13:16 +07:00
andri lim 4383831772
separate Frontier and Homestead opcode dispatcher 2019-03-18 11:27:32 +07:00
andri lim d0822c26d1
fix callcode insufficient funds, GST +6 2019-03-16 22:54:24 +07:00
andri lim 433ccba15f
fix writePaddedResult, GST +4 2019-03-16 21:42:06 +07:00
andri lim adb1286e28
fix create hash collision, GST +1 2019-03-16 12:13:57 +07:00
andri lim 99d128ca26
fix CREATE opcode gas cost 2019-03-15 22:15:40 +07:00
andri lim 823dd95a53
write contract unification 2019-03-15 18:16:47 +07:00
andri lim 0654a232a3
rename transferBalance to canTransfer 2019-03-14 16:24:27 +07:00
andri lim 039ab1ce71
refactor/relocate CALL/CREATE to reduce stack usage 2019-03-14 14:58:26 +07:00
Ștefan Talpalaru a67edd693a
assert() -> doAssert() 2019-03-13 22:36:54 +01:00
andri lim 4ed98e03d1
remove unneeded param from transferBalance 2019-03-13 22:14:10 +07:00
andri lim 44688259f1
simplify transferBalance again 2019-03-13 22:06:32 +07:00
andri lim 2f9f708f1b
simplify balance transfer 2019-03-13 21:34:53 +07:00
andri lim f1fac6be0f
remove redundant updateOpcodeExec 2019-03-13 21:15:13 +07:00
andri lim 1b3ca200fa
remove redundant execPrecompiles call 2019-03-13 21:10:16 +07:00
andri lim f5d6d6bc02 fix block 1317742 problem 2019-03-13 15:49:54 +02:00
andri lim 9f8191d408 EVM write contract transformation 2019-03-12 13:32:41 +02:00
andri lim b1da3576ad
fix block 1149150 problem 2019-03-11 18:50:13 +07:00
andri lim de809b0060
fix block 1017395 problem 2019-03-11 12:03:57 +07:00
andri lim a15805e41a fix applyCreateMessage 2019-02-28 10:04:49 +02:00
andri lim fc613b33df computation.nim cleanup 2019-02-28 10:04:49 +02:00
andri lim 4cc318d948 fix block 668910 problem 2019-02-28 10:04:49 +02:00
andri lim 9d6fb4c82e add comment to transaction tracer 2019-02-27 13:30:18 +02:00
andri lim 2c032ad1ab refactor utils 2019-02-27 13:30:18 +02:00
andri lim 9522c1145f
fix #245 again 2019-02-25 22:59:05 +07:00
andri lim 9fcba8f90d
fix block 512335 problem 2019-02-25 21:18:13 +07:00
andri lim 0d64e0a6c3
fix #245 2019-02-25 20:02:16 +07:00
andri lim 3dd18bd8ec
fix block 299804 problem 2019-02-25 17:03:43 +07:00
andri lim 592fa5df7e fix SIGNEXTEND opcode 2019-02-23 17:57:53 +02:00
andri lim bc675b1daa fix contract creation 2019-02-23 17:57:53 +02:00
andri lim f5e54b8d4f fix self destruct problem 2019-02-23 17:57:53 +02:00
andri lim 28245e92a2 fixes #235 2019-02-22 13:10:22 +02:00
andri lim 47a8089ff8 fixes #236 2019-02-21 13:09:36 +02:00
andri lim 4dc45550dd fix block 226522 problem 2019-02-21 13:09:36 +02:00
andri lim b198ffee2d fix vm oog problem 2019-02-20 15:16:07 +02:00
andri lim dcf7699358 fix callcode regression 2019-02-20 15:16:07 +02:00
andri lim 71e7ee2dae fixes ECRecover precompiles 2019-02-20 15:16:07 +02:00
andri lim 96ae5ee05a fix CALLCODE storage address 2019-02-20 15:16:07 +02:00
andri lim 999c958641 fix opcode call OOG 2019-02-20 15:16:07 +02:00
andri lim 2e8176eb15 simplify CREATE gasCost 2019-02-20 15:16:07 +02:00
andri lim 0b9326f955 fix block 81383 problem 2019-02-20 15:16:07 +02:00
andri lim c722f34ef3 safer snapshot commit revert and dispose 2019-02-18 18:15:32 +02:00
andri lim d015fc3819 bugfix: transaction tracer more robust storage key handling 2019-02-18 13:16:04 +02:00
andri lim 8461211f9a bugfix: implement computation snapshot, revert, commit 2019-02-18 13:16:04 +02:00
andri lim 927abdc142 bugfix: multi-depth transaction tracer storage 2019-02-18 13:16:04 +02:00
andri lim a1242d2538 bugfix: block 78458 crash 2019-02-18 13:16:04 +02:00
andri lim 282824cd53 zah's request: add missing comments 2019-02-18 13:16:04 +02:00
andri lim 8f9d1ae748 fixes callcode bug 2019-02-15 17:20:51 +02:00
andri lim d7bd55bd21 fixes opcode call: simplify gas costs 2019-02-15 17:20:51 +02:00
andri lim 44d05dfdb1 fixes transaction_tracer.nim: tracing depth 2019-02-15 17:20:51 +02:00
andri lim 17188dfcb1 fixes memory write: no padding 2019-02-15 17:20:51 +02:00
andri lim e38b1bf803 fixes generateChildComputation 2019-02-15 17:20:51 +02:00
andri lim 5701c8bacb fixes precompile contract: identity gascost 2019-02-15 17:20:51 +02:00
andri lim 00087de2ce trade 7 failed GST with 107 OK GST 2019-02-07 11:01:43 +01:00
andri lim 9efef3829f fixes storage tracer 2019-02-06 18:42:03 +01:00
andri lim a28f06a825 fixes CALL opcode 2019-02-06 18:42:03 +01:00
Yuriy Glukhov 481c6cf4ed Use nim-eth (#224) 2019-02-05 20:15:50 +01:00
Ștefan Talpalaru 7c7260552d
rebase and various fixes
- port to new APIs
- added copyright headers
- bumped the copyright interval in modified files
- fixed tests
- reorganised imports
- normalised function names
- deleted some trailing space
- added test_rpc to all_tests
- assert() -> doAssert()
- moved the RPC port in a constant for the test suite
2019-01-06 20:19:48 +01:00
andri lim b93d809805 fix internal transactions account tracing 2019-01-06 13:17:25 +02:00
andri lim e78fb72ef6 fixes #188 2019-01-06 13:16:45 +02:00
andri lim 8a6d351c22 add internal transactions dump 2019-01-06 11:43:38 +02:00
andri lim b159b5c945 remove lastOpCodeHasRetVal, make it simpler 2019-01-06 11:43:38 +02:00
Ștefan Talpalaru 26ee2fce26 fix breakage with Nim HEAD 2019-01-04 15:39:16 +02:00
andri lim ad1202f98a initial make_receipt 2018-12-16 15:38:51 +02:00
Ștefan Talpalaru f91e69f7c7
more VM tracing
The existing vmState tracing is plugged into chronicles, at the TRACE
level, to facilitate state test debugging.

Some useful chronicles defines are added to "tests/nim.cfg" to simplify
the compile-and-run command for individual tests.
2018-12-12 11:47:10 +01:00
Ștefan Talpalaru 115843487c
general-state testsuite changes and better fork selection
- skipped the tests in allowedFailInCurrentBuild()
- replaced doAssert() with check() in testFixtureIndexes() so we can see
  both hash values on failure
- checking filename extension for JSON tests to avoid editor swap files
- replaced the duplicated block values in the main net's ChainConfig
  with values from forkBlocks
- allowed overriding the current fork in computations, because the old
  strategy of only looking at the block number doesn't work with JSON tests
  where the block number is usually 1
- explicitly pass the fork to gasCosts() and use it for conditional cost
  calculation
- fixed a logic error in the CREATE opcode
- fixed VM selection based on current fork in updateOpcodeExec()
- single point of control for supported forks in tests (just one fork, at the
  moment)
- 44 new test failures (that were probably passing for the wrong reasons)
2018-12-07 18:18:29 +01:00
Ștefan Talpalaru 03ec65487d
logging changes
- port some "echo" logging to "chronicles"
- change the logging level of messages that should not appear by default
  to TRACE instead of DEBUG
- remove the "nimbusTrace" define
- suppress logging for messages below the ERROR level in "nimble test"
2018-12-07 00:45:52 +01:00
coffeepots 86853ea97c
Merge pull request #187 from status-im/modexp-fixes
Modexp fixes
2018-12-06 10:10:59 +00:00
andri lim fe5ddf757b fix trace returnValue 2018-12-05 22:01:29 +07:00
andri lim 572de41507 tracing opcode return value 2018-12-05 22:01:29 +07:00
andri lim 7a3ddfec87 correcting account storage retrieval 2018-12-05 22:01:29 +07:00
andri lim 2552d6452a fix traceTransaction 2018-12-05 22:01:29 +07:00
andri lim 5509c66cce implement transaction tracer 2018-12-05 22:01:28 +07:00
mratsim 24bcb3b2d8 remove log2 spurious comment 2018-12-04 15:56:18 +01:00
mratsim f50bb57eb6 Reactivate the precompiles test + consume gas 2018-12-04 15:52:59 +01:00
mratsim 29f8a8a066 modExp fixed! 2018-12-04 15:46:33 +01:00
mratsim 6d93bdffea modExp, support up to uint4096 2018-12-04 14:39:10 +01:00
mratsim 949c5a1dc6 Modexp fix example 1 (returned to early for ints of length 1) 2018-12-04 12:49:48 +01:00
coffeepots f99138dca6 Merge branch 'call-fixes-precompiles' 2018-11-12 15:57:54 +00:00
coffeepots 1cead76327 Add note about cyclic dep 2018-11-08 16:40:40 +00:00
coffeepots 6eb430fd52 Fix CREATE op code gas costs, more debug output, call transactions 2018-11-08 16:00:21 +00:00
coffeepots 492d2ae676 Debug message for new messages 2018-11-08 15:48:32 +00:00
coffeepots 6b1e989ff0 Add initial gas cost for CREATE 2018-11-08 15:47:48 +00:00
Yuriy Glukhov bac452f589 Initial TransactionTracer impl 2018-10-28 14:38:05 +01:00
coffeepots 7ba1cfaf13 Remove endian code, precompiles should now run. Removed raise as case stmt is full now. 2018-10-19 14:41:04 +01:00
coffeepots 434edcc2ae Fix incorrect message parameters (had sender and destination swapped) 2018-10-18 17:47:54 +01:00
cheatfate 0b15b86195 Fix ecMul, ecPairing, ecAdd. 2018-10-16 11:49:13 +03:00
coffeepots 6e4616e443 Precompiles now executed if called from vm_state_transactions 2018-10-12 16:16:14 +01:00
coffeepots 67df44e917 Fix ecrecover, pad ripemd result and use sha256 vs keccak256 2018-10-10 17:36:11 +01:00
mratsim bb6e1e1d76 modExp precompiles: fix padding and static evaluation 2018-10-10 16:26:21 +02:00
mratsim 0494e2a877 Support short inputs with missing bytes 2018-10-05 17:37:52 +02:00
mratsim 38b4d54815 Add modExp precompile + gas costs 2018-10-05 17:26:20 +02:00
cheatfate 9318ea93cf Added nim-bncurve dependency.
Added implementation of `ecAdd`, `ecMul`, `ecPairing` precompiles.
2018-10-05 12:15:04 +03:00
coffeepots 6a4cd4ec67 Update precompile gas costs case (cosmetic change) 2018-10-03 17:59:41 +01:00
coffeepots 3249c3e048 Add precompile costs 2018-10-03 16:39:34 +01:00
coffeepots 3deb09bbb6 Add SHA256, RIPEMD160 and Identity precompiles 2018-10-03 13:33:19 +01:00
coffeepots fcffd94469 Support different endians 2018-10-02 16:39:01 +01:00
coffeepots 36270ff4d5 Fixes for Call gas usage, Calls use precompiles, pass down their opCode 2018-10-02 16:07:16 +01:00
coffeepots 62968bf733 Initial support for precompiles with ecRecover 2018-10-02 15:46:39 +01:00
Dustin Brody 3f5fc9a034 read through block 49017 by properly setting createAddress/storageAddress of the computation message and detecting whether the computation has the gas required to pay 200*code length; also, clean up pointless commented nonnegativity assertions for nonnegative GasInt type 2018-09-28 10:26:27 +03:00
tersec 690ce2cf97
Partly fix state_db getCode for 20 new working GeneralStateTests (#156)
* partly fix state_db getCode to get 20 new working GeneralStateTests; remove 2 functions which existed as workarounds; switch all remaining setBalance calls in GeneralStateTestRunner to subBalance (addBalance calls already changed)

* two of the 20 new tests don't work in 32-bit builds
2018-09-20 21:36:57 +00:00
Dustin Brody 8f4e1a4445
integrate GeneralStateTest runner into CI with 775 running tests (#153)
* fix 32-bit issue in AppVeyor

* allow another dozen or so GeneralStateTest fixtures which work on 64-bit, but not on 32-bit platforms, to safely-fail, but demarcate them separately to facilitate debugging

* steal fa672600eb from @coffeepots fix-int32-high-zero branch
2018-09-19 16:46:14 +00:00
Yuriy Glukhov 0adfaf0f31 s/increaseBalance/addBalance 2018-09-19 18:41:17 +03:00
coffeepots 766d1c4091 Temp fix for int32.high returning zero 2018-09-19 12:11:54 +03:00
mratsim 070487d78a Homestead contract creation gas cost 2018-09-18 17:28:40 +02:00
Dustin Brody dd20f4079c revert better toSeq version to worse for-loop version of extracting keys from table because former now fails to compile 2018-09-18 07:07:04 -07:00
Dustin Brody 048921b045 20 new working GeneralStateTests 2018-09-18 14:00:30 +00:00
Dustin Brody 7dfd2a3849 update deltabalance to mix of setBalance and increaseBalance 2018-09-18 06:25:28 -07:00
coffeepots 4f03c9cf2a
Merge pull request #139 from status-im/callOpCodeWork
Flesh out call op
2018-09-18 14:09:00 +01:00
coffeepots b49637cdbf Helper procs for updating opcode executor based on fork 2018-09-18 13:10:30 +01:00
coffeepots d435e434ec Copy opCodeExec to child computation 2018-09-18 13:03:22 +01:00
Zahary Karadjov d71ce6fb24 Make use of the new transactional API offered by the Trie DB 2018-09-18 02:56:10 +03:00
coffeepots d484420f5b Remove fork distinguished procs, handle in applyCreateMessage 2018-09-17 19:35:07 +01:00
coffeepots 949d4c11f8 Full names for `$`(fork) 2018-09-17 18:38:10 +01:00
Dustin Brody beb1befc6e 13 additional GeneralStateTests working; remove commented auto-ported Py-EVM validations which are implicit in UInt256; address comments to last commit (toSeq, hoising vmState.readOnlyStateDB, deltaBalance -> increaseBalance) 2018-09-17 13:41:32 +00:00
coffeepots cdfcda41b4 Remove init 0 after child computation 2018-09-14 18:04:09 +01:00
coffeepots 63f9acd8ce Add create and apply message procs 2018-09-14 18:03:26 +01:00
coffeepots c7a014bb10 Add gas cost for create 2018-09-14 17:59:21 +01:00
coffeepots af76d209a6 Add opcode executor proc to computation 2018-09-14 16:47:40 +01:00
coffeepots 6183761251 Refactor for generateChildComputation 2018-09-14 16:16:55 +01:00
coffeepots 2b6342764c Add fork to string proc 2018-09-14 16:16:55 +01:00
coffeepots d465fcd038 Appy child computation in call op code 2018-09-14 16:16:55 +01:00
coffeepots 2a38c0194d Expose isCreate for export 2018-09-14 16:16:55 +01:00
coffeepots 69f07c587a Add generateChildComputation, addChildComputation and applyChildComputation 2018-09-14 16:16:55 +01:00
coffeepots d24108a79b Convert code from byte range to seq 2018-09-14 16:16:55 +01:00
coffeepots b4fd38e062 Call now gets and checks balance against funds, also now fetches code 2018-09-14 16:16:55 +01:00
Dustin Brody 7ba90fda54
48 new working GeneralStateTests, via fixing some overflows/underflows, creating a rudimentary balance commit/revert scheme, and implementing account deletion for the selfdestruct instruction (#146) 2018-09-14 13:43:40 +00:00
Dustin Brody fd07d6fed1 A simple/basic GeneralStateTest runner which gets 400+ of them correct 2018-09-10 19:42:45 +03:00
Yuriy Glukhov 3a1ec035b3 Various fixes towards state reconstruction 2018-09-07 14:00:37 +03:00
coffeepots 085880758b Always update account nonce even if there's an contract address collision 2018-09-06 13:57:42 +01:00