diff --git a/README.md b/README.md index f92d2b06e3..de81ca132d 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,13 @@ This monorepo uses [Lerna](https://lerna.js.org/). It links the local packages t TLDR: Setup ```sh npm install -npm build +npm run build ``` TLDR: To update dependencies and (re-)link packages ```sh npm run bootstrap -npm build +npm run build ``` Above is the quickest way to set you up. Going down the road, there are two sets of commands: *project* and *package-specific* commands. You can find them at `./package.json` and `./packages/*/package.json`, respectively. Here's a breakdown: diff --git a/packages/block/CHANGELOG.md b/packages/block/CHANGELOG.md index 2be7fee73c..2f20a16bd4 100644 --- a/packages/block/CHANGELOG.md +++ b/packages/block/CHANGELOG.md @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 3.0.0-beta.2 - UNRELEASED +## 3.0.0-beta.2 - 2020-11-12 + +This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.1) for an overview on the full changes since the last publicly released version. - Added `freeze` option to allow for block freeze deactivation (e.g. to allow for subclassing block and adding additional parameters), see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941) - **Breaking:** Difficulty-depending methods `canonicalDifficulty()` and `validateDifficulty()` in block and header now throw on non-PoW chains, see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937) diff --git a/packages/block/README.md b/packages/block/README.md index abe31600b4..6e6ebfee9d 100644 --- a/packages/block/README.md +++ b/packages/block/README.md @@ -8,13 +8,45 @@ Implements schema and functions related to Ethereum's block. +Note: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-block) for an introduction on the last preceeding release. + # INSTALL `npm install @ethereumjs/block` -# BROWSER +# USAGE + +There are three static factories to instantiate a `Block` or `BlockHeader`: + +- `Block.fromBlockData(blockData: BlockData = {}, opts?: BlockOptions)` +- `Block.fromRLPSerializedBlock(serialized: Buffer, opts?: BlockOptions)` +- `Block.fromValuesArray(values: BlockBuffer, opts?: BlockOptions)` + +Instantiation Example: + +```typescript +const headerData = { + number: 15, + parentHash: '0x6bfee7294bf44572b7266358e627f3c35105e1c3851f3de09e6d646f955725a7', + difficulty: 131072, + gasLimit: 8000000, + timestamp: 1562422144, +} +const header = BlockHeader.fromHeaderData(headerData) +``` + +Properties of a `Block` or `BlockHeader` object are frozen with `Object.freeze()` which gives you enhanced security and consistency properties when working with the instantiated object. This behavior can be modified using the `freeze` option in the constructor if needed. + +API Usage Example: -This module works with `browserify`. +```typescript +try { + await block.validate(blockchain) + // Block validation has passed +} catch (err) { + // handle errors appropriately +} +``` # API diff --git a/packages/block/package.json b/packages/block/package.json index 47deb88c5d..953c85ea18 100644 --- a/packages/block/package.json +++ b/packages/block/package.json @@ -1,6 +1,6 @@ { "name": "@ethereumjs/block", - "version": "3.0.0-beta.1", + "version": "3.0.0-beta.2", "description": "Provides Block serialization and help functions", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -39,8 +39,8 @@ }, "homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/block#synopsis", "dependencies": { - "@ethereumjs/common": "2.0.0-beta.1", - "@ethereumjs/tx": "3.0.0-beta.1", + "@ethereumjs/common": "2.0.0-beta.2", + "@ethereumjs/tx": "3.0.0-beta.2", "@types/bn.js": "^4.11.6", "ethereumjs-util": "^7.0.7", "merkle-patricia-tree": "^4.0.0" diff --git a/packages/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index 5cc078f74e..63a24c5753 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -6,9 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 5.0.0-beta.2 - UNRELEASED +## 5.0.0-beta.2 - 2020-11-12 -This is the second beta release towards a final `v5.0.0` `Blockchain` library release, see [v5.0.0-beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.1) for an overview on the full changes since the last publicly released version. +This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.1) for an overview on the full changes since the last publicly released version. This release introduces **new breaking changes**, so please carefully read the additional release note sections! @@ -122,8 +122,6 @@ in performance benefits for Node.js consumers, see [here](https://github.com/eth - Fixed blockchain hanging forever in case code throws between a semaphore `lock`/`unlock`, Issue [#877](https://github.com/ethereumjs/ethereumjs-vm/issues/877) -[5.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblockchain%404.0.2...%40ethereumjs%2Fblockchain%405.0.0 - ## 4.0.4 - 2020-07-27 This release replaces the tilde (`~`) dependency from `ethereumjs-util` for a caret (`^`) one, meaning that any update to `ethereumjs-util` v6 will also be available for this library. diff --git a/packages/blockchain/README.md b/packages/blockchain/README.md index 8d65eb82b2..7ef585baea 100644 --- a/packages/blockchain/README.md +++ b/packages/blockchain/README.md @@ -8,15 +8,13 @@ A module to store and interact with blocks. -# INSTALL - -`npm install ethereumjs-blockchain` +Note: this `README` reflects the state of the library from `v5.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-blockchain) for an introduction on the last preceeding release. -# API +# INSTALL -[Documentation](./docs/README.md) +`npm install @ethereumjs/blockchain` -# EXAMPLE +# USAGE The following is an example to iterate through an existing Geth DB (needs `level` to be installed separately). @@ -29,8 +27,10 @@ const level = require('level') const gethDbPath = './chaindata' // Add your own path here. It will get modified, see remarks. +const common = new Common({ chain: 'ropsten' }) const db = level(gethDbPath) -const blockchain = new Blockchain({ db }) +// Use the safe static constructor which awaits the init method +const blockchain = Blockchain.create({ common, db }) blockchain.iterator('i', (block) => { const blockNumber = block.header.number.toString() @@ -41,6 +41,10 @@ blockchain.iterator('i', (block) => { **WARNING**: Since `@ethereumjs/blockchain` is also doing write operations on the DB for safety reasons only run this on a copy of your database, otherwise this might lead to a compromised DB state. +# API + +[Documentation](./docs/README.md) + # EthereumJS See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index c212222f68..0e75e1d654 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -1,6 +1,6 @@ { "name": "@ethereumjs/blockchain", - "version": "5.0.0-beta.1", + "version": "5.0.0-beta.2", "description": "A module to store and interact with blocks", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -36,8 +36,8 @@ }, "homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#synopsis", "dependencies": { - "@ethereumjs/block": "3.0.0-beta.1", - "@ethereumjs/common": "2.0.0-beta.1", + "@ethereumjs/block": "3.0.0-beta.2", + "@ethereumjs/common": "2.0.0-beta.2", "@ethereumjs/ethash": "1.0.0-beta.1", "ethereumjs-util": "^7.0.7", "level-mem": "^5.0.1", diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 0c18b82632..354bbeda83 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 2.0.0-beta.2 - UNRELEASED +## 2.0.0-beta.2 - 2020-11-12 + +This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fcommon%402.0.0-beta.1) for an overview on the full changes since the last publicly released version. - Added consensus information to chains, new functions `Common.consensusType()` for consensus type access ("pow" or "poa") and `Common.consensusAlgorithm()` to get the associated algorithm or protocol (e.g. "ethash" PoW algorithm or "clique" PoA protocol), see PR [#937](https://github.com/ethereumjs/ethereumjs-vm/pull/937) diff --git a/packages/common/README.md b/packages/common/README.md index 194b387ac3..fbcaa32cab 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -8,7 +8,7 @@ Resources common to all Ethereum implementations. -Succeeds the old [ethereum/common](https://github.com/ethereumjs/common/) library. +Note: this `README` reflects the state of the library from `v2.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-common) for an introduction on the last preceeding release. # INSTALL @@ -20,19 +20,26 @@ All parameters can be accessed through the `Common` class which can be required main package and instantiated either with just the `chain` (e.g. 'mainnet') or the `chain` together with a specific `hardfork` provided. +If no hardfork is provided the common is initialized with the default hardfork. + +Current `DEFAULT_HARDFORK`: `istanbul` + Here are some simple usage examples: -```javascript -const Common = require('@ethereumjs/common') +```typescript +import Common from '@ethereumjs/common' -// Instantiate with only the chain -let c = new Common({ chain: 'ropsten' }) -c.param('gasPrices', 'ecAddGas', 'byzantium') // 500 +// Instantiate with the chain (and the default hardfork) +const c = new Common({ chain: 'ropsten' }) +c.param('gasPrices', 'ecAddGas') // 500 // Chain and hardfork provided c = new Common({ chain: 'ropsten', hardfork: 'byzantium' }) c.param('pow', 'minerReward') // 3000000000000000000 +// Instantiate with an EIP activated +const c = new Common({ chain: 'mainnet', eips: [2537] }) + // Access genesis data for Ropsten network c.genesis().hash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d @@ -40,10 +47,9 @@ c.genesis().hash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1 c.bootstrapNodes() // Array with current nodes ``` -It is encouraged to also explicitly set the `supportedHardforks` if the initializing library -only supports a certain range of `hardforks`: +If the initializing library only supports a certain range of `hardforks` you can use the `supportedHardforks` option to restrict hardfork access on the `Common` instance: -```javascript +```typescript let c = new Common({ chain: 'ropsten', supportedHardforks: ['byzantium', 'constantinople', 'petersburg'], @@ -77,13 +83,16 @@ library supported: - `byzantium` - `constantinople` - `petersburg` (aka `constantinopleFix`, apply together with `constantinople`) -- `istanbul` (`DEFAULT_HARDFORK`) -- `muirGlacier` +- `istanbul` (`DEFAULT_HARDFORK` (`v2.0.0` release series)) +- `muirGlacier` (since `v1.5.0`) ## Future Hardforks -The `muirGlacier` HF delaying the difficulty bomb and scheduled for January 2020 -is supported by the library since `v1.5.0`. +General support for the `berlin` hardfork has been added along `v2.0.0`, specification of the hardfork regarding EIPs included was not finalized upon release date. + +Currently supported `berlin` EIPs: + +- `EIP-2315` ## Parameter Access @@ -102,9 +111,6 @@ hardfork. The hardfork-specific json files only contain the deltas from `chainstart` and shouldn't be accessed directly until you have a specific reason for it. -Note: The list of `gasPrices` and gas price changes on hardforks is consistent -but not complete, so there are currently gas price values missing (PRs welcome!). - # Chain Params Supported chains: @@ -113,7 +119,7 @@ Supported chains: - `ropsten` - `rinkeby` - `kovan` -- `goerli` (final configuration since `v1.1.0`) +- `goerli` - Private/custom chain parameters The following chain-specific parameters are provided: @@ -121,6 +127,8 @@ The following chain-specific parameters are provided: - `name` - `chainId` - `networkId` +- `consensusType` (e.g. `pow` or `poa`) +- `consensusAlgorithm` (e.g. `ethash` or `clique`) - `genesis` block header values - `hardforks` block numbers - `bootstrapNodes` list diff --git a/packages/common/docs/classes/_index_.common.md b/packages/common/docs/classes/_index_.common.md index 43451c6899..a839443f46 100644 --- a/packages/common/docs/classes/_index_.common.md +++ b/packages/common/docs/classes/_index_.common.md @@ -30,6 +30,8 @@ Common class to access chain and hardfork parameters * [bootstrapNodes](_index_.common.md#bootstrapnodes) * [chainId](_index_.common.md#chainid) * [chainName](_index_.common.md#chainname) +* [consensusAlgorithm](_index_.common.md#consensusalgorithm) +* [consensusType](_index_.common.md#consensustype) * [eips](_index_.common.md#eips) * [forkHash](_index_.common.md#forkhash) * [genesis](_index_.common.md#genesis) @@ -269,6 +271,34 @@ chain name (lower case) ___ +### consensusAlgorithm + +▸ **consensusAlgorithm**(): *string* + +*Defined in [index.ts:649](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L649)* + +Returns the concrete consensus implementation +algorithm or protocol for the network +e.g. "ethash" for "pow" consensus type or +"clique" for "poa" consensus type + +**Returns:** *string* + +___ + +### consensusType + +▸ **consensusType**(): *string* + +*Defined in [index.ts:639](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L639)* + +Returns the consensus type of the network +Possible values: "pow"|"poa" + +**Returns:** *string* + +___ + ### eips ▸ **eips**(): *number[]* @@ -338,13 +368,13 @@ ___ ### hardfork -▸ **hardfork**(): *string | null* +▸ **hardfork**(): *string* *Defined in [index.ts:599](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L599)* Returns the hardfork set -**Returns:** *string | null* +**Returns:** *string* Hardfork name diff --git a/packages/common/package.json b/packages/common/package.json index 215b301eed..85178cd44f 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@ethereumjs/common", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.2", "description": "Resources common to all Ethereum implementations", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index c9c9ca37c7..f89b0cbe2a 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -596,7 +596,7 @@ export default class Common { * Returns the hardfork set * @returns Hardfork name */ - hardfork(): string | null { + hardfork(): string { return this._hardfork } diff --git a/packages/ethash/README.md b/packages/ethash/README.md index 2634739529..26e013c366 100644 --- a/packages/ethash/README.md +++ b/packages/ethash/README.md @@ -8,15 +8,17 @@ Implements [Ethash](https://github.com/ethereum/wiki/wiki/Ethash). +Note: this `README` reflects the state of the library from `v1.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethashjs) for an introduction on the last preceeding release. + # INSTALL -`npm install ethashjs` +`npm install @ethereumjs/ethash` # USAGE -```javascript -const Ethash = require('@ethereumjs/ethash') -const Block = require('@ethereumjs/block') +```typescript +import Ethash from '@ethereumjs/ethash' +import { Block } from '@ethereumjs/block' const level = require('level-mem') const cacheDB = level() @@ -25,7 +27,7 @@ const ethash = new Ethash(cacheDB) const validblockRlp = 'f90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910111213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0' -const validBlock = new Block(Buffer.from(validblockRlp, 'hex')) +const validBlock = Block.fromRLPSerializedBlock(Buffer.from(validblockRlp, 'hex')) const result = await ethash.verifyPOW(validBlock) console.log(result) // => true diff --git a/packages/ethash/package.json b/packages/ethash/package.json index 580988b9ba..71f0a47239 100644 --- a/packages/ethash/package.json +++ b/packages/ethash/package.json @@ -40,7 +40,7 @@ "miller-rabin": "^4.0.0" }, "devDependencies": { - "@ethereumjs/block": "3.0.0-beta.1", + "@ethereumjs/block": "3.0.0-beta.2", "@ethereumjs/config-coverage": "^2.0.0", "@ethereumjs/config-typescript": "^2.0.0", "@ethereumjs/eslint-config-defaults": "^2.0.0", diff --git a/packages/tx/CHANGELOG.md b/packages/tx/CHANGELOG.md index 89b3a331f4..73ab7c0085 100644 --- a/packages/tx/CHANGELOG.md +++ b/packages/tx/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 3.0.0-beta.2 - UNRELEASED +## 3.0.0-beta.2 - 2020-11-12 - Added `freeze` option to allow for transaction freeze deactivation (e.g. to allow for subclassing tx and adding additional parameters), see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941) - **Breaking:** Reworked constructor to take in data as a `TxData` typed dictionary instead of single values, the `Tx.fromTxData()` factory method becomes an alias for the constructor with this change, see PR [#944](https://github.com/ethereumjs/ethereumjs-vm/pull/944) diff --git a/packages/tx/README.md b/packages/tx/README.md index 3808afdd54..e8535347e2 100644 --- a/packages/tx/README.md +++ b/packages/tx/README.md @@ -6,6 +6,8 @@ [![Code Coverage][tx-coverage-badge]][tx-coverage-link] [![Discord][discord-badge]][discord-link] +Note: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-tx) for an introduction on the last preceeding release. + # INSTALL `npm install @ethereumjs/tx` @@ -26,7 +28,7 @@ const txParams = { data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', } -const commmon = new Common({ chain: 'mainnet', hardfork: 'petersburg' }) +const commmon = new Common({ chain: 'mainnet' }) const tx = Transaction.fromTxData(txParams, { common }) const privateKey = Buffer.from( @@ -39,6 +41,8 @@ const signedTx = tx.sign(privateKey) const serializedTx = signedTx.serialize() ``` +Properties of a `Transaction` object are frozen with `Object.freeze()` which gives you enhanced security and consistency properties when working with the instantiated object. This behavior can be modified using the `freeze` option in the constructor if needed. + ## Fake Transaction Creating a fake tansaction for use in e.g. `VM.runTx()` is simple, just overwrite `getSenderAddress()` with a custom [`Address`](https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/classes/_address_.address.md) like so: @@ -63,7 +67,7 @@ _getFakeTransaction(txParams: TxParams): Transaction { # Chain and Hardfork Support -The `Transaction` constructor receives a parameter of an [`@ethereumjs/common`](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common) object that lets you specify the chain and hardfork to be used. By default, `mainnet` and `petersburg` will be used. +The `Transaction` constructor receives a parameter of an [`@ethereumjs/common`](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common) object that lets you specify the chain and hardfork to be used. By default, `mainnet` and `istanbul` will be used. ## MuirGlacier Support diff --git a/packages/tx/docs/classes/_index_.transaction.md b/packages/tx/docs/classes/_index_.transaction.md index 34bfa54cc6..0c4d7bc2ea 100644 --- a/packages/tx/docs/classes/_index_.transaction.md +++ b/packages/tx/docs/classes/_index_.transaction.md @@ -54,9 +54,9 @@ An Ethereum transaction. ### constructor -\+ **new Transaction**(`nonce`: BN, `gasPrice`: BN, `gasLimit`: BN, `to`: Address | undefined, `value`: BN, `data`: Buffer, `v?`: BN, `r?`: BN, `s?`: BN, `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)* +\+ **new Transaction**(`txData`: [TxData](../interfaces/_index_.txdata.md), `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)* -*Defined in [transaction.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L87)* +*Defined in [transaction.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L76)* This constructor takes the values, validates them, assigns them and freezes the object. Use the static factory methods to assist in creating a Transaction object from varying data types. @@ -67,15 +67,7 @@ Use the static factory methods to assist in creating a Transaction object from v Name | Type | ------ | ------ | -`nonce` | BN | -`gasPrice` | BN | -`gasLimit` | BN | -`to` | Address | undefined | -`value` | BN | -`data` | Buffer | -`v?` | BN | -`r?` | BN | -`s?` | BN | +`txData` | [TxData](../interfaces/_index_.txdata.md) | `opts?` | [TxOptions](../interfaces/_index_.txoptions.md) | **Returns:** *[Transaction](_index_.transaction.md)* @@ -166,7 +158,7 @@ ___ ▸ **getBaseFee**(): *BN* -*Defined in [transaction.ts:292](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L292)* +*Defined in [transaction.ts:279](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L279)* The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) @@ -178,7 +170,7 @@ ___ ▸ **getChainId**(): *number* -*Defined in [transaction.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L179)* +*Defined in [transaction.ts:162](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L162)* Returns chain ID @@ -190,7 +182,7 @@ ___ ▸ **getDataFee**(): *BN* -*Defined in [transaction.ts:278](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L278)* +*Defined in [transaction.ts:265](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L265)* The amount of gas paid for the data in this tx @@ -202,7 +194,7 @@ ___ ▸ **getMessageToSign**(): *Buffer‹›* -*Defined in [transaction.ts:168](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L168)* +*Defined in [transaction.ts:151](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L151)* **Returns:** *Buffer‹›* @@ -212,7 +204,7 @@ ___ ▸ **getMessageToVerifySignature**(): *Buffer‹›* -*Defined in [transaction.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L172)* +*Defined in [transaction.ts:155](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L155)* **Returns:** *Buffer‹›* @@ -222,7 +214,7 @@ ___ ▸ **getSenderAddress**(): *Address* -*Defined in [transaction.ts:186](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L186)* +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* Returns the sender's address @@ -234,7 +226,7 @@ ___ ▸ **getSenderPublicKey**(): *Buffer* -*Defined in [transaction.ts:193](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L193)* +*Defined in [transaction.ts:176](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L176)* Returns the public key of the sender @@ -246,7 +238,7 @@ ___ ▸ **getUpfrontCost**(): *BN* -*Defined in [transaction.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L303)* +*Defined in [transaction.ts:290](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L290)* The up front amount that an account must have for this transaction to be valid @@ -258,7 +250,7 @@ ___ ▸ **hash**(): *Buffer* -*Defined in [transaction.ts:152](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L152)* +*Defined in [transaction.ts:135](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L135)* Computes a sha3-256 hash of the serialized tx @@ -270,7 +262,7 @@ ___ ▸ **isSigned**(): *boolean* -*Defined in [transaction.ts:368](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L368)* +*Defined in [transaction.ts:357](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L357)* **Returns:** *boolean* @@ -280,7 +272,7 @@ ___ ▸ **raw**(): *Buffer[]* -*Defined in [transaction.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L330)* +*Defined in [transaction.ts:319](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L319)* Returns a Buffer Array of the raw Buffers of this transaction, in order. @@ -292,7 +284,7 @@ ___ ▸ **serialize**(): *Buffer* -*Defined in [transaction.ts:347](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L347)* +*Defined in [transaction.ts:336](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L336)* Returns the rlp encoding of the transaction. @@ -304,7 +296,7 @@ ___ ▸ **sign**(`privateKey`: Buffer): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:242](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L242)* +*Defined in [transaction.ts:227](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L227)* Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified). @@ -328,7 +320,7 @@ ___ ▸ **toCreationAddress**(): *boolean* -*Defined in [transaction.ts:145](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L145)* +*Defined in [transaction.ts:128](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L128)* If the tx's `to` is to the creation address @@ -340,7 +332,7 @@ ___ ▸ **toJSON**(): *[JsonTx](../interfaces/_index_.jsontx.md)* -*Defined in [transaction.ts:354](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L354)* +*Defined in [transaction.ts:343](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L343)* Returns an object with the JSON representation of the transaction @@ -352,15 +344,17 @@ ___ ▸ **validate**(): *boolean* -*Defined in [transaction.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L310)* +*Defined in [transaction.ts:299](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L299)* -Validates the signature and checks to see if it has enough gas. +Validates the signature and checks if +the transaction has the minimum amount of gas required +(DataFee + TxFee + Creation Fee). **Returns:** *boolean* ▸ **validate**(`stringError`: false): *boolean* -*Defined in [transaction.ts:311](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L311)* +*Defined in [transaction.ts:300](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L300)* **Parameters:** @@ -372,7 +366,7 @@ Name | Type | ▸ **validate**(`stringError`: true): *string[]* -*Defined in [transaction.ts:312](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L312)* +*Defined in [transaction.ts:301](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L301)* **Parameters:** @@ -388,7 +382,7 @@ ___ ▸ **verifySignature**(): *boolean* -*Defined in [transaction.ts:224](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L224)* +*Defined in [transaction.ts:207](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L207)* Determines if the signature is valid @@ -400,7 +394,7 @@ ___ ▸ **fromRlpSerializedTx**(`serialized`: Buffer, `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L56)* +*Defined in [transaction.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L43)* **Parameters:** @@ -434,7 +428,7 @@ ___ ▸ **fromValuesArray**(`values`: Buffer[], `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:66](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L66)* +*Defined in [transaction.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L53)* **Parameters:** diff --git a/packages/tx/docs/classes/_transaction_.transaction.md b/packages/tx/docs/classes/_transaction_.transaction.md index e74ca7b3de..c436147327 100644 --- a/packages/tx/docs/classes/_transaction_.transaction.md +++ b/packages/tx/docs/classes/_transaction_.transaction.md @@ -54,9 +54,9 @@ An Ethereum transaction. ### constructor -\+ **new Transaction**(`nonce`: BN, `gasPrice`: BN, `gasLimit`: BN, `to`: Address | undefined, `value`: BN, `data`: Buffer, `v?`: BN, `r?`: BN, `s?`: BN, `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_transaction_.transaction.md)* +\+ **new Transaction**(`txData`: [TxData](../interfaces/_index_.txdata.md), `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_transaction_.transaction.md)* -*Defined in [transaction.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L87)* +*Defined in [transaction.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L76)* This constructor takes the values, validates them, assigns them and freezes the object. Use the static factory methods to assist in creating a Transaction object from varying data types. @@ -67,15 +67,7 @@ Use the static factory methods to assist in creating a Transaction object from v Name | Type | ------ | ------ | -`nonce` | BN | -`gasPrice` | BN | -`gasLimit` | BN | -`to` | Address | undefined | -`value` | BN | -`data` | Buffer | -`v?` | BN | -`r?` | BN | -`s?` | BN | +`txData` | [TxData](../interfaces/_index_.txdata.md) | `opts?` | [TxOptions](../interfaces/_index_.txoptions.md) | **Returns:** *[Transaction](_transaction_.transaction.md)* @@ -166,7 +158,7 @@ ___ ▸ **getBaseFee**(): *BN* -*Defined in [transaction.ts:292](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L292)* +*Defined in [transaction.ts:279](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L279)* The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) @@ -178,7 +170,7 @@ ___ ▸ **getChainId**(): *number* -*Defined in [transaction.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L179)* +*Defined in [transaction.ts:162](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L162)* Returns chain ID @@ -190,7 +182,7 @@ ___ ▸ **getDataFee**(): *BN* -*Defined in [transaction.ts:278](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L278)* +*Defined in [transaction.ts:265](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L265)* The amount of gas paid for the data in this tx @@ -202,7 +194,7 @@ ___ ▸ **getMessageToSign**(): *Buffer‹›* -*Defined in [transaction.ts:168](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L168)* +*Defined in [transaction.ts:151](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L151)* **Returns:** *Buffer‹›* @@ -212,7 +204,7 @@ ___ ▸ **getMessageToVerifySignature**(): *Buffer‹›* -*Defined in [transaction.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L172)* +*Defined in [transaction.ts:155](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L155)* **Returns:** *Buffer‹›* @@ -222,7 +214,7 @@ ___ ▸ **getSenderAddress**(): *Address* -*Defined in [transaction.ts:186](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L186)* +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* Returns the sender's address @@ -234,7 +226,7 @@ ___ ▸ **getSenderPublicKey**(): *Buffer* -*Defined in [transaction.ts:193](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L193)* +*Defined in [transaction.ts:176](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L176)* Returns the public key of the sender @@ -246,7 +238,7 @@ ___ ▸ **getUpfrontCost**(): *BN* -*Defined in [transaction.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L303)* +*Defined in [transaction.ts:290](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L290)* The up front amount that an account must have for this transaction to be valid @@ -258,7 +250,7 @@ ___ ▸ **hash**(): *Buffer* -*Defined in [transaction.ts:152](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L152)* +*Defined in [transaction.ts:135](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L135)* Computes a sha3-256 hash of the serialized tx @@ -270,7 +262,7 @@ ___ ▸ **isSigned**(): *boolean* -*Defined in [transaction.ts:368](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L368)* +*Defined in [transaction.ts:357](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L357)* **Returns:** *boolean* @@ -280,7 +272,7 @@ ___ ▸ **raw**(): *Buffer[]* -*Defined in [transaction.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L330)* +*Defined in [transaction.ts:319](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L319)* Returns a Buffer Array of the raw Buffers of this transaction, in order. @@ -292,7 +284,7 @@ ___ ▸ **serialize**(): *Buffer* -*Defined in [transaction.ts:347](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L347)* +*Defined in [transaction.ts:336](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L336)* Returns the rlp encoding of the transaction. @@ -304,7 +296,7 @@ ___ ▸ **sign**(`privateKey`: Buffer): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:242](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L242)* +*Defined in [transaction.ts:227](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L227)* Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified). @@ -328,7 +320,7 @@ ___ ▸ **toCreationAddress**(): *boolean* -*Defined in [transaction.ts:145](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L145)* +*Defined in [transaction.ts:128](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L128)* If the tx's `to` is to the creation address @@ -340,7 +332,7 @@ ___ ▸ **toJSON**(): *[JsonTx](../interfaces/_index_.jsontx.md)* -*Defined in [transaction.ts:354](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L354)* +*Defined in [transaction.ts:343](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L343)* Returns an object with the JSON representation of the transaction @@ -352,15 +344,17 @@ ___ ▸ **validate**(): *boolean* -*Defined in [transaction.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L310)* +*Defined in [transaction.ts:299](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L299)* -Validates the signature and checks to see if it has enough gas. +Validates the signature and checks if +the transaction has the minimum amount of gas required +(DataFee + TxFee + Creation Fee). **Returns:** *boolean* ▸ **validate**(`stringError`: false): *boolean* -*Defined in [transaction.ts:311](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L311)* +*Defined in [transaction.ts:300](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L300)* **Parameters:** @@ -372,7 +366,7 @@ Name | Type | ▸ **validate**(`stringError`: true): *string[]* -*Defined in [transaction.ts:312](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L312)* +*Defined in [transaction.ts:301](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L301)* **Parameters:** @@ -388,7 +382,7 @@ ___ ▸ **verifySignature**(): *boolean* -*Defined in [transaction.ts:224](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L224)* +*Defined in [transaction.ts:207](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L207)* Determines if the signature is valid @@ -400,7 +394,7 @@ ___ ▸ **fromRlpSerializedTx**(`serialized`: Buffer, `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L56)* +*Defined in [transaction.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L43)* **Parameters:** @@ -434,7 +428,7 @@ ___ ▸ **fromValuesArray**(`values`: Buffer[], `opts?`: [TxOptions](../interfaces/_index_.txoptions.md)): *[Transaction](_index_.transaction.md)‹›* -*Defined in [transaction.ts:66](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L66)* +*Defined in [transaction.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L53)* **Parameters:** diff --git a/packages/tx/docs/interfaces/_index_.jsontx.md b/packages/tx/docs/interfaces/_index_.jsontx.md index 944254956a..2be0e417c2 100644 --- a/packages/tx/docs/interfaces/_index_.jsontx.md +++ b/packages/tx/docs/interfaces/_index_.jsontx.md @@ -28,7 +28,7 @@ An object with all of the transaction's values represented as strings. • **data**? : *undefined | string* -*Defined in [types.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L76)* +*Defined in [types.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L87)* ___ @@ -36,7 +36,7 @@ ___ • **gasLimit**? : *undefined | string* -*Defined in [types.ts:74](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L74)* +*Defined in [types.ts:85](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L85)* ___ @@ -44,7 +44,7 @@ ___ • **gasPrice**? : *undefined | string* -*Defined in [types.ts:73](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L73)* +*Defined in [types.ts:84](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L84)* ___ @@ -52,7 +52,7 @@ ___ • **nonce**? : *undefined | string* -*Defined in [types.ts:72](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L72)* +*Defined in [types.ts:83](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L83)* ___ @@ -60,7 +60,7 @@ ___ • **r**? : *undefined | string* -*Defined in [types.ts:78](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L78)* +*Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)* ___ @@ -68,7 +68,7 @@ ___ • **s**? : *undefined | string* -*Defined in [types.ts:79](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L79)* +*Defined in [types.ts:90](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L90)* ___ @@ -76,7 +76,7 @@ ___ • **to**? : *undefined | string* -*Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L75)* +*Defined in [types.ts:86](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L86)* ___ @@ -84,7 +84,7 @@ ___ • **v**? : *undefined | string* -*Defined in [types.ts:77](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L77)* +*Defined in [types.ts:88](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L88)* ___ @@ -92,4 +92,4 @@ ___ • **value**? : *undefined | string* -*Defined in [types.ts:80](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L80)* +*Defined in [types.ts:91](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L91)* diff --git a/packages/tx/docs/interfaces/_index_.txdata.md b/packages/tx/docs/interfaces/_index_.txdata.md index 4e49a6c348..6384effcb3 100644 --- a/packages/tx/docs/interfaces/_index_.txdata.md +++ b/packages/tx/docs/interfaces/_index_.txdata.md @@ -28,7 +28,7 @@ An object with an optional field with each of the transaction's values. • **data**? : *BufferLike* -*Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L50)* +*Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L61)* This will contain the data of the message or the init of a contract. @@ -38,7 +38,7 @@ ___ • **gasLimit**? : *BNLike* -*Defined in [types.ts:35](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L35)* +*Defined in [types.ts:46](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L46)* The transaction's gas limit. @@ -48,7 +48,7 @@ ___ • **gasPrice**? : *BNLike* -*Defined in [types.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L30)* +*Defined in [types.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L41)* The transaction's gas price. @@ -58,7 +58,7 @@ ___ • **nonce**? : *BNLike* -*Defined in [types.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L25)* +*Defined in [types.ts:36](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L36)* The transaction's nonce. @@ -68,7 +68,7 @@ ___ • **r**? : *BNLike* -*Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L60)* +*Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L71)* EC signature parameter. @@ -78,7 +78,7 @@ ___ • **s**? : *BNLike* -*Defined in [types.ts:65](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L65)* +*Defined in [types.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L76)* EC signature parameter. @@ -88,7 +88,7 @@ ___ • **to**? : *AddressLike* -*Defined in [types.ts:40](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L40)* +*Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L51)* The transaction's the address is sent to. @@ -98,7 +98,7 @@ ___ • **v**? : *BNLike* -*Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L55)* +*Defined in [types.ts:66](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L66)* EC recovery ID. @@ -108,6 +108,6 @@ ___ • **value**? : *BNLike* -*Defined in [types.ts:45](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L45)* +*Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L56)* The amount of Ether sent. diff --git a/packages/tx/docs/interfaces/_index_.txoptions.md b/packages/tx/docs/interfaces/_index_.txoptions.md index f569047514..54dcf64355 100644 --- a/packages/tx/docs/interfaces/_index_.txoptions.md +++ b/packages/tx/docs/interfaces/_index_.txoptions.md @@ -13,6 +13,7 @@ The options for initializing a Transaction. ### Properties * [common](_index_.txoptions.md#optional-common) +* [freeze](_index_.txoptions.md#optional-freeze) ## Properties @@ -27,3 +28,20 @@ A Common object defining the chain and hardfork for the transaction. Default: `Common` object set to `mainnet` and the default hardfork as defined in the `Common` class. Current default hardfork: `istanbul` + +___ + +### `Optional` freeze + +• **freeze**? : *undefined | false | true* + +*Defined in [types.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L26)* + +A transaction object by default gets frozen along initialization. This gives you +strong additional security guarantees on the consistency of the tx parameters. + +If you need to deactivate the tx freeze - e.g. because you want to subclass tx and +add aditional properties - it is strongly encouraged that you do the freeze yourself +within your code instead. + +Default: true diff --git a/packages/tx/docs/interfaces/_types_.jsontx.md b/packages/tx/docs/interfaces/_types_.jsontx.md index c2e3212fb7..1ffb2f6c20 100644 --- a/packages/tx/docs/interfaces/_types_.jsontx.md +++ b/packages/tx/docs/interfaces/_types_.jsontx.md @@ -28,7 +28,7 @@ An object with all of the transaction's values represented as strings. • **data**? : *undefined | string* -*Defined in [types.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L76)* +*Defined in [types.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L87)* ___ @@ -36,7 +36,7 @@ ___ • **gasLimit**? : *undefined | string* -*Defined in [types.ts:74](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L74)* +*Defined in [types.ts:85](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L85)* ___ @@ -44,7 +44,7 @@ ___ • **gasPrice**? : *undefined | string* -*Defined in [types.ts:73](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L73)* +*Defined in [types.ts:84](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L84)* ___ @@ -52,7 +52,7 @@ ___ • **nonce**? : *undefined | string* -*Defined in [types.ts:72](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L72)* +*Defined in [types.ts:83](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L83)* ___ @@ -60,7 +60,7 @@ ___ • **r**? : *undefined | string* -*Defined in [types.ts:78](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L78)* +*Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)* ___ @@ -68,7 +68,7 @@ ___ • **s**? : *undefined | string* -*Defined in [types.ts:79](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L79)* +*Defined in [types.ts:90](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L90)* ___ @@ -76,7 +76,7 @@ ___ • **to**? : *undefined | string* -*Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L75)* +*Defined in [types.ts:86](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L86)* ___ @@ -84,7 +84,7 @@ ___ • **v**? : *undefined | string* -*Defined in [types.ts:77](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L77)* +*Defined in [types.ts:88](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L88)* ___ @@ -92,4 +92,4 @@ ___ • **value**? : *undefined | string* -*Defined in [types.ts:80](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L80)* +*Defined in [types.ts:91](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L91)* diff --git a/packages/tx/docs/interfaces/_types_.txdata.md b/packages/tx/docs/interfaces/_types_.txdata.md index 1737904a8a..d8a79c6a37 100644 --- a/packages/tx/docs/interfaces/_types_.txdata.md +++ b/packages/tx/docs/interfaces/_types_.txdata.md @@ -28,7 +28,7 @@ An object with an optional field with each of the transaction's values. • **data**? : *BufferLike* -*Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L50)* +*Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L61)* This will contain the data of the message or the init of a contract. @@ -38,7 +38,7 @@ ___ • **gasLimit**? : *BNLike* -*Defined in [types.ts:35](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L35)* +*Defined in [types.ts:46](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L46)* The transaction's gas limit. @@ -48,7 +48,7 @@ ___ • **gasPrice**? : *BNLike* -*Defined in [types.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L30)* +*Defined in [types.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L41)* The transaction's gas price. @@ -58,7 +58,7 @@ ___ • **nonce**? : *BNLike* -*Defined in [types.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L25)* +*Defined in [types.ts:36](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L36)* The transaction's nonce. @@ -68,7 +68,7 @@ ___ • **r**? : *BNLike* -*Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L60)* +*Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L71)* EC signature parameter. @@ -78,7 +78,7 @@ ___ • **s**? : *BNLike* -*Defined in [types.ts:65](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L65)* +*Defined in [types.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L76)* EC signature parameter. @@ -88,7 +88,7 @@ ___ • **to**? : *AddressLike* -*Defined in [types.ts:40](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L40)* +*Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L51)* The transaction's the address is sent to. @@ -98,7 +98,7 @@ ___ • **v**? : *BNLike* -*Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L55)* +*Defined in [types.ts:66](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L66)* EC recovery ID. @@ -108,6 +108,6 @@ ___ • **value**? : *BNLike* -*Defined in [types.ts:45](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L45)* +*Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L56)* The amount of Ether sent. diff --git a/packages/tx/docs/interfaces/_types_.txoptions.md b/packages/tx/docs/interfaces/_types_.txoptions.md index ab716be86d..5e652504e1 100644 --- a/packages/tx/docs/interfaces/_types_.txoptions.md +++ b/packages/tx/docs/interfaces/_types_.txoptions.md @@ -13,6 +13,7 @@ The options for initializing a Transaction. ### Properties * [common](_types_.txoptions.md#optional-common) +* [freeze](_types_.txoptions.md#optional-freeze) ## Properties @@ -27,3 +28,20 @@ A Common object defining the chain and hardfork for the transaction. Default: `Common` object set to `mainnet` and the default hardfork as defined in the `Common` class. Current default hardfork: `istanbul` + +___ + +### `Optional` freeze + +• **freeze**? : *undefined | false | true* + +*Defined in [types.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L26)* + +A transaction object by default gets frozen along initialization. This gives you +strong additional security guarantees on the consistency of the tx parameters. + +If you need to deactivate the tx freeze - e.g. because you want to subclass tx and +add aditional properties - it is strongly encouraged that you do the freeze yourself +within your code instead. + +Default: true diff --git a/packages/tx/package.json b/packages/tx/package.json index b90dd46d9c..bb592410fb 100644 --- a/packages/tx/package.json +++ b/packages/tx/package.json @@ -1,6 +1,6 @@ { "name": "@ethereumjs/tx", - "version": "3.0.0-beta.1", + "version": "3.0.0-beta.2", "description": "A simple module for creating, manipulating and signing Ethereum transactions", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -31,7 +31,7 @@ "author": "mjbecze ", "license": "MPL-2.0", "dependencies": { - "@ethereumjs/common": "2.0.0-beta.1", + "@ethereumjs/common": "2.0.0-beta.2", "ethereumjs-util": "^7.0.7" }, "devDependencies": { diff --git a/packages/vm/CHANGELOG.md b/packages/vm/CHANGELOG.md index 0e948d3b7c..d00a66e2ff 100644 --- a/packages/vm/CHANGELOG.md +++ b/packages/vm/CHANGELOG.md @@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 5.0.0-beta.2 +## 5.0.0-beta.2 - 2020-11-12 +This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fvm%405.0.0-beta.1) for an overview on the full changes since the last publicly released version. + +- Fixed `SSTORE` gas calculation on `constantinople`, PR [#931](https://github.com/ethereumjs/ethereumjs-vm/pull/931) - Visibility cleanup (Renaming and/or code docs additions) for class members not being part of the API, PR [#925](https://github.com/ethereumjs/ethereumjs-vm/pull/925) ## 5.0.0-beta.1 - 2020-10-22 @@ -90,8 +93,11 @@ PR [#872](https://github.com/ethereumjs/ethereumjs-vm/pull/872). This API can be used as follows: ```typescript -import VM from 'ethereumjs-vm' -const vm = new VM({ eips: [2537] }) +import Common from '@ethereumjs/common' +import VM from '@ethereumjs/vm' + +const common = new Common({ chain: 'mainnet', eips: [2537] }) +const vm = new VM({ common }) ``` ### API Change: New Major Library Versions diff --git a/packages/vm/README.md b/packages/vm/README.md index 79657be1cf..06efebab72 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -6,74 +6,22 @@ [![Code Coverage][vm-coverage-badge]][vm-coverage-link] [![Discord][discord-badge]][discord-link] -Implements Ethereum's VM in Javascript. +Implements Ethereum's VM in `TypeScript`. -#### Fork Support - -The VM currently supports the following hardfork rules: - -- `Chainstart` (a.k.a. Frontier) (v5, UNRELEASED) -- `Homestead` (v5, UNRELEASED) -- `TangerineWhistle` (v5, UNRELEASED) -- `SpuriousDragon` (v5, UNRELEASED) -- `Byzantium` -- `Constantinople` -- `Petersburg` (default) -- `Istanbul` -- `MuirGlacier` (only `mainnet` and `ropsten`) - -##### MuirGlacier Hardfork Support - -An Ethereum test suite compliant `MuirGlacier` HF implementation is available -since the `v4.1.3` VM release. You can activate a `MuirGlacier` VM by using the -`muirGlacier` `hardfork` option flag. - -**Note:** The original `v4.1.2` release contains a critical bug preventing the -`MuirGlacier` VM to work properly and there is the need to update. - -##### Istanbul Harfork Support - -An Ethereum test suite compliant `Istanbul` HF implementation is available -since the `v4.1.1` VM release. You can activate an `Istanbul` VM by using the -`istanbul` `hardfork` option flag. - -Supported `Istanbul` EIPs: - -- [EIP-152](https://eips.ethereum.org/EIPS/eip-152): Blake 2b `F` precompile, - PR [#584](https://github.com/ethereumjs/ethereumjs-vm/pull/584) -- [EIP-1108](https://eips.ethereum.org/EIPS/eip-1108): Reduce `alt_bn128` - precompile gas costs, - PR [#540](https://github.com/ethereumjs/ethereumjs-vm/pull/540) - (already released in `v4.0.0`) -- [EIP-1344](https://eips.ethereum.org/EIPS/eip-1344): Add ChainID Opcode, - PR [#572](https://github.com/ethereumjs/ethereumjs-vm/pull/572) -- [EIP-1884](https://eips.ethereum.org/EIPS/eip-1884): Trie-size-dependent - Opcode Repricing, - PR [#581](https://github.com/ethereumjs/ethereumjs-vm/pull/581) -- [EIP-2200](https://eips.ethereum.org/EIPS/eip-2200): Rebalance net-metered - SSTORE gas costs, - PR [#590](https://github.com/ethereumjs/ethereumjs-vm/pull/590) - -#### EIP Support - -It is possible to individually activate EIP support in the VM. In order to do so, pass an array to the `eips` field of the VMs options, such as `new VM({ eips: [ 2537 ]})`. - -Currently supported EIPs are: - -- [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537): BLS precompiles +Note: this `README` reflects the state of the library from `v5.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-vm) for an introduction on the last preceeding release. # INSTALL -`npm install ethereumjs-vm` +`npm install @ethereumjs/vm` # USAGE -```javascript +```typescript import { BN } from 'ethereumjs-util' import Common from '@ethereumjs/common' import VM from '@ethereumjs/vm' -const common = new Common({ chain: 'mainnet', hardfork: 'istanbul' }) +const common = new Common({ chain: 'mainnet' }) const vm = new VM({ common }) const STOP = '00' @@ -110,10 +58,6 @@ This projects contain the following examples: All of the examples have their own `README.md` explaining how to run them. -# BROWSER - -To build the VM for standalone use in the browser, see: [Running the VM in a browser](https://github.com/ethereumjs/ethereumjs-vm/tree/master/examples/run-code-browser). - # API ## VM @@ -122,44 +66,67 @@ For documentation on `VM` instantiation, exposed API and emitted `events` see ge ## StateManager -The API for the `StateManager` is currently in `Beta`, separate documentation can be found [here](./docs/classes/statemanager.md), see also [release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/v2.5.0) from the `v2.5.0` VM release for details on the `StateManager` rewrite. +Documentation on the `StateManager` can be found [here](./docs/classes/_state_statemanager_.defaultstatemanager.md). If you want to provide your own `StateManager` you can implement the dedicated [interface](./docs/interfaces/_state_interface_.statemanager.md) to ensure that your implementation conforms with the current API. -# Internal Structure +# BROWSER -The VM processes state changes at many levels. +To build the VM for standalone use in the browser, see: [Running the VM in a browser](https://github.com/ethereumjs/ethereumjs-vm/tree/master/examples/run-code-browser). -- **runBlockchain** - - for every block, runBlock -- **runBlock** - - for every tx, runTx - - pay miner and uncles -- **runTx** - - check sender balance - - check sender nonce - - runCall - - transfer gas charges -- **runCall** - - checkpoint state - - transfer value - - load code - - runCode - - materialize created contracts - - revert or commit checkpoint -- **runCode** - - iterate over code - - run op codes - - track gas usage -- **OpFns** - - run individual op code - - modify stack - - modify memory - - calculate fee +# SETUP -The opFns for `CREATE`, `CALL`, and `CALLCODE` call back up to `runCall`. +## Hardfork Support + +Starting with the `v5` release series all hardforks from `Frontier` (`chainstart`) up to the latest active mainnet hardfork are supported. + +The VM currently supports the following hardfork rules: + +- `chainstart` (a.k.a. Frontier) (`v5.0.0`+) +- `homestead` (`v5.0.0`+) +- `tangerineWhistle` (`v5.0.0`+) +- `spuriousDragon` (`v5.0.0`+) +- `byzantium` +- `constantinople` +- `petersburg` +- `istanbul` (`v4.1.1`+) +- `muirGlacier` (only `mainnet` and `ropsten`) (`v4.1.3`+) +- `berlin` (`DRAFT`, only `EIP-2315`) -## VM's tracing events +Default: `istanbul` (taken from `Common.DEFAULT_HARDFORK`) -You can subscribe to the following events of the VM: +A specific hardfork VM ruleset can be activated by passing in the hardfork +along the `Common` instance: + +```typescript +import Common from '@ethereumjs/common' +import VM from '@ethereumjs/vm' + +const common = new Common({ chain: 'mainnet', hardfork: 'byzantium' }) +const vm = new VM({ common }) +``` + +## EIP Support + +It is possible to individually activate EIP support in the VM by instantiate the `Common` instance passed +with the respective EIPs, e.g.: + +```typescript +import Common from '@ethereumjs/common' +import VM from '@ethereumjs/vm' + +const common = new Common({ chain: 'mainnet', eips: [2537] }) +const vm = new VM({ common }) +``` + +Currently supported EIPs: + +- [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537): BLS precompiles +- [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929): gas cost increases for state access opcodes + +## Tracing Events + +Our `TypeScript` VM is implemented as an [AsyncEventEmitter](https://github.com/ahultgren/async-eventemitter) and events are submitted along major execution steps which you can listen to. + +You can subscribe to the following events: - `beforeBlock`: Emits a `Block` right before running it. - `afterBlock`: Emits `RunBlockResult` right after running a block. @@ -170,6 +137,8 @@ You can subscribe to the following events of the VM: - `step`: Emits an `InterpreterStep` right before running an EVM step. - `newContract`: Emits a `NewContractEvent` right before creating a contract. This event contains the deployment code, not the deployed code, as the creation message may not return such a code. +An example for the `step` event can be found in the initial usage example in this `README`. + ### Asynchronous event handlers You can perform asynchronous operations from within an event handler @@ -197,6 +166,39 @@ by it, the exception will bubble into the VM and interrupt it, possibly corrupting its state. It's strongly recommended not to throw from withing event handlers. +# Internal Structure + +The VM processes state changes at many levels. + +- **runBlockchain** + - for every block, runBlock +- **runBlock** + - for every tx, runTx + - pay miner and uncles +- **runTx** + - check sender balance + - check sender nonce + - runCall + - transfer gas charges +- **runCall** + - checkpoint state + - transfer value + - load code + - runCode + - materialize created contracts + - revert or commit checkpoint +- **runCode** + - iterate over code + - run op codes + - track gas usage +- **OpFns** + - run individual op code + - modify stack + - modify memory + - calculate fee + +The opFns for `CREATE`, `CALL`, and `CALLCODE` call back up to `runCall`. + # DEVELOPMENT Developer documentation - currently mainly with information on testing and debugging - can be found [here](./developer.md). diff --git a/packages/vm/docs/classes/_index_.vm.md b/packages/vm/docs/classes/_index_.vm.md index 3e7cadeb79..6cdc6a5215 100644 --- a/packages/vm/docs/classes/_index_.vm.md +++ b/packages/vm/docs/classes/_index_.vm.md @@ -99,7 +99,7 @@ ___ ▸ **copy**(): *[VM](_index_.vm.md)* -*Defined in [index.ts:324](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L324)* +*Defined in [index.ts:326](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L326)* Returns a copy of the [VM](_index_.vm.md) instance. @@ -121,7 +121,7 @@ ___ ▸ **runBlock**(`opts`: [RunBlockOpts](../interfaces/_runblock_.runblockopts.md)): *Promise‹[RunBlockResult](../interfaces/_runblock_.runblockresult.md)›* -*Defined in [index.ts:278](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L278)* +*Defined in [index.ts:280](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L280)* Processes the `block` running all of the transactions it contains and updating the miner's account @@ -143,7 +143,7 @@ ___ ▸ **runBlockchain**(`blockchain?`: Blockchain): *Promise‹void›* -*Defined in [index.ts:263](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L263)* +*Defined in [index.ts:265](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L265)* Processes blocks and adds them to the blockchain. @@ -163,7 +163,7 @@ ___ ▸ **runCall**(`opts`: [RunCallOpts](../interfaces/_runcall_.runcallopts.md)): *Promise‹[EVMResult](../interfaces/_evm_evm_.evmresult.md)›* -*Defined in [index.ts:304](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L304)* +*Defined in [index.ts:306](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L306)* runs a call (or create) operation. @@ -183,7 +183,7 @@ ___ ▸ **runCode**(`opts`: [RunCodeOpts](../interfaces/_runcode_.runcodeopts.md)): *Promise‹[ExecResult](../interfaces/_evm_evm_.execresult.md)›* -*Defined in [index.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L316)* +*Defined in [index.ts:318](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L318)* Runs EVM code. @@ -203,7 +203,7 @@ ___ ▸ **runTx**(`opts`: [RunTxOpts](../interfaces/_runtx_.runtxopts.md)): *Promise‹[RunTxResult](../interfaces/_runtx_.runtxresult.md)›* -*Defined in [index.ts:292](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L292)* +*Defined in [index.ts:294](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/index.ts#L294)* Process a transaction. Run the vm. Transfers eth. Checks balances. diff --git a/packages/vm/docs/interfaces/_evm_opcodes_functions_.asyncophandler.md b/packages/vm/docs/interfaces/_evm_opcodes_functions_.asyncophandler.md index daaea85e8d..b28ecb69bf 100644 --- a/packages/vm/docs/interfaces/_evm_opcodes_functions_.asyncophandler.md +++ b/packages/vm/docs/interfaces/_evm_opcodes_functions_.asyncophandler.md @@ -10,7 +10,7 @@ ▸ (`runState`: RunState): *Promise‹void›* -*Defined in [evm/opcodes/functions.ts:34](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L34)* +*Defined in [evm/opcodes/functions.ts:35](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L35)* **Parameters:** diff --git a/packages/vm/docs/interfaces/_evm_opcodes_functions_.syncophandler.md b/packages/vm/docs/interfaces/_evm_opcodes_functions_.syncophandler.md index 05adbf1983..44278cce51 100644 --- a/packages/vm/docs/interfaces/_evm_opcodes_functions_.syncophandler.md +++ b/packages/vm/docs/interfaces/_evm_opcodes_functions_.syncophandler.md @@ -10,7 +10,7 @@ ▸ (`runState`: RunState): *void* -*Defined in [evm/opcodes/functions.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L30)* +*Defined in [evm/opcodes/functions.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L31)* **Parameters:** diff --git a/packages/vm/docs/interfaces/_evm_opcodes_index_.asyncophandler.md b/packages/vm/docs/interfaces/_evm_opcodes_index_.asyncophandler.md index 1a5bfd79d2..eedfead9a8 100644 --- a/packages/vm/docs/interfaces/_evm_opcodes_index_.asyncophandler.md +++ b/packages/vm/docs/interfaces/_evm_opcodes_index_.asyncophandler.md @@ -10,7 +10,7 @@ ▸ (`runState`: RunState): *Promise‹void›* -*Defined in [evm/opcodes/functions.ts:34](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L34)* +*Defined in [evm/opcodes/functions.ts:35](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L35)* **Parameters:** diff --git a/packages/vm/docs/interfaces/_evm_opcodes_index_.syncophandler.md b/packages/vm/docs/interfaces/_evm_opcodes_index_.syncophandler.md index c3cab09587..0df4bc9748 100644 --- a/packages/vm/docs/interfaces/_evm_opcodes_index_.syncophandler.md +++ b/packages/vm/docs/interfaces/_evm_opcodes_index_.syncophandler.md @@ -10,7 +10,7 @@ ▸ (`runState`: RunState): *void* -*Defined in [evm/opcodes/functions.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L30)* +*Defined in [evm/opcodes/functions.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L31)* **Parameters:** diff --git a/packages/vm/docs/modules/_evm_opcodes_functions_.md b/packages/vm/docs/modules/_evm_opcodes_functions_.md index ce6e9a703e..76abb5fbd2 100644 --- a/packages/vm/docs/modules/_evm_opcodes_functions_.md +++ b/packages/vm/docs/modules/_evm_opcodes_functions_.md @@ -23,7 +23,7 @@ Ƭ **OpHandler**: *[SyncOpHandler](../interfaces/_evm_opcodes_functions_.syncophandler.md) | [AsyncOpHandler](../interfaces/_evm_opcodes_functions_.asyncophandler.md)* -*Defined in [evm/opcodes/functions.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L38)* +*Defined in [evm/opcodes/functions.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L39)* ## Variables @@ -736,8 +736,15 @@ // TODO: Replace getContractStorage with EEI method const found = await getContractStorage(runState, runState.eei.getAddress(), keyBuf) accessStorageEIP2929(runState, keyBuf, true) - updateSstoreGasEIP1283(runState, found, setLengthLeftStorage(value)) - updateSstoreGasEIP2200(runState, found, setLengthLeftStorage(value), keyBuf) + + if (runState._common.hardfork() === 'constantinople') { + updateSstoreGasEIP1283(runState, found, setLengthLeftStorage(value)) + } else if (runState._common.gteHardfork('istanbul')) { + updateSstoreGasEIP2200(runState, found, setLengthLeftStorage(value), keyBuf) + } else { + updateSstoreGas(runState, found, setLengthLeftStorage(value), keyBuf) + } + await runState.eei.storageStore(keyBuf, value) }, ], @@ -1199,4 +1206,4 @@ ], ]) -*Defined in [evm/opcodes/functions.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L41)* +*Defined in [evm/opcodes/functions.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L42)* diff --git a/packages/vm/docs/modules/_evm_opcodes_index_.md b/packages/vm/docs/modules/_evm_opcodes_index_.md index eee10da1aa..9967c5d903 100644 --- a/packages/vm/docs/modules/_evm_opcodes_index_.md +++ b/packages/vm/docs/modules/_evm_opcodes_index_.md @@ -37,6 +37,7 @@ * [setLengthLeftStorage](_evm_opcodes_index_.md#setlengthleftstorage) * [subMemUsage](_evm_opcodes_index_.md#submemusage) * [trap](_evm_opcodes_index_.md#trap) +* [updateSstoreGas](_evm_opcodes_index_.md#updatesstoregas) * [writeCallOutput](_evm_opcodes_index_.md#writecalloutput) ## Type aliases @@ -45,7 +46,7 @@ Ƭ **OpHandler**: *[SyncOpHandler](../interfaces/_evm_opcodes_functions_.syncophandler.md) | [AsyncOpHandler](../interfaces/_evm_opcodes_functions_.asyncophandler.md)* -*Defined in [evm/opcodes/functions.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L38)* +*Defined in [evm/opcodes/functions.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L39)* ___ @@ -766,8 +767,15 @@ ___ // TODO: Replace getContractStorage with EEI method const found = await getContractStorage(runState, runState.eei.getAddress(), keyBuf) accessStorageEIP2929(runState, keyBuf, true) - updateSstoreGasEIP1283(runState, found, setLengthLeftStorage(value)) - updateSstoreGasEIP2200(runState, found, setLengthLeftStorage(value), keyBuf) + + if (runState._common.hardfork() === 'constantinople') { + updateSstoreGasEIP1283(runState, found, setLengthLeftStorage(value)) + } else if (runState._common.gteHardfork('istanbul')) { + updateSstoreGasEIP2200(runState, found, setLengthLeftStorage(value), keyBuf) + } else { + updateSstoreGas(runState, found, setLengthLeftStorage(value), keyBuf) + } + await runState.eei.storageStore(keyBuf, value) }, ], @@ -1229,7 +1237,7 @@ ___ ], ]) -*Defined in [evm/opcodes/functions.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L41)* +*Defined in [evm/opcodes/functions.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/functions.ts#L42)* ## Functions @@ -1237,7 +1245,7 @@ ___ ▸ **addressToBuffer**(`address`: BN | Buffer): *Buffer‹›* -*Defined in [evm/opcodes/util.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L38)* +*Defined in [evm/opcodes/util.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L39)* Converts BN address (they're stored like this on the stack) to buffer address @@ -1255,7 +1263,7 @@ ___ ▸ **describeLocation**(`runState`: RunState): *string* -*Defined in [evm/opcodes/util.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L49)* +*Defined in [evm/opcodes/util.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L50)* Error message helper - generates location string @@ -1273,7 +1281,7 @@ ___ ▸ **divCeil**(`a`: BN, `b`: BN): *BN* -*Defined in [evm/opcodes/util.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L63)* +*Defined in [evm/opcodes/util.ts:64](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L64)* Find Ceil(a / b) @@ -1292,7 +1300,7 @@ ___ ▸ **getContractStorage**(`runState`: RunState, `address`: Address, `key`: Buffer): *Promise‹any›* -*Defined in [evm/opcodes/util.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L82)* +*Defined in [evm/opcodes/util.ts:83](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L83)* Calls relevant stateManager.getContractStorage method based on hardfork @@ -1312,7 +1320,7 @@ ___ ▸ **getDataSlice**(`data`: Buffer, `offset`: BN, `length`: BN): *Buffer* -*Defined in [evm/opcodes/util.ts:110](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L110)* +*Defined in [evm/opcodes/util.ts:111](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L111)* Returns an overflow-safe slice of an array. It right-pads the data with zeros to `length`. @@ -1333,7 +1341,7 @@ ___ ▸ **getFullname**(`code`: number, `name`: string): *string* -*Defined in [evm/opcodes/util.ts:135](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L135)* +*Defined in [evm/opcodes/util.ts:136](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L136)* Get full opcode name from its name and code. @@ -1374,7 +1382,7 @@ ___ ▸ **jumpIsValid**(`runState`: RunState, `dest`: number): *boolean* -*Defined in [evm/opcodes/util.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L160)* +*Defined in [evm/opcodes/util.ts:161](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L161)* Checks if a jump is valid given a destination @@ -1393,7 +1401,7 @@ ___ ▸ **jumpSubIsValid**(`runState`: RunState, `dest`: number): *boolean* -*Defined in [evm/opcodes/util.ts:171](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L171)* +*Defined in [evm/opcodes/util.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L172)* Checks if a jumpsub is valid given a destination @@ -1412,7 +1420,7 @@ ___ ▸ **maxCallGas**(`gasLimit`: BN, `gasLeft`: BN, `runState`: RunState): *BN* -*Defined in [evm/opcodes/util.ts:183](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L183)* +*Defined in [evm/opcodes/util.ts:184](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L184)* Returns an overflow-safe slice of an array. It right-pads @@ -1434,7 +1442,7 @@ ___ ▸ **setLengthLeftStorage**(`value`: Buffer): *Buffer‹›* -*Defined in [evm/opcodes/util.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L13)* +*Defined in [evm/opcodes/util.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L14)* Proxy function for ethereumjs-util's setLengthLeft, except it returns a zero @@ -1454,7 +1462,7 @@ ___ ▸ **subMemUsage**(`runState`: RunState, `offset`: BN, `length`: BN): *void* -*Defined in [evm/opcodes/util.ts:201](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L201)* +*Defined in [evm/opcodes/util.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L202)* Subtracts the amount needed for memory usage from `runState.gasLeft` @@ -1476,7 +1484,7 @@ ___ ▸ **trap**(`err`: string): *void* -*Defined in [evm/opcodes/util.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L27)* +*Defined in [evm/opcodes/util.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L28)* Wraps error message as VMError @@ -1490,11 +1498,32 @@ Name | Type | Description | ___ +### updateSstoreGas + +▸ **updateSstoreGas**(`runState`: RunState, `found`: any, `value`: Buffer, `keyBuf`: Buffer): *void* + +*Defined in [evm/opcodes/util.ts:250](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L250)* + +The first rule set of SSTORE rules, which are the rules pre-Constantinople and in Petersburg + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`runState` | RunState | - | +`found` | any | - | +`value` | Buffer | - | +`keyBuf` | Buffer | | + +**Returns:** *void* + +___ + ### writeCallOutput ▸ **writeCallOutput**(`runState`: RunState, `outOffset`: BN, `outLength`: BN): *void* -*Defined in [evm/opcodes/util.ts:229](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L229)* +*Defined in [evm/opcodes/util.ts:230](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L230)* Writes data returned by eei.call* methods to memory diff --git a/packages/vm/docs/modules/_evm_opcodes_util_.md b/packages/vm/docs/modules/_evm_opcodes_util_.md index 0569d52200..33e647b235 100644 --- a/packages/vm/docs/modules/_evm_opcodes_util_.md +++ b/packages/vm/docs/modules/_evm_opcodes_util_.md @@ -18,6 +18,7 @@ * [setLengthLeftStorage](_evm_opcodes_util_.md#setlengthleftstorage) * [subMemUsage](_evm_opcodes_util_.md#submemusage) * [trap](_evm_opcodes_util_.md#trap) +* [updateSstoreGas](_evm_opcodes_util_.md#updatesstoregas) * [writeCallOutput](_evm_opcodes_util_.md#writecalloutput) ## Functions @@ -26,7 +27,7 @@ ▸ **addressToBuffer**(`address`: BN | Buffer): *Buffer‹›* -*Defined in [evm/opcodes/util.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L38)* +*Defined in [evm/opcodes/util.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L39)* Converts BN address (they're stored like this on the stack) to buffer address @@ -44,7 +45,7 @@ ___ ▸ **describeLocation**(`runState`: RunState): *string* -*Defined in [evm/opcodes/util.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L49)* +*Defined in [evm/opcodes/util.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L50)* Error message helper - generates location string @@ -62,7 +63,7 @@ ___ ▸ **divCeil**(`a`: BN, `b`: BN): *BN* -*Defined in [evm/opcodes/util.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L63)* +*Defined in [evm/opcodes/util.ts:64](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L64)* Find Ceil(a / b) @@ -81,7 +82,7 @@ ___ ▸ **getContractStorage**(`runState`: RunState, `address`: Address, `key`: Buffer): *Promise‹any›* -*Defined in [evm/opcodes/util.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L82)* +*Defined in [evm/opcodes/util.ts:83](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L83)* Calls relevant stateManager.getContractStorage method based on hardfork @@ -101,7 +102,7 @@ ___ ▸ **getDataSlice**(`data`: Buffer, `offset`: BN, `length`: BN): *Buffer* -*Defined in [evm/opcodes/util.ts:110](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L110)* +*Defined in [evm/opcodes/util.ts:111](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L111)* Returns an overflow-safe slice of an array. It right-pads the data with zeros to `length`. @@ -122,7 +123,7 @@ ___ ▸ **getFullname**(`code`: number, `name`: string): *string* -*Defined in [evm/opcodes/util.ts:135](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L135)* +*Defined in [evm/opcodes/util.ts:136](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L136)* Get full opcode name from its name and code. @@ -143,7 +144,7 @@ ___ ▸ **jumpIsValid**(`runState`: RunState, `dest`: number): *boolean* -*Defined in [evm/opcodes/util.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L160)* +*Defined in [evm/opcodes/util.ts:161](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L161)* Checks if a jump is valid given a destination @@ -162,7 +163,7 @@ ___ ▸ **jumpSubIsValid**(`runState`: RunState, `dest`: number): *boolean* -*Defined in [evm/opcodes/util.ts:171](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L171)* +*Defined in [evm/opcodes/util.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L172)* Checks if a jumpsub is valid given a destination @@ -181,7 +182,7 @@ ___ ▸ **maxCallGas**(`gasLimit`: BN, `gasLeft`: BN, `runState`: RunState): *BN* -*Defined in [evm/opcodes/util.ts:183](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L183)* +*Defined in [evm/opcodes/util.ts:184](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L184)* Returns an overflow-safe slice of an array. It right-pads @@ -203,7 +204,7 @@ ___ ▸ **setLengthLeftStorage**(`value`: Buffer): *Buffer‹›* -*Defined in [evm/opcodes/util.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L13)* +*Defined in [evm/opcodes/util.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L14)* Proxy function for ethereumjs-util's setLengthLeft, except it returns a zero @@ -223,7 +224,7 @@ ___ ▸ **subMemUsage**(`runState`: RunState, `offset`: BN, `length`: BN): *void* -*Defined in [evm/opcodes/util.ts:201](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L201)* +*Defined in [evm/opcodes/util.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L202)* Subtracts the amount needed for memory usage from `runState.gasLeft` @@ -245,7 +246,7 @@ ___ ▸ **trap**(`err`: string): *void* -*Defined in [evm/opcodes/util.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L27)* +*Defined in [evm/opcodes/util.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L28)* Wraps error message as VMError @@ -259,11 +260,32 @@ Name | Type | Description | ___ +### updateSstoreGas + +▸ **updateSstoreGas**(`runState`: RunState, `found`: any, `value`: Buffer, `keyBuf`: Buffer): *void* + +*Defined in [evm/opcodes/util.ts:250](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L250)* + +The first rule set of SSTORE rules, which are the rules pre-Constantinople and in Petersburg + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`runState` | RunState | - | +`found` | any | - | +`value` | Buffer | - | +`keyBuf` | Buffer | | + +**Returns:** *void* + +___ + ### writeCallOutput ▸ **writeCallOutput**(`runState`: RunState, `outOffset`: BN, `outLength`: BN): *void* -*Defined in [evm/opcodes/util.ts:229](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L229)* +*Defined in [evm/opcodes/util.ts:230](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/vm/lib/evm/opcodes/util.ts#L230)* Writes data returned by eei.call* methods to memory diff --git a/packages/vm/package.json b/packages/vm/package.json index 5e864d09ab..a89c55119f 100644 --- a/packages/vm/package.json +++ b/packages/vm/package.json @@ -1,6 +1,6 @@ { "name": "@ethereumjs/vm", - "version": "5.0.0-beta.1", + "version": "5.0.0-beta.2", "description": "An Ethereum VM implementation", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -45,10 +45,10 @@ "dependencies": { "async-eventemitter": "^0.2.4", "core-js-pure": "^3.0.1", - "@ethereumjs/block": "3.0.0-beta.1", - "@ethereumjs/blockchain": "5.0.0-beta.1", - "@ethereumjs/common": "2.0.0-beta.1", - "@ethereumjs/tx": "3.0.0-beta.1", + "@ethereumjs/block": "3.0.0-beta.2", + "@ethereumjs/blockchain": "5.0.0-beta.2", + "@ethereumjs/common": "2.0.0-beta.2", + "@ethereumjs/tx": "3.0.0-beta.2", "ethereumjs-util": "^7.0.7", "functional-red-black-tree": "^1.0.1", "merkle-patricia-tree": "^4.0.0",