@ethereumjs/evm
Advanced tools
Comparing version 2.0.0-rc.2 to 2.0.0
@@ -399,2 +399,3 @@ "use strict"; | ||
} | ||
message.createdAddresses; | ||
const env = { | ||
@@ -416,2 +417,3 @@ address: message.to ?? util_1.Address.zero(), | ||
versionedHashes: message.versionedHashes ?? [], | ||
createdAddresses: message.createdAddresses, | ||
}; | ||
@@ -418,0 +420,0 @@ const interpreter = new interpreter_js_1.Interpreter(this, this.stateManager, this.blockchain, env, message.gasLimit, this.journal); |
@@ -46,2 +46,3 @@ import { Account } from '@ethereumjs/util'; | ||
versionedHashes: Uint8Array[]; /** Versioned hashes for blob transactions */ | ||
createdAddresses?: Set<string>; | ||
} | ||
@@ -48,0 +49,0 @@ export interface RunState { |
@@ -785,13 +785,31 @@ "use strict"; | ||
this._result.selfdestruct.add((0, util_1.bytesToHex)(this._env.address.bytes)); | ||
const toSelf = (0, util_1.equalsBytes)(toAddress.bytes, this._env.address.bytes); | ||
// Add to beneficiary balance | ||
let toAccount = await this._stateManager.getAccount(toAddress); | ||
if (!toAccount) { | ||
toAccount = new util_1.Account(); | ||
if (!toSelf) { | ||
let toAccount = await this._stateManager.getAccount(toAddress); | ||
if (!toAccount) { | ||
toAccount = new util_1.Account(); | ||
} | ||
toAccount.balance += this._env.contract.balance; | ||
await this.journal.putAccount(toAddress, toAccount); | ||
} | ||
toAccount.balance += this._env.contract.balance; | ||
await this.journal.putAccount(toAddress, toAccount); | ||
// Subtract from contract balance | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}); | ||
// Modify the account (set balance to 0) flag | ||
let doModify = !this.common.isActivatedEIP(6780); // Always do this if 6780 is not active | ||
if (!doModify) { | ||
// If 6780 is active, check if current address is being created. If so | ||
// old behavior of SELFDESTRUCT exists and balance should be set to 0 of this account | ||
// (i.e. burn the ETH in current account) | ||
doModify = this._env.createdAddresses.has(this._env.address.toString()); | ||
// If contract is not being created in this tx... | ||
if (!doModify) { | ||
// Check if ETH being sent to another account (thus set balance to 0) | ||
doModify = !toSelf; | ||
} | ||
} | ||
// Set contract balance to 0 | ||
if (doModify) { | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}); | ||
} | ||
(0, index_js_1.trap)(exceptions_js_1.ERROR.STOP); | ||
@@ -798,0 +816,0 @@ } |
@@ -278,5 +278,5 @@ import type { EvmError } from './exceptions.js'; | ||
/** | ||
* Amount of data gas consumed by the transaction | ||
* Amount of blob gas consumed by the transaction | ||
*/ | ||
dataGasUsed?: bigint; | ||
blobGasUsed?: bigint; | ||
} | ||
@@ -283,0 +283,0 @@ /** |
@@ -396,2 +396,3 @@ import { Chain, Common, Hardfork } from '@ethereumjs/common'; | ||
} | ||
message.createdAddresses; | ||
const env = { | ||
@@ -413,2 +414,3 @@ address: message.to ?? Address.zero(), | ||
versionedHashes: message.versionedHashes ?? [], | ||
createdAddresses: message.createdAddresses, | ||
}; | ||
@@ -415,0 +417,0 @@ const interpreter = new Interpreter(this, this.stateManager, this.blockchain, env, message.gasLimit, this.journal); |
@@ -46,2 +46,3 @@ import { Account } from '@ethereumjs/util'; | ||
versionedHashes: Uint8Array[]; /** Versioned hashes for blob transactions */ | ||
createdAddresses?: Set<string>; | ||
} | ||
@@ -48,0 +49,0 @@ export interface RunState { |
import { ConsensusAlgorithm } from '@ethereumjs/common'; | ||
import { Account, MAX_UINT64, bigIntToHex, bytesToBigInt, bytesToHex } from '@ethereumjs/util'; | ||
import { Account, MAX_UINT64, bigIntToHex, bytesToBigInt, bytesToHex, equalsBytes, } from '@ethereumjs/util'; | ||
import debugDefault from 'debug'; | ||
@@ -782,13 +782,31 @@ import { EOF } from './eof.js'; | ||
this._result.selfdestruct.add(bytesToHex(this._env.address.bytes)); | ||
const toSelf = equalsBytes(toAddress.bytes, this._env.address.bytes); | ||
// Add to beneficiary balance | ||
let toAccount = await this._stateManager.getAccount(toAddress); | ||
if (!toAccount) { | ||
toAccount = new Account(); | ||
if (!toSelf) { | ||
let toAccount = await this._stateManager.getAccount(toAddress); | ||
if (!toAccount) { | ||
toAccount = new Account(); | ||
} | ||
toAccount.balance += this._env.contract.balance; | ||
await this.journal.putAccount(toAddress, toAccount); | ||
} | ||
toAccount.balance += this._env.contract.balance; | ||
await this.journal.putAccount(toAddress, toAccount); | ||
// Subtract from contract balance | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}); | ||
// Modify the account (set balance to 0) flag | ||
let doModify = !this.common.isActivatedEIP(6780); // Always do this if 6780 is not active | ||
if (!doModify) { | ||
// If 6780 is active, check if current address is being created. If so | ||
// old behavior of SELFDESTRUCT exists and balance should be set to 0 of this account | ||
// (i.e. burn the ETH in current account) | ||
doModify = this._env.createdAddresses.has(this._env.address.toString()); | ||
// If contract is not being created in this tx... | ||
if (!doModify) { | ||
// Check if ETH being sent to another account (thus set balance to 0) | ||
doModify = !toSelf; | ||
} | ||
} | ||
// Set contract balance to 0 | ||
if (doModify) { | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}); | ||
} | ||
trap(ERROR.STOP); | ||
@@ -795,0 +813,0 @@ } |
@@ -278,5 +278,5 @@ import type { EvmError } from './exceptions.js'; | ||
/** | ||
* Amount of data gas consumed by the transaction | ||
* Amount of blob gas consumed by the transaction | ||
*/ | ||
dataGasUsed?: bigint; | ||
blobGasUsed?: bigint; | ||
} | ||
@@ -283,0 +283,0 @@ /** |
{ | ||
"name": "@ethereumjs/evm", | ||
"version": "2.0.0-rc.2", | ||
"version": "2.0.0", | ||
"description": "JavaScript Ethereum Virtual Machine (EVM) implementation", | ||
@@ -55,6 +55,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@ethereumjs/common": "4.0.0-rc.1", | ||
"@ethereumjs/statemanager": "2.0.0-rc.1", | ||
"@ethereumjs/tx": "5.0.0-rc.1", | ||
"@ethereumjs/util": "9.0.0-rc.1", | ||
"@ethereumjs/common": "^4.0.0", | ||
"@ethereumjs/statemanager": "^2.0.0", | ||
"@ethereumjs/tx": "^5.0.0", | ||
"@ethereumjs/util": "^9.0.0", | ||
"debug": "^4.3.3", | ||
@@ -61,0 +61,0 @@ "ethereum-cryptography": "^2.1.2", |
@@ -9,4 +9,2 @@ # @ethereumjs/evm | ||
Note: this README has been updated containing the changes from our next breaking release round [UNRELEASED] targeted for Summer 2023. See the README files from the [maintenance-v6](https://github.com/ethereumjs/ethereumjs-monorepo/tree/maintenance-v6/) branch for documentation matching our latest releases. | ||
| TypeScript implementation of the Ethereum EVM. | | ||
@@ -123,3 +121,3 @@ | ---------------------------------------------- | | ||
If you use Node.js specific `require` the CJS build will be used: | ||
If you use Node.js specific `require`, the CJS build will be used: | ||
@@ -198,6 +196,6 @@ ```typescript | ||
import { Chain, Common } from '@ethereumjs/common' | ||
import { VM } from '@ethereumjs/vm' | ||
import { EVM } from '@ethereumjs/evm' | ||
const common = new Common({ chain: Chain.Mainnet, eips: [2537] }) | ||
const vm = new VM({ common }) | ||
const evm = new EVM({ common }) | ||
``` | ||
@@ -204,0 +202,0 @@ |
@@ -534,2 +534,3 @@ import { Chain, Common, Hardfork } from '@ethereumjs/common' | ||
} | ||
message.createdAddresses | ||
const env = { | ||
@@ -551,2 +552,3 @@ address: message.to ?? Address.zero(), | ||
versionedHashes: message.versionedHashes ?? [], | ||
createdAddresses: message.createdAddresses, | ||
} | ||
@@ -553,0 +555,0 @@ |
import { ConsensusAlgorithm } from '@ethereumjs/common' | ||
import { Account, MAX_UINT64, bigIntToHex, bytesToBigInt, bytesToHex } from '@ethereumjs/util' | ||
import { | ||
Account, | ||
MAX_UINT64, | ||
bigIntToHex, | ||
bytesToBigInt, | ||
bytesToHex, | ||
equalsBytes, | ||
} from '@ethereumjs/util' | ||
import debugDefault from 'debug' | ||
@@ -59,2 +66,3 @@ | ||
versionedHashes: Uint8Array[] /** Versioned hashes for blob transactions */ | ||
createdAddresses?: Set<string> | ||
} | ||
@@ -1044,15 +1052,36 @@ | ||
const toSelf = equalsBytes(toAddress.bytes, this._env.address.bytes) | ||
// Add to beneficiary balance | ||
let toAccount = await this._stateManager.getAccount(toAddress) | ||
if (!toAccount) { | ||
toAccount = new Account() | ||
if (!toSelf) { | ||
let toAccount = await this._stateManager.getAccount(toAddress) | ||
if (!toAccount) { | ||
toAccount = new Account() | ||
} | ||
toAccount.balance += this._env.contract.balance | ||
await this.journal.putAccount(toAddress, toAccount) | ||
} | ||
toAccount.balance += this._env.contract.balance | ||
await this.journal.putAccount(toAddress, toAccount) | ||
// Subtract from contract balance | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}) | ||
// Modify the account (set balance to 0) flag | ||
let doModify = !this.common.isActivatedEIP(6780) // Always do this if 6780 is not active | ||
if (!doModify) { | ||
// If 6780 is active, check if current address is being created. If so | ||
// old behavior of SELFDESTRUCT exists and balance should be set to 0 of this account | ||
// (i.e. burn the ETH in current account) | ||
doModify = this._env.createdAddresses!.has(this._env.address.toString()) | ||
// If contract is not being created in this tx... | ||
if (!doModify) { | ||
// Check if ETH being sent to another account (thus set balance to 0) | ||
doModify = !toSelf | ||
} | ||
} | ||
// Set contract balance to 0 | ||
if (doModify) { | ||
await this._stateManager.modifyAccountFields(this._env.address, { | ||
balance: BigInt(0), | ||
}) | ||
} | ||
trap(ERROR.STOP) | ||
@@ -1059,0 +1088,0 @@ } |
@@ -311,5 +311,5 @@ import { zeros } from '@ethereumjs/util' | ||
/** | ||
* Amount of data gas consumed by the transaction | ||
* Amount of blob gas consumed by the transaction | ||
*/ | ||
dataGasUsed?: bigint | ||
blobGasUsed?: bigint | ||
} | ||
@@ -316,0 +316,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1370246
20457
0
386
+ Added@ethereumjs/common@4.4.0(transitive)
+ Added@ethereumjs/rlp@5.0.2(transitive)
+ Added@ethereumjs/statemanager@2.4.0(transitive)
+ Added@ethereumjs/trie@6.2.1(transitive)
+ Added@ethereumjs/tx@5.4.0(transitive)
+ Added@ethereumjs/util@9.1.0(transitive)
+ Added@types/node@22.7.4(transitive)
+ Added@types/readable-stream@2.3.15(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedlru-cache@10.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removed@adraffy/ens-normalize@1.10.1(transitive)
- Removed@ethereumjs/common@4.0.0-rc.1(transitive)
- Removed@ethereumjs/rlp@5.0.0-rc.1(transitive)
- Removed@ethereumjs/statemanager@2.0.0-rc.1(transitive)
- Removed@ethereumjs/tx@5.0.0-rc.1(transitive)
- Removed@ethereumjs/util@9.0.0-rc.1(transitive)
- Removed@noble/curves@1.2.0(transitive)
- Removed@noble/hashes@1.3.2(transitive)
- Removed@types/node@18.15.13(transitive)
- Removedaes-js@4.0.0-beta.5(transitive)
- Removedcrc@4.3.2(transitive)
- Removedethers@6.13.2(transitive)
- Removedlru-cache@10.4.3(transitive)
- Removedtslib@2.4.0(transitive)
- Removedws@8.17.1(transitive)
Updated@ethereumjs/common@^4.0.0
Updated@ethereumjs/tx@^5.0.0
Updated@ethereumjs/util@^9.0.0