@@ -52,6 +52,10 @@ export interface VMOpts {
52
52
/**
53
53
* Execution engine which can be used to run a blockchain, individual
54
54
* blocks, individual transactions, or snippets of EVM bytecode.
55
+ *
56
+ * This class is an AsyncEventEmitter, which means that event handlers are run to completion before
57
+ * continuing. If an error is thrown in an event handler, it will bubble up to the VM and thrown
58
+ * from the method call that triggered the event.
55
59
*/
56
60
export default class VM extends AsyncEventEmitter {
57
61
opts : VMOpts
@@ -109,6 +113,9 @@ export default class VM extends AsyncEventEmitter {
109
113
110
114
/**
111
115
* Processes blocks and adds them to the blockchain.
116
+ *
117
+ * This method modifies the state.
118
+ *
112
119
* @param blockchain - A [blockchain](https://github.com/ethereum/ethereumjs-blockchain) object to process
113
120
* @param cb - the callback function
114
121
*/
@@ -118,6 +125,11 @@ export default class VM extends AsyncEventEmitter {
118
125
119
126
/**
120
127
* Processes the `block` running all of the transactions it contains and updating the miner's account
128
+ *
129
+ * This method modifies the state. If `generate` is `true`, the state modifications will be
130
+ * reverted if an exception is raised. If it's `false`, it won't revert if the block's header is
131
+ * invalid. If an error is thrown from an event handler, the state may or may not be reverted.
132
+ *
121
133
* @param opts - Default values for options:
122
134
* - `generate`: false
123
135
*/
@@ -127,20 +139,28 @@ export default class VM extends AsyncEventEmitter {
127
139
128
140
/**
129
141
* Process a transaction. Run the vm. Transfers eth. Checks balances.
142
+ *
143
+ * This method modifies the state. If an error is thrown, the modifications are reverted, except
144
+ * when the error is thrown from an event handler. In the latter case the state may or may not be
145
+ * reverted.
130
146
*/
131
147
runTx ( opts : RunTxOpts ) : Promise < RunTxResult > {
132
148
return runTx . bind ( this ) ( opts )
133
149
}
134
150
135
151
/**
136
152
* runs a call (or create) operation.
153
+ *
154
+ * This method modifies the state.
137
155
*/
138
156
runCall ( opts : RunCallOpts ) : Promise < EVMResult > {
139
157
return runCall . bind ( this ) ( opts )
140
158
}
141
159
142
160
/**
143
161
* Runs EVM code.
162
+ *
163
+ * This method modifies the state.
144
164
*/
145
165
runCode ( opts : RunCodeOpts ) : Promise < ExecResult > {
146
166
return runCode . bind ( this ) ( opts )
0 commit comments