Socket
Socket
Sign inDemoInstall

@ethereumjs/evm

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/evm - npm Package Compare versions

Comparing version 2.0.0-rc.2 to 2.0.0

2

dist/cjs/evm.js

@@ -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 {

36

dist/cjs/interpreter.js

@@ -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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc