Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-vm

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-vm - npm Package Compare versions

Comparing version 2.2.2 to 2.3.1

lib/precompiled/05-modexp.js

17

CHANGELOG.md

@@ -8,5 +8,14 @@ # Changelog

## [2.3.0] - Unreleased
- TODO
## [2.3.1] - 2017-10-11
- ``Byzantium`` compatible
- New opcodes ``REVERT``, ``RETURNDATA`` and ``STATICCALL``
- Precompiles for curve operations and bigint mod exp
- Transaction return data in receipts
- For detailed list of changes see PR [#161](https://github.com/ethereumjs/ethereumjs-vm/pull/161)
- For a ``Spurious Dragon``/``EIP 150`` compatible version of this library install latest version of ``2.2.x``
[2.3.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/v2.2.2...v2.3.1
## [2.3.0] - Version Skipped due to faulty npm release
## [2.2.2] - 2017-09-19

@@ -20,2 +29,4 @@ - Fixed [JS number issues](https://github.com/ethereumjs/ethereumjs-vm/pull/168)

[2.2.2]: https://github.com/ethereumjs/ethereumjs-vm/compare/v2.2.1...v2.2.2
## [2.2.1] - 2017-08-04

@@ -27,3 +38,3 @@ - Fixed bug prevent the library to be used in the browser

## [2.2.0] - 2017-07-28
- Spurious Dragon & EIP 150 compatible
- ``Spurious Dragon`` & ``EIP 150`` compatible
- Detailed list of changes in pull requests [#147](https://github.com/ethereumjs/ethereumjs-vm/pull/147) and [#143](https://github.com/ethereumjs/ethereumjs-vm/pull/143)

@@ -30,0 +41,0 @@ - Removed ``enableHomestead`` option when creating a [ new VM object](https://github.com/ethereumjs/ethereumjs-vm#new-vmstatetrie-blockchain) (pre-Homestead fork rules not supported any more)

3

examples/run-blockchain/index.js

@@ -113,2 +113,3 @@ const Buffer = require('safe-buffer').Buffer // use for Node.js <4.5.0

async.series([
function (cb2) {

@@ -134,3 +135,3 @@ var keys = Object.keys(acctData.storage)

}
state.put(Buffer.from(key, 'hex'), account.serialize(), function () {
state.put(Buffer.from(utils.stripHexPrefix(key), 'hex'), account.serialize(), function () {
cb2()

@@ -137,0 +138,0 @@ })

{
"blocks": [
{
"blockHeader": {
"bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty": "0x020000",
"extraData": "0x",
"gasLimit": "0x023ec6",
"gasUsed": "0x021536",
"hash": "0xf53f268d23a71e85c7d6d83a9504298712b84c1a2ba220441c86eeda0bf0b6e3",
"mixHash": "0x29f07836e4e59229b3a065913afc27702642c683bba689910b2b2fd45db310d3",
"nonce": "0x8957e6d004a31802",
"number": "0x01",
"parentHash": "0xce1f26f798dd03c8782d63b3e42e79a64eaea5694ea686ac5d7ce3df5171d1ae",
"receiptTrie": "0x5c5b4fc43c2d45787f54e1ae7d27afdb4ad16dfc567c5692070d5c4556e0b1d7",
"stateRoot": "0xa65c2364cd0f1542d761823dc0109c6b072f14c20459598c5455c274601438f4",
"timestamp": "0x56851097",
"transactionsTrie": "0x70616ebd7ad2ed6fb7860cf7e9df00163842351c38a87cac2c1cb193895035a2",
"uncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp": "0xf904a8f901faa0ce1f26f798dd03c8782d63b3e42e79a64eaea5694ea686ac5d7ce3df5171d1aea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0a65c2364cd0f1542d761823dc0109c6b072f14c20459598c5455c274601438f4a070616ebd7ad2ed6fb7860cf7e9df00163842351c38a87cac2c1cb193895035a2a05c5b4fc43c2d45787f54e1ae7d27afdb4ad16dfc567c5692070d5c4556e0b1d7b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000183023ec683021536845685109780a029f07836e4e59229b3a065913afc27702642c683bba689910b2b2fd45db310d3888957e6d004a31802f902a7f85f800a8255f094aaaf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca0575da4e21b66fa764be5f74da9389e67693d066fb0d1312e19e17e501da00ecda06baf5a5327595f6619dfc2fcb3f2e6fb410b5810af3cb52d0e7508038e91a188f85f010a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba04fa966bf34b93abc1bcd665554b7f316b50f928477b50be0f3285ead29d18c5ba017bba0eeec1625ab433746955e125d46d80b7fdc97386c51266f842d8e02192ef85f020a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca004377418ae981cc32b1312b4a427a1d69a821b28db8584f5f2bd8c6d42458adaa053a1dba1af177fac92f3b6af0a9fa46a22adf56e686c93794b6a012bf254abf5f85f030a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ca04fe13febd28a05f4fcb2f451d7ddc2dda56486d9f8c79a62b0ba4da775122615a0651b2382dd402df9ebc27f8cb4b2e0f3cea68dda2dca0ee9603608f0b6f51668f85f040a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba078e6a0ba086a08f8450e208a399bb2f2d2a0d984acd2517c7c7df66ccfab567da013254002cd45a97fac049ae00afbc43ed0d9961d0c56a3b2382c80ce41c198ddf85f050a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba0a7174d8f43ea71c8e3ca9477691add8d80ac8e0ed89d8d8b572041eef81f4a54a0534ea2e28ec4da3b5b944b18c51ec84a5cf35f5b3343c5fb86521fd2d388f506f85f060a82520894bbbf5374fce5edbc8e2a8697c15331677e6ebf0b0a801ba034bd04065833536a10c77ee2a43a5371bc6d34837088b861dd9d4b7f44074b59a078807715786a13876d3455716a6b9cb2186b7a4887a5c31160fc877454958616c0",
"transactions": [
"_info" : {
"comment" : "",
"filledwith" : "cpp-1.3.0+commit.70e7d177.Linux.g++",
"source" : "../../tests/src/BlockchainTestsFiller/bcValidBlockTest/SimpleTxFiller.json"
},
"blocks" : [
{
"data": "0x",
"gasLimit": "0x55f0",
"gasPrice": "0x0a",
"nonce": "0x00",
"r": "0x575da4e21b66fa764be5f74da9389e67693d066fb0d1312e19e17e501da00ecd",
"s": "0x6baf5a5327595f6619dfc2fcb3f2e6fb410b5810af3cb52d0e7508038e91a188",
"to": "0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1c",
"value": "0x0a"
"blockHeader" : {
"bloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x5208",
"hash" : "0x117545e24e3d1e1836bb92e3d6f3e77ac5b2ecd171a535830bf9b5afb8f522e5",
"mixHash" : "0x0a55dc80ced5e71738a5a15e12f63be192a65c5cb257f8ee10c875c9599b5b52",
"nonce" : "0xba58e9414abfa06f",
"number" : "0x01",
"parentHash" : "0x7285abd5b24742f184ad676e31f6054663b3529bc35ea2fcad8a3e0f642a46f7",
"receiptTrie" : "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
"stateRoot" : "0xecc60e00b3fe5ce9f6e1a10e5469764daf51f1fe93c22ec3f9a7583a80357217",
"timestamp" : "0x59af0178",
"transactionsTrie" : "0x53d5b71a8fbb9590de82d69dfa4ac31923b0c8afce0d30d0d8d1e931f25030dc",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90260f901f9a07285abd5b24742f184ad676e31f6054663b3529bc35ea2fcad8a3e0f642a46f7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ecc60e00b3fe5ce9f6e1a10e5469764daf51f1fe93c22ec3f9a7583a80357217a053d5b71a8fbb9590de82d69dfa4ac31923b0c8afce0d30d0d8d1e931f25030dca0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd88252088459af017880a00a55dc80ced5e71738a5a15e12f63be192a65c5cb257f8ee10c875c9599b5b5288ba58e9414abfa06ff861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0f3266921c93d600c43f6fa4724b7abae079b35b9e95df592f95f9f3445e94c88a012f977552ebdb7a492cf35f3106df16ccb4576ebad4113056ee1f52cbe4978c1c0",
"transactions" : [
{
"data" : "",
"gasLimit" : "0xc350",
"gasPrice" : "0x0a",
"nonce" : "0x00",
"r" : "0xf3266921c93d600c43f6fa4724b7abae079b35b9e95df592f95f9f3445e94c88",
"s" : "0x12f977552ebdb7a492cf35f3106df16ccb4576ebad4113056ee1f52cbe4978c1",
"to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "0x1b",
"value" : "0x0a"
}
],
"uncleHeaders" : [
]
}
],
"genesisBlockHeader" : {
"bloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x00",
"hash" : "0x7285abd5b24742f184ad676e31f6054663b3529bc35ea2fcad8a3e0f642a46f7",
"mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"nonce" : "0x0102030405060708",
"number" : "0x00",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "0xcafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421880102030405060708c0c0",
"lastblockhash" : "0x117545e24e3d1e1836bb92e3d6f3e77ac5b2ecd171a535830bf9b5afb8f522e5",
"network" : "Byzantium",
"postState" : {
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0a",
"code" : "",
"nonce" : "0x00",
"storage" : {
}
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x01",
"r": "0x4fa966bf34b93abc1bcd665554b7f316b50f928477b50be0f3285ead29d18c5b",
"s": "0x17bba0eeec1625ab433746955e125d46d80b7fdc97386c51266f842d8e02192e",
"to": "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1b",
"value": "0x0a"
"0x8888f1f195afa192cfee860698584c030f4c9db1" : {
"balance" : "0x29a2241af62f3450",
"code" : "",
"nonce" : "0x00",
"storage" : {
}
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x02",
"r": "0x04377418ae981cc32b1312b4a427a1d69a821b28db8584f5f2bd8c6d42458ada",
"s": "0x53a1dba1af177fac92f3b6af0a9fa46a22adf56e686c93794b6a012bf254abf5",
"to": "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1c",
"value": "0x0a"
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x03",
"r": "0x4fe13febd28a05f4fcb2f451d7ddc2dda56486d9f8c79a62b0ba4da775122615",
"s": "0x651b2382dd402df9ebc27f8cb4b2e0f3cea68dda2dca0ee9603608f0b6f51668",
"to": "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1c",
"value": "0x0a"
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x04",
"r": "0x78e6a0ba086a08f8450e208a399bb2f2d2a0d984acd2517c7c7df66ccfab567d",
"s": "0x13254002cd45a97fac049ae00afbc43ed0d9961d0c56a3b2382c80ce41c198dd",
"to": "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1b",
"value": "0x0a"
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x05",
"r": "0xa7174d8f43ea71c8e3ca9477691add8d80ac8e0ed89d8d8b572041eef81f4a54",
"s": "0x534ea2e28ec4da3b5b944b18c51ec84a5cf35f5b3343c5fb86521fd2d388f506",
"to": "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1b",
"value": "0x0a"
},
{
"data": "0x",
"gasLimit": "0x5208",
"gasPrice": "0x0a",
"nonce": "0x06",
"r": "0x34bd04065833536a10c77ee2a43a5371bc6d34837088b861dd9d4b7f44074b59",
"s": "0x78807715786a13876d3455716a6b9cb2186b7a4887a5c31160fc877454958616",
"to": "0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b",
"v": "0x1b",
"value": "0x0a"
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x025408afa6",
"code" : "",
"nonce" : "0x01",
"storage" : {
}
}
],
"uncleHeaders": []
}
],
"genesisBlockHeader": {
"bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty": "0x020000",
"extraData": "0x42",
"gasLimit": "0x023e38",
"gasUsed": "0x00",
"hash": "0xce1f26f798dd03c8782d63b3e42e79a64eaea5694ea686ac5d7ce3df5171d1ae",
"mixHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"nonce": "0x0102030405060708",
"number": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xaf81e09f8c46ca322193edfda764fa7e88e81923f802f1d325ec0b0308ac2cd0",
"timestamp": "0x54c98c81",
"transactionsTrie": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"genesisRLP": "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0af81e09f8c46ca322193edfda764fa7e88e81923f802f1d325ec0b0308ac2cd0a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008083023e38808454c98c8142a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421880102030405060708c0c0",
"lastblockhash": "0xf53f268d23a71e85c7d6d83a9504298712b84c1a2ba220441c86eeda0bf0b6e3",
"postState": {
"8888f1f195afa192cfee860698584c030f4c9db1": {
"balance": "0x456391824508d41c",
"code": "0x",
"nonce": "0x00",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x4a723dc6b40b8cedf70fa8",
"code": "0x",
"nonce": "0x07",
"storage": {}
},
"bbbf5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x3c",
"code": "0x",
"nonce": "0x00",
"storage": {}
"pre" : {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x02540be400",
"code" : "",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"pre": {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x4a723dc6b40b8a9a000000",
"code": "0x",
"nonce": "0x00",
"storage": {}
},
"aaaf5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x02540be400",
"code": "0x73a94f5374fce5edbc8e2a8697c15331677e6ebf0bff",
"nonce": "0x00",
"storage": {}
}
}
}
}

@@ -6,3 +6,5 @@ exports.ERROR = {

INVALID_JUMP: 'invalid JUMP',
INVALID_OPCODE: 'invalid opcode'
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
STATIC_STATE_CHANGE: 'static state change'
}

@@ -14,2 +14,6 @@ const Buffer = require('safe-buffer').Buffer

const num04 = require('./precompiled/04-identity.js')
const num05 = require('./precompiled/05-modexp.js')
const num06 = require('./precompiled/06-ecadd.js')
const num07 = require('./precompiled/07-ecmul.js')
const num08 = require('./precompiled/08-ecpairing.js')

@@ -50,5 +54,9 @@ module.exports = VM

this._precompiled['0000000000000000000000000000000000000004'] = num04
this._precompiled['0000000000000000000000000000000000000005'] = num05
this._precompiled['0000000000000000000000000000000000000006'] = num06
this._precompiled['0000000000000000000000000000000000000007'] = num07
this._precompiled['0000000000000000000000000000000000000008'] = num08
if (this.opts.activatePrecompiles) {
for (var i = 1; i <= 4; i++) {
for (var i = 1; i <= 7; i++) {
this.trie.put(new BN(i).toArrayLike(Buffer, 'be', 20), new Account().serialize())

@@ -55,0 +63,0 @@ }

@@ -47,2 +47,4 @@ const codes = {

0x3c: ['EXTCODECOPY', 700, 4, 0, true, true],
0x3d: ['RETURNDATASIZE', 2, 0, 1, true],
0x3e: ['RETURNDATACOPY', 3, 3, 0, true],

@@ -151,2 +153,4 @@ // '0x40' range - block operations

0xf4: ['DELEGATECALL', 700, 6, 1, true, true],
0xfa: ['STATICCALL', 700, 6, 1, true, true],
0xfd: ['REVERT', 0, 2, 0, false],

@@ -153,0 +157,0 @@ // '0x70', range - other

@@ -301,2 +301,18 @@ const Buffer = require('safe-buffer').Buffer

},
RETURNDATASIZE: function (runState) {
return utils.intToBuffer(runState.lastReturned.length)
},
RETURNDATACOPY: function (memOffset, returnDataOffset, length, runState) {
memOffset = utils.bufferToInt(memOffset)
returnDataOffset = utils.bufferToInt(returnDataOffset)
length = utils.bufferToInt(length)
if (returnDataOffset + length > runState.lastReturned.length) {
trap(ERROR.OUT_OF_GAS)
}
memStore(runState, memOffset, utils.toBuffer(runState.lastReturned), returnDataOffset, length, false)
// sub the COPY fee
subGas(runState, new BN(fees.copyGas.v).imuln(Math.ceil(length / 32)))
},
GASPRICE: function (runState) {

@@ -365,2 +381,5 @@ return utils.setLengthLeft(runState.gasPrice, 32)

SSTORE: function (key, val, runState, cb) {
if (runState.static) {
trap(ERROR.STATIC_STATE_CHANGE)
}
var stateManager = runState.stateManager

@@ -470,2 +489,6 @@ var address = runState.address

var runState = args.pop()
if (runState.static) {
trap(ERROR.STATIC_STATE_CHANGE)
}
var topics = args.slice(2)

@@ -493,2 +516,6 @@ topics = topics.map(function (a) {

CREATE: function (value, offset, length, runState, done) {
if (runState.static) {
trap(ERROR.STATIC_STATE_CHANGE)
}
value = new BN(value)

@@ -526,2 +553,6 @@ offset = utils.bufferToInt(offset)

if (runState.static && !value.isZero()) {
trap(ERROR.STATIC_STATE_CHANGE)
}
var data = memLoad(runState, inOffset, inLength)

@@ -533,3 +564,4 @@

to: toAddress,
data: data
data: data,
static: runState.static
}

@@ -604,3 +636,4 @@

data: data,
to: runState.address
to: runState.address,
static: runState.static
}

@@ -630,3 +663,3 @@

if (err) return done(err)
if (utils.isPrecompiled(toAddress)) {
if (runState._precompiled[toAddress.toString('hex')]) {
options.compiled = true

@@ -663,3 +696,4 @@ options.code = runState._precompiled[toAddress.toString('hex')]

caller: runState.caller,
delegatecall: true
delegatecall: true,
static: runState.static
}

@@ -680,3 +714,3 @@

if (err) return done(err)
if (utils.isPrecompiled(toAddress)) {
if (runState._precompiled[toAddress.toString('hex')]) {
options.compiled = true

@@ -695,2 +729,53 @@ options.code = runState._precompiled[toAddress.toString('hex')]

},
STATICCALL: function (gasLimit, toAddress, inOffset, inLength, outOffset, outLength, runState, done) {
var stateManager = runState.stateManager
gasLimit = new BN(gasLimit)
toAddress = utils.setLengthLeft(toAddress, 20)
var value = new BN(0)
inOffset = utils.bufferToInt(inOffset)
inLength = utils.bufferToInt(inLength)
outOffset = utils.bufferToInt(outOffset)
outLength = utils.bufferToInt(outLength)
var data = memLoad(runState, inOffset, inLength)
var options = {
gasLimit: gasLimit,
value: value,
to: toAddress,
data: data,
static: true
}
var localOpts = {
inOffset: inOffset,
inLength: inLength,
outOffset: outOffset,
outLength: outLength
}
stateManager.exists(toAddress, function (err, exists) {
if (err) {
done(err)
return
}
stateManager.accountIsEmpty(toAddress, function (err, empty) {
if (err) {
done(err)
return
}
try {
checkCallMemCost(runState, options, localOpts)
checkOutOfGas(runState, options)
} catch (e) {
done(e.error)
return
}
makeCall(runState, options, localOpts, done)
})
})
},
RETURN: function (offset, length, runState) {

@@ -701,4 +786,15 @@ offset = utils.bufferToInt(offset)

},
REVERT: function (offset, length, runState) {
offset = utils.bufferToInt(offset)
length = utils.bufferToInt(length)
runState.stopped = true
runState.returnValue = memLoad(runState, offset, length)
trap(ERROR.REVERT)
},
// '0x70', range - other
SELFDESTRUCT: function (selfdestructToAddress, runState, cb) {
if (runState.static) {
trap(ERROR.STATIC_STATE_CHANGE)
}
var stateManager = runState.stateManager

@@ -885,2 +981,3 @@ var contract = runState.contract

callOptions.populateCache = false
callOptions.static = callOptions.static || false
callOptions.selfdestruct = runState.selfdestruct

@@ -891,2 +988,5 @@

// empty the return data buffer
runState.lastReturned = new Buffer([])
// check if account has enough ether

@@ -923,8 +1023,21 @@ // Note: in the case of delegatecall, the value is persisted and doesn't need to be deducted again

if (!results.vm.exceptionError) {
// save results to memory
if (results.vm.return) {
memStore(runState, localOpts.outOffset, results.vm.return, 0, localOpts.outLength, false)
// save results to memory
if (results.vm.return && (!results.vm.exceptionError || results.vm.exceptionError === ERROR.REVERT)) {
memStore(runState, localOpts.outOffset, results.vm.return, 0, localOpts.outLength, false)
if (results.vm.exceptionError === ERROR.REVERT && runState.opName === 'CREATE') {
runState.lastReturned = results.vm.return
}
switch (runState.opName) {
case 'CALL':
case 'CALLCODE':
case 'DELEGATECALL':
case 'STATICCALL':
runState.lastReturned = results.vm.return
break
}
}
if (!results.vm.exceptionError) {
// update stateRoot on current contract

@@ -931,0 +1044,0 @@ runState.stateManager.getAccount(runState.address, function (err, account) {

@@ -11,4 +11,2 @@ const Buffer = require('safe-buffer').Buffer

const minerReward = new BN(common.minerReward.v)
const niblingReward = new BN(common.niblingReward.v)
const ommerReward = new BN(common.ommerReward.v)

@@ -102,2 +100,3 @@ /**

txResults.push(result)
// var receiptResult = new BN(1)

@@ -120,4 +119,5 @@ // abort if error

var txLogs = result.vm.logs || []
var rawTxReceipt = [
self.trie.root,
result.vm.exception ? 1 : 0, // result.vm.exception is 0 when an exception occurs, and 1 when it doesn't. TODO make this the opposite
gasUsed.toArrayLike(Buffer),

@@ -128,3 +128,3 @@ result.bloom.bitvector,

var txReceipt = {
stateRoot: rawTxReceipt[0],
status: rawTxReceipt[0],
gasUsed: rawTxReceipt[1],

@@ -194,3 +194,5 @@ bitvector: rawTxReceipt[2],

ommers.forEach(rewardOmmer)
// calculate nibling reward
var niblingReward = minerReward.div(new BN(32))
var totalNiblingReward = niblingReward.mul(new BN(ommers.length))

@@ -209,3 +211,8 @@ minerAccount = self.stateManager.cache.get(block.header.coinbase)

var heightDiff = new BN(block.header.number).sub(new BN(ommer.number))
var reward = minerReward.sub(ommerReward.mul(heightDiff))
var reward = ((new BN(8)).sub(heightDiff)).mul(minerReward.div(new BN(8)))
if (reward.lt(new BN(0))) {
reward = new BN(0)
}
// credit miners account

@@ -212,0 +219,0 @@ var ommerAccount = self.stateManager.cache.get(ommer.coinbase)

@@ -48,2 +48,3 @@ const Buffer = require('safe-buffer').Buffer

var delegatecall = opts.delegatecall || false
var isStatic = opts.static || false

@@ -107,3 +108,3 @@ txValue = new BN(txValue)

// loads the contract's code if the account is a contract
if (code || !(toAccount.isContract() || ethUtil.isPrecompiled(toAddress))) {
if (code || !(toAccount.isContract() || self._precompiled[toAddress.toString('hex')])) {
cb()

@@ -113,3 +114,3 @@ return

if (ethUtil.isPrecompiled(toAddress)) {
if (self._precompiled[toAddress.toString('hex')]) {
isCompiled = true

@@ -148,3 +149,4 @@ code = self._precompiled[toAddress.toString('hex')]

selfdestruct: selfdestruct,
populateCache: false
populateCache: false,
static: isStatic
}

@@ -162,4 +164,7 @@

// fee for size of the return value
var returnFee = results.return.length * fees.createDataGas.v
var totalGas = results.gasUsed.addn(returnFee)
var totalGas = results.gasUsed
if (!results.runState.vmError) {
var returnFee = results.return.length * fees.createDataGas.v
totalGas = totalGas.addn(returnFee)
}
// if not enough gas

@@ -189,3 +194,3 @@ if (totalGas.lte(gasLimit) && results.return.length <= 24576) {

// store code for a new contract
if (createdAddress && vmResults.return.toString() !== '') {
if (createdAddress && !vmResults.runState.vmError && vmResults.return.toString() !== '') {
stateManager.putContractCode(createdAddress, vmResults.return, cb)

@@ -192,0 +197,0 @@ } else {

@@ -61,2 +61,3 @@ /*

stack: [],
lastReturned: [],
logs: [],

@@ -76,3 +77,4 @@ validJumps: [],

code: opts.code,
populateCache: opts.populateCache === undefined ? true : opts.populateCache
populateCache: opts.populateCache === undefined ? true : opts.populateCache,
static: opts.static || false
}

@@ -242,3 +244,3 @@

if (err) {
if (err && err !== ERROR.REVERT) {
results.gasUsed = runState.gasLimit

@@ -245,0 +247,0 @@ } else {

{
"name": "ethereumjs-vm",
"version": "2.2.2",
"version": "2.3.1",
"description": "an ethereum VM implementation",

@@ -9,5 +9,5 @@ "main": "index.js",

"async-eventemitter": "^0.2.2",
"ethereum-common": "0.1.0",
"ethereum-common": "0.2.0",
"ethereumjs-account": "^2.0.3",
"ethereumjs-block": "~1.6.0",
"ethereumjs-block": "~1.7.0",
"ethereumjs-util": "4.5.0",

@@ -17,2 +17,3 @@ "fake-merkle-patricia-tree": "^1.0.1",

"merkle-patricia-tree": "^2.1.2",
"rustbn.js": "~0.1.0",
"safe-buffer": "^5.1.1"

@@ -23,3 +24,3 @@ },

"babelify": "^7.3.0",
"ethereumjs-blockchain": "~2.0.0",
"ethereumjs-blockchain": "~2.1.0",
"ethereumjs-testing": "https://github.com/ethereumjs/ethereumjs-testing",

@@ -33,3 +34,3 @@ "ethereumjs-tx": "1.3.3",

"standard": "^10.0.0",
"tape": "^4.2.0"
"tape": "4.6.3"
},

@@ -36,0 +37,0 @@ "browserify": {

@@ -11,2 +11,12 @@ # SYNOPSIS

#### Note on Byzantium Support:
The ``master`` branch of this repository has now been updated with the latest
[Byzantium changes](https://github.com/ethereumjs/ethereumjs-vm/pull/161) please install
directly from GitHub if you want to try out the latest ``VM`` version and report
issues on our [Gitter channel](https://gitter.im/ethereum/ethereumjs-lib).
For a ``Spurious Dragon``/``EIP 150`` compatible version of this library install the
latest of the ``2.2.x`` series (see [Changelog](./CHANGELOG.md)).
# INSTALL

@@ -230,2 +240,19 @@ `npm install ethereumjs-vm`

Only run test cases with selected ``data``, ``gas`` and/or ``value`` values (see
[attribute description](http://ethereum-tests.readthedocs.io/en/latest/test_types/state_tests.html) in
test docs), provided by the index of the array element in the test ``transaction`` section:
`node tests/tester -s --test='CreateCollisionToEmpty' --data=0 --gas=1 --value=0`
Compare TAP output from blockchain/state tests and produces concise diff of the differences between them (example):
```
curl https://gist.githubusercontent.com/jwasinger/6cef66711b5e0787667ceb3db6bea0dc/raw/0740f03b4ce90d0955d5aba1e0c30ce698c7145a/gistfile1.txt > output-wip-byzantium.txt
curl https://gist.githubusercontent.com/jwasinger/e7004e82426ff0a7137a88d273f11819/raw/66fbd58722747ebe4f7006cee59bbe22461df8eb/gistfile1.txt > output-master.txt
python utils/diffTestOutput.py output-wip-byzantium.txt output-master.txt
```
Run a state test from a specified source file not under the ``tests`` directory:
`node ./tests/tester -s --customStateTest='{path_to_file}'`
For a wider picture about how to use tests to implement EIPs you can have a look at this [reddit post](https://www.reddit.com/r/ethereum/comments/6kc5g3/ethereumjs_team_is_seeking_contributors/)

@@ -232,0 +259,0 @@ or the associated YouTube video introduction to [core development with Ethereumjs-vm](https://www.youtube.com/watch?v=L0BVDl6HZzk&feature=youtu.be).

@@ -8,6 +8,18 @@ const async = require('async')

function parseTestCases (forkConfig, testData) {
const testCases = testData['post'][forkConfig].map(testCase => {
function parseTestCases (forkConfig, testData, data, gasLimit, value) {
let testCases = testData['post'][forkConfig].map(testCase => {
let testIndexes = testCase['indexes']
let tx = Object.assign({}, testData.transaction)
if (data !== undefined && testIndexes['data'] !== data) {
return null
}
if (value !== undefined && testIndexes['value'] !== value) {
return null
}
if (gasLimit !== undefined && testIndexes['gas'] !== gasLimit) {
return null
}
tx.data = testData.transaction.data[testIndexes['data']]

@@ -24,2 +36,6 @@ tx.gasLimit = testData.transaction.gasLimit[testIndexes['gas']]

testCases = testCases.filter(testCase => {
return testCase != null
})
return testCases

@@ -99,3 +115,3 @@ }

module.exports = function runStateTest (options, testData, t, cb) {
const testCases = parseTestCases(options.forkConfig, testData)
const testCases = parseTestCases(options.forkConfig, testData, options.data, options.gasLimit, options.value)
async.eachSeries(testCases,

@@ -102,0 +118,0 @@ (testCase, done) => runTestCase(options, testCase, t, done),

@@ -5,3 +5,3 @@ const argv = require('minimist')(process.argv.slice(2))

const testing = require('ethereumjs-testing')
const FORK_CONFIG = argv.fork || 'EIP158'
const FORK_CONFIG = argv.fork || 'Byzantium'
const skip = [

@@ -25,2 +25,10 @@ 'CreateHashCollision', // impossible hash collision on generating address

'Call50000bytesContract50_2',
'Call1MB1024Calldepth', // slow
'static_Call1MB1024Calldepth', // slow
'static_Call50000', // slow
'static_Call50000_ecrec',
'static_Call50000_identity',
'static_Call50000_identity2',
'static_Call50000_rip160',
'static_Return50000_2',
'Callcode50000', // slow

@@ -36,6 +44,42 @@ 'Return50000', // slow

'CREATE_Bounds', // nodejs crash
'CreateCollisionToEmpty', // temporary till fixed (2017-09-21)
'TransactionCollisionToEmptyButCode', // temporary till fixed (2017-09-21)
'TransactionCollisionToEmptyButNonce', // temporary till fixed (2017-09-21)
'randomStatetest642', // temporary till fixed (2017-09-25)
'DELEGATECALL_Bounds', // nodejs crash
'RevertDepthCreateAddressCollision', // test case is wrong
'zeroSigTransactionInvChainID', // metropolis test
'randomStatetest643'
'randomStatetest643',
'static_CreateHashCollision', // impossible hash collision on generating address
'static_SuicidesMixingCoinbase', // sucides to the coinbase, since we run a blockLevel we create coinbase account.
'static_TransactionMakeAccountBalanceOverflow',
'static_RecursiveCreateContracts',
'static_sha3_bigSize',
'static_createJS_ExampleContract', // creates an account that already exsists
'static_mload32bitBound_return',
'static_mload32bitBound_return2',
'static_QuadraticComplexitySolidity_CallDataCopy', // tests hash collisoin, sending from a contract
'static_Call50000', // slow
'static_Call50000_ecrec', // slow
'static_Call50000_identity', // slow
'static_Call50000_identity2', // slow
'static_Call50000_sha256', // slow
'static_Call50000_rip160', // slow
'static_Call50000bytesContract50_1', // slow
'static_Call50000bytesContract50_2',
'static_Call1MB1024Calldepth', // slow
'static_Callcode50000', // slow
'static_Return50000', // slow
'static_Return50000_2', // slow
'static_uncleBlockAtBlock3AfterBlock3',
'static_ForkUncle', // correct behaviour unspecified (?)
'static_UncleFromSideChain', // same as ForkUncle, the TD is the same for two diffent branches so its not clear which one should be the finally chain
'static_bcSimpleTransitionTest', // HF stuff
'static_CALL_Bounds', // nodejs crash
'static_CALLCODE_Bounds', // nodejs crash
'static_CREATE_Bounds', // nodejs crash
'static_DELEGATECALL_Bounds', // nodejs crash
'static_RevertDepthCreateAddressCollision', // test case is wrong
'static_zeroSigTransactionInvChainID', // metropolis test
'zeroSigTransactionInvChainID' // metropolis test
]

@@ -147,26 +191,51 @@

testGetterArgs.customStateTest = argv.customStateTest
runnerArgs.forkConfig = FORK_CONFIG
runnerArgs.jsontrace = argv.jsontrace
runnerArgs.debug = argv.debug // for BlockchainTests
// for GeneralStateTests
runnerArgs.data = argv.data
runnerArgs.gasLimit = argv.gas
runnerArgs.value = argv.value
// runnerArgs.vmtrace = true; // for VMTests
tape(name, t => {
const runner = require(`./${name}Runner.js`)
testing.getTestsFromArgs(name, (fileName, testName, test) => {
return new Promise((resolve, reject) => {
if (name === 'VMTests') {
// suppress some output of VMTests
// t.comment(`file: ${fileName} test: ${testName}`)
test.fileName = fileName
test.testName = testName
runner(runnerArgs, test, t, resolve)
} else {
t.comment(`file: ${fileName} test: ${testName}`)
runner(runnerArgs, test, t, resolve)
if (argv.customStateTest) {
const stateTestRunner = require('./GeneralStateTestsRunner.js')
let fileName = argv.customStateTest
tape(name, t => {
testing.getTestFromSource(fileName, (err, test) => {
if (err) {
return t.fail(err)
}
}).catch(err => console.log(err))
}, testGetterArgs).then(() => {
t.end()
t.comment(`file: ${fileName} test: ${test.testName}`)
stateTestRunner(runnerArgs, test, t, () => {
t.end()
})
})
})
})
} else {
tape(name, t => {
const runner = require(`./${name}Runner.js`)
testing.getTestsFromArgs(name, (fileName, testName, test) => {
return new Promise((resolve, reject) => {
if (name === 'VMTests') {
// suppress some output of VMTests
// t.comment(`file: ${fileName} test: ${testName}`)
test.fileName = fileName
test.testName = testName
runner(runnerArgs, test, t, resolve)
} else {
t.comment(`file: ${fileName} test: ${testName}`)
runner(runnerArgs, test, t, resolve)
}
}).catch(err => console.log(err))
}, testGetterArgs).then(() => {
t.end()
})
})
}
}

@@ -173,0 +242,0 @@

@@ -86,3 +86,3 @@ const async = require('async')

var q = async.queue(function (task, cb2) {
exports.verifyAccountPostConditions(state, task.account, task.testData, t, cb2)
exports.verifyAccountPostConditions(state, task.address, task.account, task.testData, t, cb2)
}, 1)

@@ -96,2 +96,3 @@

var testData = hashedAccounts[key]
var address = keyMap[key]
delete keyMap[key]

@@ -101,2 +102,3 @@

q.push({
address: address,
account: acnt,

@@ -129,2 +131,3 @@ testData: testData

* @param {[type]} state DB/trie
* @param {[type]} string Account Address
* @param {[type]} account to verify

@@ -134,3 +137,4 @@ * @param {[type]} acctData postconditions JSON from tests repo

*/
exports.verifyAccountPostConditions = function (state, account, acctData, t, cb) {
exports.verifyAccountPostConditions = function (state, address, account, acctData, t, cb) {
t.comment('Account: ' + address)
t.equal(format(account.balance, true).toString('hex'), format(acctData.balance, true).toString('hex'), 'correct balance')

@@ -137,0 +141,0 @@ t.equal(format(account.nonce, true).toString('hex'), format(acctData.nonce, true).toString('hex'), 'correct nonce')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc