Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tx: rename method names (remove EIP word) #3597

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/block/examples/4844.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createBlock } from '@ethereumjs/block'
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
import { create4844BlobTx } from '@ethereumjs/tx'
import { createBlob4844Tx } from '@ethereumjs/tx'
import { createAddressFromPrivateKey } from '@ethereumjs/util'
import { randomBytes } from 'crypto'
import { loadKZG } from 'kzg-wasm'
Expand All @@ -15,7 +15,7 @@ const main = async () => {
kzg,
},
})
const blobTx = create4844BlobTx(
const blobTx = createBlob4844Tx(
{ blobsData: ['myFirstBlob'], to: createAddressFromPrivateKey(randomBytes(32)) },
{ common },
)
Expand Down
16 changes: 6 additions & 10 deletions packages/block/src/block/block.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConsensusType } from '@ethereumjs/common'
import { RLP } from '@ethereumjs/rlp'
import { Trie } from '@ethereumjs/trie'
import { BlobEIP4844Transaction, Capability } from '@ethereumjs/tx'
import { Blob4844Tx, Capability } from '@ethereumjs/tx'
import {
BIGINT_0,
CLRequestType,
Expand Down Expand Up @@ -34,11 +34,7 @@ import {
/* eslint-enable */
import type { BlockBytes, BlockOptions, ExecutionPayload, JsonBlock } from '../types.js'
import type { Common } from '@ethereumjs/common'
import type {
FeeMarketEIP1559Transaction,
LegacyTransaction,
TypedTransaction,
} from '@ethereumjs/tx'
import type { FeeMarket1559Tx, LegacyTx, TypedTransaction } from '@ethereumjs/tx'
import type {
CLRequest,
ConsolidationRequest,
Expand Down Expand Up @@ -284,12 +280,12 @@ export class Block {
const errs = tx.getValidationErrors()
if (this.common.isActivatedEIP(1559)) {
if (tx.supports(Capability.EIP1559FeeMarket)) {
tx = tx as FeeMarketEIP1559Transaction
tx = tx as FeeMarket1559Tx
if (tx.maxFeePerGas < this.header.baseFeePerGas!) {
errs.push('tx unable to pay base fee (EIP-1559 tx)')
}
} else {
tx = tx as LegacyTransaction
tx = tx as LegacyTx
if (tx.gasPrice < this.header.baseFeePerGas!) {
errs.push('tx unable to pay base fee (non EIP-1559 tx)')
}
Expand All @@ -298,7 +294,7 @@ export class Block {
if (this.common.isActivatedEIP(4844)) {
const blobGasLimit = this.common.param('maxblobGasPerBlock')
const blobGasPerBlob = this.common.param('blobGasPerBlob')
if (tx instanceof BlobEIP4844Transaction) {
if (tx instanceof Blob4844Tx) {
blobGasUsed += BigInt(tx.numBlobs()) * blobGasPerBlob
if (blobGasUsed > blobGasLimit) {
errs.push(
Expand Down Expand Up @@ -414,7 +410,7 @@ export class Block {
let blobGasPrice

for (const tx of this.transactions) {
if (tx instanceof BlobEIP4844Transaction) {
if (tx instanceof Blob4844Tx) {
blobGasPrice = blobGasPrice ?? this.header.getBlobGasPrice()
if (tx.maxFeePerBlobGas < blobGasPrice) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions packages/block/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RLP } from '@ethereumjs/rlp'
import { Trie } from '@ethereumjs/trie'
import { BlobEIP4844Transaction } from '@ethereumjs/tx'
import { Blob4844Tx } from '@ethereumjs/tx'
import { BIGINT_0, BIGINT_1, TypeOutput, isHexString, toType } from '@ethereumjs/util'

import type { BlockHeaderBytes, HeaderData } from './types.js'
Expand Down Expand Up @@ -96,7 +96,7 @@ export function getDifficulty(headerData: HeaderData): bigint | null {
export const getNumBlobs = (transactions: TypedTransaction[]) => {
let numBlobs = 0
for (const tx of transactions) {
if (tx instanceof BlobEIP4844Transaction) {
if (tx instanceof Blob4844Tx) {
numBlobs += tx.blobVersionedHashes.length
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/block/test/eip1559block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
import { create1559FeeMarketTx } from '@ethereumjs/tx'
import { createFeeMarket1559Tx } from '@ethereumjs/tx'
import { hexToBytes } from '@ethereumjs/util'
import { assert, describe, it } from 'vitest'

Expand Down Expand Up @@ -408,7 +408,7 @@ describe('EIP1559 tests', () => {
})

it('Header -> validateTransactions() -> tx', async () => {
const transaction = create1559FeeMarketTx(
const transaction = createFeeMarket1559Tx(
{
maxFeePerGas: BigInt(0),
maxPriorityFeePerGas: BigInt(0),
Expand Down
6 changes: 3 additions & 3 deletions packages/block/test/eip4844block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Common, Hardfork, Mainnet, createCommonFromGethGenesis } from '@ethereumjs/common'
import { create4844BlobTx } from '@ethereumjs/tx'
import { createBlob4844Tx } from '@ethereumjs/tx'
import {
blobsToCommitments,
commitmentsToVersionedHashes,
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('transaction validation tests', () => {
const commitments = blobsToCommitments(kzg, blobs)
const blobVersionedHashes = commitmentsToVersionedHashes(commitments)

const tx1 = create4844BlobTx(
const tx1 = createBlob4844Tx(
{
blobVersionedHashes,
blobs,
Expand All @@ -187,7 +187,7 @@ describe('transaction validation tests', () => {
},
{ common },
).sign(randomBytes(32))
const tx2 = create4844BlobTx(
const tx2 = createBlob4844Tx(
{
blobVersionedHashes,
blobs,
Expand Down
6 changes: 2 additions & 4 deletions packages/block/test/from-rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as blockDataWithWithdrawals from './testdata/testdata-from-rpc-with-wit
import * as blockData from './testdata/testdata-from-rpc.json'

import type { JsonRpcBlock } from '../src/index.js'
import type { LegacyTransaction } from '@ethereumjs/tx'
import type { LegacyTx } from '@ethereumjs/tx'
import type { PrefixedHexString } from '@ethereumjs/util'

describe('[fromRPC]: block #2924874', () => {
Expand Down Expand Up @@ -69,9 +69,7 @@ describe('[fromRPC]:', () => {
{ common },
)
assert.equal(
(
createBlockFromTransactionGasPriceAsInteger.transactions[0] as LegacyTransaction
).gasPrice.toString(),
(createBlockFromTransactionGasPriceAsInteger.transactions[0] as LegacyTx).gasPrice.toString(),
gasPriceAsIntegerString,
)
})
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/miner/pendingBlock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hardfork } from '@ethereumjs/common'
import { BlobEIP4844Transaction } from '@ethereumjs/tx'
import { Blob4844Tx } from '@ethereumjs/tx'

Check warning on line 2 in packages/client/src/miner/pendingBlock.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/miner/pendingBlock.ts#L2

Added line #L2 was not covered by tests
import {
BIGINT_1,
BIGINT_2,
Expand Down Expand Up @@ -322,7 +322,7 @@
switch (addTxResult) {
case AddTxResult.Success:
// Push the tx in blobTxs only after successful addTransaction
if (tx instanceof BlobEIP4844Transaction) blobTxs.push(tx)
if (tx instanceof Blob4844Tx) blobTxs.push(tx)

Check warning on line 325 in packages/client/src/miner/pendingBlock.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/miner/pendingBlock.ts#L325

Added line #L325 was not covered by tests
break

case AddTxResult.BlockFull:
Expand Down Expand Up @@ -382,10 +382,10 @@
/**
* An internal helper for storing the blob bundle associated with each transaction in an EIP4844 world
* @param payloadId the payload Id of the pending block
* @param txs an array of {@BlobEIP4844Transaction } transactions
* @param txs an array of {@Blob4844Tx } transactions

Check warning on line 385 in packages/client/src/miner/pendingBlock.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/miner/pendingBlock.ts#L385

Added line #L385 was not covered by tests
* @param blockHash the blockhash of the pending block (computed from the header data provided)
*/
private constructBlobsBundle = (payloadId: string, txs: BlobEIP4844Transaction[]) => {
private constructBlobsBundle = (payloadId: string, txs: Blob4844Tx[]) => {

Check warning on line 388 in packages/client/src/miner/pendingBlock.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/miner/pendingBlock.ts#L388

Added line #L388 was not covered by tests
let blobs: Uint8Array[] = []
let commitments: Uint8Array[] = []
let proofs: Uint8Array[] = []
Expand All @@ -397,7 +397,7 @@
}

for (let tx of txs) {
tx = tx as BlobEIP4844Transaction
tx = tx as Blob4844Tx

Check warning on line 400 in packages/client/src/miner/pendingBlock.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/miner/pendingBlock.ts#L400

Added line #L400 was not covered by tests
if (tx.blobs !== undefined && tx.blobs.length > 0) {
blobs = blobs.concat(tx.blobs)
commitments = commitments.concat(tx.kzgCommitments!)
Expand Down
24 changes: 10 additions & 14 deletions packages/client/src/net/protocol/ethprotocol.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createBlockFromBytesArray, createBlockHeaderFromBytesArray } from '@ethereumjs/block'
import { RLP } from '@ethereumjs/rlp'
import {
BlobEIP4844Transaction,
create4844BlobTxFromSerializedNetworkWrapper,
Blob4844Tx,
createBlob4844TxFromSerializedNetworkWrapper,

Check warning on line 5 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L4-L5

Added lines #L4 - L5 were not covered by tests
createTxFromBlockBodyData,
createTxFromSerializedData,
isAccessListEIP2930Tx,
isBlobEIP4844Tx,
isEOACodeEIP7702Tx,
isFeeMarketEIP1559Tx,
isAccessList2930Tx,
isBlob4844Tx,
isEOACode7702Tx,
isFeeMarket1559Tx,

Check warning on line 11 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L8-L11

Added lines #L8 - L11 were not covered by tests
isLegacyTx,
} from '@ethereumjs/tx'
import {
Expand Down Expand Up @@ -117,7 +117,7 @@
const serializedTxs = []
for (const tx of txs) {
// Don't automatically broadcast blob transactions - they should only be announced using NewPooledTransactionHashes
if (tx instanceof BlobEIP4844Transaction) continue
if (tx instanceof Blob4844Tx) continue

Check warning on line 120 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L120

Added line #L120 was not covered by tests
serializedTxs.push(tx.serialize())
}
return serializedTxs
Expand Down Expand Up @@ -253,13 +253,9 @@
const serializedTxs = []
for (const tx of txs) {
// serialize txs as per type
if (isBlobEIP4844Tx(tx)) {
if (isBlob4844Tx(tx)) {

Check warning on line 256 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L256

Added line #L256 was not covered by tests
serializedTxs.push(tx.serializeNetworkWrapper())
} else if (
isFeeMarketEIP1559Tx(tx) ||
isAccessListEIP2930Tx(tx) ||
isEOACodeEIP7702Tx(tx)
) {
} else if (isFeeMarket1559Tx(tx) || isAccessList2930Tx(tx) || isEOACode7702Tx(tx)) {

Check warning on line 258 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L258

Added line #L258 was not covered by tests
serializedTxs.push(tx.serialize())
} else if (isLegacyTx(tx)) {
serializedTxs.push(tx.raw())
Expand Down Expand Up @@ -288,7 +284,7 @@
txs.map((txData) => {
// Blob transactions are deserialized with network wrapper
if (txData[0] === 3) {
return create4844BlobTxFromSerializedNetworkWrapper(txData, { common })
return createBlob4844TxFromSerializedNetworkWrapper(txData, { common })

Check warning on line 287 in packages/client/src/net/protocol/ethprotocol.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/net/protocol/ethprotocol.ts#L287

Added line #L287 was not covered by tests
} else {
return createTxFromBlockBodyData(txData, { common })
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/rpc/modules/engine/util/newPayload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBlockFromExecutionPayload } from '@ethereumjs/block'
import { BlobEIP4844Transaction } from '@ethereumjs/tx'
import { Blob4844Tx } from '@ethereumjs/tx'

Check warning on line 2 in packages/client/src/rpc/modules/engine/util/newPayload.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/engine/util/newPayload.ts#L2

Added line #L2 was not covered by tests
import { equalsBytes, hexToBytes } from '@ethereumjs/util'

import { short } from '../../../../util/index.js'
Expand Down Expand Up @@ -59,7 +59,7 @@
// Collect versioned hashes in the flat array `txVersionedHashes` to match with received
const txVersionedHashes = []
for (const tx of headBlock.transactions) {
if (tx instanceof BlobEIP4844Transaction) {
if (tx instanceof Blob4844Tx) {

Check warning on line 62 in packages/client/src/rpc/modules/engine/util/newPayload.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/engine/util/newPayload.ts#L62

Added line #L62 was not covered by tests
for (const vHash of tx.blobVersionedHashes) {
txVersionedHashes.push(vHash)
}
Expand Down
34 changes: 15 additions & 19 deletions packages/client/src/rpc/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Hardfork } from '@ethereumjs/common'
import {
Capability,
create4844BlobTxFromSerializedNetworkWrapper,
createBlob4844TxFromSerializedNetworkWrapper,

Check warning on line 5 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L5

Added line #L5 was not covered by tests
createTxFromSerializedData,
createTxFromTxData,
} from '@ethereumjs/tx'
Expand Down Expand Up @@ -47,11 +47,7 @@
import type { Block, JsonRpcBlock } from '@ethereumjs/block'
import type { Log } from '@ethereumjs/evm'
import type { Proof } from '@ethereumjs/statemanager'
import type {
FeeMarketEIP1559Transaction,
LegacyTransaction,
TypedTransaction,
} from '@ethereumjs/tx'
import type { FeeMarket1559Tx, LegacyTx, TypedTransaction } from '@ethereumjs/tx'

Check warning on line 50 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L50

Added line #L50 was not covered by tests
import type { Address, PrefixedHexString } from '@ethereumjs/util'

const EMPTY_SLOT = `0x${'00'.repeat(32)}`
Expand Down Expand Up @@ -965,13 +961,13 @@
const { blobGasPrice, blobGasUsed } = runBlockResult.receipts[i] as EIP4844BlobTxReceipt
const effectiveGasPrice =
tx.supports(Capability.EIP1559FeeMarket) === true
? (tx as FeeMarketEIP1559Transaction).maxPriorityFeePerGas <
(tx as FeeMarketEIP1559Transaction).maxFeePerGas - block.header.baseFeePerGas!
? (tx as FeeMarketEIP1559Transaction).maxPriorityFeePerGas
: (tx as FeeMarketEIP1559Transaction).maxFeePerGas -
? (tx as FeeMarket1559Tx).maxPriorityFeePerGas <
(tx as FeeMarket1559Tx).maxFeePerGas - block.header.baseFeePerGas!
? (tx as FeeMarket1559Tx).maxPriorityFeePerGas
: (tx as FeeMarket1559Tx).maxFeePerGas -

Check warning on line 967 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L964-L967

Added lines #L964 - L967 were not covered by tests
block.header.baseFeePerGas! +
block.header.baseFeePerGas!
: (tx as LegacyTransaction).gasPrice
: (tx as LegacyTx).gasPrice

Check warning on line 970 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L970

Added line #L970 was not covered by tests

return jsonRpcReceipt(
r,
Expand Down Expand Up @@ -1016,13 +1012,13 @@
const parentBlock = await this._chain.getBlock(block.header.parentHash)
const tx = block.transactions[txIndex]
const effectiveGasPrice = tx.supports(Capability.EIP1559FeeMarket)
? (tx as FeeMarketEIP1559Transaction).maxPriorityFeePerGas <
(tx as FeeMarketEIP1559Transaction).maxFeePerGas - block.header.baseFeePerGas!
? (tx as FeeMarketEIP1559Transaction).maxPriorityFeePerGas
: (tx as FeeMarketEIP1559Transaction).maxFeePerGas -
? (tx as FeeMarket1559Tx).maxPriorityFeePerGas <
(tx as FeeMarket1559Tx).maxFeePerGas - block.header.baseFeePerGas!
? (tx as FeeMarket1559Tx).maxPriorityFeePerGas
: (tx as FeeMarket1559Tx).maxFeePerGas -

Check warning on line 1018 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L1015-L1018

Added lines #L1015 - L1018 were not covered by tests
block.header.baseFeePerGas! +
block.header.baseFeePerGas!
: (tx as LegacyTransaction).gasPrice
: (tx as LegacyTx).gasPrice

Check warning on line 1021 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L1021

Added line #L1021 was not covered by tests

const vmCopy = await this._vm!.shallowCopy()
vmCopy.common.setHardfork(tx.common.hardfork())
Expand Down Expand Up @@ -1172,7 +1168,7 @@
const txBuf = hexToBytes(serializedTx)
if (txBuf[0] === 0x03) {
// Blob Transactions sent over RPC are expected to be in Network Wrapper format
tx = create4844BlobTxFromSerializedNetworkWrapper(txBuf, { common })
tx = createBlob4844TxFromSerializedNetworkWrapper(txBuf, { common })

Check warning on line 1171 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L1171

Added line #L1171 was not covered by tests

const blobGasLimit = tx.common.param('maxblobGasPerBlock')
const blobGasPerBlob = tx.common.param('blobGasPerBlob')
Expand Down Expand Up @@ -1341,7 +1337,7 @@
let priorityFee = BIGINT_0
const block = await this._chain.getBlock(latest.number)
for (const tx of block.transactions) {
const maxPriorityFeePerGas = (tx as FeeMarketEIP1559Transaction).maxPriorityFeePerGas
const maxPriorityFeePerGas = (tx as FeeMarket1559Tx).maxPriorityFeePerGas

Check warning on line 1340 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L1340

Added line #L1340 was not covered by tests
priorityFee += maxPriorityFeePerGas
}

Expand All @@ -1360,7 +1356,7 @@
}

for (const tx of block.transactions) {
const txGasPrice = (tx as LegacyTransaction).gasPrice
const txGasPrice = (tx as LegacyTx).gasPrice

Check warning on line 1359 in packages/client/src/rpc/modules/eth.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/rpc/modules/eth.ts#L1359

Added line #L1359 was not covered by tests
gasPrice += txGasPrice
txCount++
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/service/fullethereumservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import type { Peer } from '../net/peer/peer.js'
import type { Protocol } from '../net/protocol/index.js'
import type { Block } from '@ethereumjs/block'
import type { BlobEIP4844Transaction } from '@ethereumjs/tx'
import type { Blob4844Tx } from '@ethereumjs/tx'

Check warning on line 22 in packages/client/src/service/fullethereumservice.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/fullethereumservice.ts#L22

Added line #L22 was not covered by tests

interface FullEthereumServiceOptions extends ServiceOptions {
/** Serve LES requests (default: false) */
Expand Down Expand Up @@ -175,7 +175,7 @@
if (rawTx.type !== TransactionType.BlobEIP4844) {
txs[1].push(rawTx.serialize().byteLength)
} else {
txs[1].push((rawTx as BlobEIP4844Transaction).serializeNetworkWrapper().byteLength)
txs[1].push((rawTx as Blob4844Tx).serializeNetworkWrapper().byteLength)

Check warning on line 178 in packages/client/src/service/fullethereumservice.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/fullethereumservice.ts#L178

Added line #L178 was not covered by tests
}
txs[2].push(hexToBytes(`0x${tx.hash}`))
}
Expand Down
Loading
Loading