You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initial `StateManager` documentation. In the process of writing this a couple of inconsistencies in the code were found. Firstly several methods, which should only be called when there are no outstanding checkpoints, were found and updated to error when this is not the case. Secondly the `checkpoint` function was made asynchronous to match other methods.
-`blockchain`**Blockchain** A [blockchain][29] that to process
41
-
-`cb`**[Function][30]** the callback function
38
+
-`blockchain`**Blockchain** A [blockchain][27] that to process
39
+
-`cb`**[Function][28]** the callback function
42
40
43
41
## VM
44
42
45
43
VM Class, `new VM(opts)` creates a new VM object
46
44
47
45
### Parameters
48
46
49
-
-`opts`**[Object][31]**
50
-
-`opts.stateManager`**StateManager** a state manager instance (EXPERIMENTAL - unstable API)
47
+
-`opts`**[Object][29]**
48
+
-`opts.stateManager`**StateManager** a [`StateManager`][30]instance to use as the state store (Beta API)
51
49
-`opts.state`**Trie** a merkle-patricia-tree instance for the state tree (ignored if stateManager is passed)
52
50
-`opts.blockchain`**Blockchain** a blockchain object for storing/retrieving blocks (ignored if stateManager is passed)
53
-
-`opts.chain`**([String][32]\|[Number][33])** the chain the VM operates on [default: 'mainnet']
54
-
-`opts.hardfork`**[String][32]** hardfork rules to be used [default: 'byzantium', supported: 'byzantium' (will throw on unsupported)]
55
-
-`opts.activatePrecompiles`**[Boolean][34]** create entries in the state tree for the precompiled contracts
56
-
-`opts.allowUnlimitedContractSize`**[Boolean][34]** allows unlimited contract sizes while debugging. By setting this to `true`, the check for contract size limit of 24KB (see [EIP-170][35]) is bypassed. (default: `false`; ONLY set to `true` during debugging)
57
-
-`opts.emitFreeLogs`**[Boolean][34]** Changes the behavior of the LOG opcode, the gas cost of the opcode becomes zero and calling it using STATICCALL won't throw. (default: `false`; ONLY set to `true` during debugging)
51
+
-`opts.chain`**([String][31]\|[Number][32])** the chain the VM operates on [default: 'mainnet']
52
+
-`opts.hardfork`**[String][31]** hardfork rules to be used [default: 'byzantium', supported: 'byzantium' (will throw on unsupported)]
53
+
-`opts.activatePrecompiles`**[Boolean][33]** create entries in the state tree for the precompiled contracts
54
+
-`opts.allowUnlimitedContractSize`**[Boolean][33]** allows unlimited contract sizes while debugging. By setting this to `true`, the check for contract size limit of 24KB (see [EIP-170][34]) is bypassed. (default: `false`; ONLY set to `true` during debugging)
55
+
-`opts.emitFreeLogs`**[Boolean][33]** Changes the behavior of the LOG opcode, the gas cost of the opcode becomes zero and calling it using STATICCALL won't throw. (default: `false`; ONLY set to `true` during debugging)
58
56
59
57
## vm.runBlock
60
58
@@ -63,37 +61,37 @@ Processes the `block` running all of the transactions it contains and updating t
63
61
### Parameters
64
62
65
63
-`opts`
66
-
-`opts.block`**Block** the [`Block`][36] to process
67
-
-`opts.generate`**[Boolean][34]**[gen=false] whether to generate the stateRoot, if false `runBlock` will check the stateRoot of the block against the Trie
68
-
-`cb`**[runBlock~callback][37]** callback
64
+
-`opts.block`**Block** the [`Block`][35] to process
65
+
-`opts.generate`**[Boolean][33]**[gen=false] whether to generate the stateRoot, if false `runBlock` will check the stateRoot of the block against the Trie
66
+
-`cb`**[runBlock~callback][36]** callback
69
67
70
68
## runBlock~callback
71
69
72
70
Callback for `runBlock` method
73
71
74
-
Type: [Function][30]
72
+
Type: [Function][28]
75
73
76
74
### Parameters
77
75
78
-
-`error`**[Error][38]** an error that may have happened or `null`
79
-
-`results`**[Object][31]**
80
-
-`results.receipts`**[Array][39]** the receipts from the transactions in the block
81
-
-`results.results`**[Array][39]**
76
+
-`error`**[Error][37]** an error that may have happened or `null`
77
+
-`results`**[Object][29]**
78
+
-`results.receipts`**[Array][38]** the receipts from the transactions in the block
79
+
-`results.results`**[Array][38]**
82
80
83
81
## runTx~callback
84
82
85
83
Callback for `runTx` method
86
84
87
-
Type: [Function][30]
85
+
Type: [Function][28]
88
86
89
87
### Parameters
90
88
91
-
-`error`**[Error][38]** an error that may have happened or `null`
92
-
-`results`**[Object][31]**
89
+
-`error`**[Error][37]** an error that may have happened or `null`
90
+
-`results`**[Object][29]**
93
91
-`results.amountSpent`**BN** the amount of ether used by this transaction as a `bignum`
94
92
-`results.gasUsed`**BN** the amount of gas as a `bignum` used by the transaction
95
93
-`results.gasRefund`**BN** the amount of gas as a `bignum` that was refunded during the transaction (i.e. `gasUsed = totalGasConsumed - gasRefund`)
96
-
-`vm`**[VM][40]** contains the results from running the code, if any, as described in `vm.runCode(params, cb)`
94
+
-`vm`**[VM][39]** contains the results from running the code, if any, as described in `vm.runCode(params, cb)`
97
95
98
96
## vm.runTx
99
97
@@ -102,54 +100,54 @@ Process a transaction. Run the vm. Transfers eth. Checks balances.
102
100
### Parameters
103
101
104
102
-`opts`
105
-
-`opts.tx`**Transaction** a [`Transaction`][41] to run
106
-
-`opts.skipNonce`**[Boolean][34]** skips the nonce check
107
-
-`opts.skipBalance`**[Boolean][34]** skips the balance check
103
+
-`opts.tx`**Transaction** a [`Transaction`][40] to run
104
+
-`opts.skipNonce`**[Boolean][33]** skips the nonce check
105
+
-`opts.skipBalance`**[Boolean][33]** skips the balance check
108
106
-`opts.block`**Block** the block to which the `tx` belongs, if no block is given a default one is created
109
-
-`cb`**[runTx~callback][42]** the callback
110
-
111
-
## vm.runCode
112
-
113
-
Runs EVM code
114
-
115
-
### Parameters
116
-
117
-
-`opts`**[Object][31]**
118
-
-`opts.account`**Account** the [`Account`][43] that the executing code belongs to. If omitted an empty account will be used
119
-
-`opts.address`**[Buffer][44]** the address of the account that is executing this code. The address should be a `Buffer` of bytes. Defaults to `0`
120
-
-`opts.block`**Block** the [`Block`][36] the `tx` belongs to. If omitted a blank block will be used
121
-
-`opts.caller`**[Buffer][44]** the address that ran this code. The address should be a `Buffer` of 20bits. Defaults to `0`
122
-
-`opts.code`**[Buffer][44]** the EVM code to run given as a `Buffer`
123
-
-`opts.data`**[Buffer][44]** the input data
124
-
-`opts.gasLimit`**[Buffer][44]** the gas limit for the code
125
-
-`opts.origin`**[Buffer][44]** the address where the call originated from. The address should be a `Buffer` of 20bits. Defaults to `0`
126
-
-`opts.value`**[Buffer][44]** the value in ether that is being sent to `opt.address`. Defaults to `0`
127
-
-`cb`**[runCode~callback][45]** callback
107
+
-`cb`**[runTx~callback][41]** the callback
128
108
129
109
## runCode~callback
130
110
131
111
Callback for `runCode` method
132
112
133
-
Type: [Function][30]
113
+
Type: [Function][28]
134
114
135
115
### Parameters
136
116
137
-
-`error`**[Error][38]** an error that may have happened or `null`
138
-
-`results`**[Object][31]**
117
+
-`error`**[Error][37]** an error that may have happened or `null`
118
+
-`results`**[Object][29]**
139
119
-`results.gas`**BN** the amount of gas left
140
120
-`results.gasUsed`**BN** the amount of gas as a `bignum` the code used to run
141
121
-`results.gasRefund`**BN** a `bignum` containing the amount of gas to refund from deleting storage values
142
-
-`results.selfdestruct`**[Object][31]** an `Object` with keys for accounts that have selfdestructed and values for balance transfer recipient accounts
143
-
-`results.logs`**[Array][39]** an `Array` of logs that the contract emitted
144
-
-`results.exception`**[Number][33]**`0` if the contract encountered an exception, `1` otherwise
145
-
-`results.exceptionError`**[String][32]** a `String` describing the exception if there was one
146
-
-`results.return`**[Buffer][44]** a `Buffer` containing the value that was returned by the contract
122
+
-`results.selfdestruct`**[Object][29]** an `Object` with keys for accounts that have selfdestructed and values for balance transfer recipient accounts
123
+
-`results.logs`**[Array][38]** an `Array` of logs that the contract emitted
124
+
-`results.exception`**[Number][32]**`0` if the contract encountered an exception, `1` otherwise
125
+
-`results.exceptionError`**[String][31]** a `String` describing the exception if there was one
126
+
-`results.return`**[Buffer][42]** a `Buffer` containing the value that was returned by the contract
127
+
128
+
## vm.runCode
129
+
130
+
Runs EVM code
131
+
132
+
### Parameters
133
+
134
+
-`opts`**[Object][29]**
135
+
-`opts.account`**Account** the [`Account`][43] that the executing code belongs to. If omitted an empty account will be used
136
+
-`opts.address`**[Buffer][42]** the address of the account that is executing this code. The address should be a `Buffer` of bytes. Defaults to `0`
137
+
-`opts.block`**Block** the [`Block`][35] the `tx` belongs to. If omitted a blank block will be used
138
+
-`opts.caller`**[Buffer][42]** the address that ran this code. The address should be a `Buffer` of 20bits. Defaults to `0`
139
+
-`opts.code`**[Buffer][42]** the EVM code to run given as a `Buffer`
140
+
-`opts.data`**[Buffer][42]** the input data
141
+
-`opts.gasLimit`**[Buffer][42]** the gas limit for the code
142
+
-`opts.origin`**[Buffer][42]** the address where the call originated from. The address should be a `Buffer` of 20bits. Defaults to `0`
143
+
-`opts.value`**[Buffer][42]** the value in ether that is being sent to `opt.address`. Defaults to `0`
144
+
-`cb`**[runCode~callback][44]** callback
147
145
148
146
## Event: beforeBlock
149
147
150
148
The `beforeBlock` event
151
149
152
-
Type: [Object][31]
150
+
Type: [Object][29]
153
151
154
152
### Properties
155
153
@@ -159,17 +157,17 @@ Type: [Object][31]
159
157
160
158
The `afterBlock` event
161
159
162
-
Type: [Object][31]
160
+
Type: [Object][29]
163
161
164
162
### Properties
165
163
166
-
-`result`**[Object][31]** emits the results of processing a block
164
+
-`result`**[Object][29]** emits the results of processing a block
167
165
168
166
## Event: beforeTx
169
167
170
168
The `beforeTx` event
171
169
172
-
Type: [Object][31]
170
+
Type: [Object][29]
173
171
174
172
### Properties
175
173
@@ -179,40 +177,29 @@ Type: [Object][31]
179
177
180
178
The `afterTx` event
181
179
182
-
Type: [Object][31]
180
+
Type: [Object][29]
183
181
184
182
### Properties
185
183
186
-
-`result`**[Object][31]** result of the transaction
187
-
188
-
## Event: newContract
189
-
190
-
The `newContract` event when a contract is created
191
-
192
-
Type: [Object][31]
193
-
194
-
### Properties
195
-
196
-
-`address`**[Buffer][44]** the created address for the new contract (type `Buffer | Uint8Array`)
197
-
-`code`**[Buffer][44]** the deployment bytecode for reference (type `Buffer | Uint8Array`)
184
+
-`result`**[Object][29]** result of the transaction
198
185
199
186
## Event: step
200
187
201
188
The `step` event for trace output
202
189
203
-
Type: [Object][31]
190
+
Type: [Object][29]
204
191
205
192
### Properties
206
193
207
-
-`pc`**[Number][33]** representing the program counter
208
-
-`opcode`**[String][32]** the next opcode to be ran
194
+
-`pc`**[Number][32]** representing the program counter
195
+
-`opcode`**[String][31]** the next opcode to be ran
209
196
-`gasLeft`**BN** amount of gasLeft
210
-
-`stack`**[Array][39]** an `Array` of `Buffers` containing the stack
211
-
-`account`**Account** the [`Account`][46] which owns the code running
212
-
-`address`**[Buffer][44]** the address of the `account`
213
-
-`depth`**[Number][33]** the current number of calls deep the contract is
214
-
-`memory`**[Buffer][44]** the memory of the VM as a `buffer`
215
-
-`storageManager`**StateManager** a state manager instance (EXPERIMENTAL - unstable API)
197
+
-`stack`**[Array][38]** an `Array` of `Buffers` containing the stack
198
+
-`account`**Account** the [`Account`][45] which owns the code running
199
+
-`address`**[Buffer][42]** the address of the `account`
200
+
-`depth`**[Number][32]** the current number of calls deep the contract is
201
+
-`memory`**[Buffer][42]** the memory of the VM as a `buffer`
202
+
-`stateManager`**StateManager** a [`StateManager`][30]instance (Beta API)
0 commit comments