diff --git a/src/chains/ethereum/block/src/runtime-block.ts b/src/chains/ethereum/block/src/runtime-block.ts index 07a7770081..e4f1e19f01 100644 --- a/src/chains/ethereum/block/src/runtime-block.ts +++ b/src/chains/ethereum/block/src/runtime-block.ts @@ -19,7 +19,7 @@ import { Common } from "@ethereumjs/common"; export type BlockHeader = { parentHash: Data; sha3Uncles: Data; - miner: Data; + miner: Address; stateRoot: Data; transactionsRoot: Data; receiptsRoot: Data; @@ -56,7 +56,7 @@ export function makeHeader( return { parentHash: Data.from(raw[0], 32), sha3Uncles: Data.from(raw[1], 32), - miner: Data.from(raw[2], 20), + miner: Address.from(raw[2]), stateRoot: Data.from(raw[3], 32), transactionsRoot: Data.from(raw[4], 32), receiptsRoot: Data.from(raw[5], 32), @@ -113,7 +113,7 @@ export class RuntimeBlock { withdrawalsRoot?: Buffer ) { this._common = common; - const coinbaseBuffer = coinbase.toBuffer(); + const coinbaseBuffer = coinbase.buf; this.header = { parentHash: parentHash.toBuffer(), coinbase: new Address(coinbaseBuffer), @@ -183,7 +183,7 @@ export class RuntimeBlock { tx.raw.length === 9 ? tx.raw // legacy transactions don't have their own encoding : tx.serialized ?? encodeWithPrefix(tx.type.toNumber(), tx.raw); - extraTxs[i] = [tx.from.toBuffer(), tx.hash.toBuffer()]; + extraTxs[i] = [tx.from.buf, tx.hash.toBuffer()]; } const rawBlock: EthereumRawBlock = isEip4895 ? [rawHeader, txs, [], []] diff --git a/src/chains/ethereum/ethereum/src/api.ts b/src/chains/ethereum/ethereum/src/api.ts index c112eab492..a6a62290ef 100644 --- a/src/chains/ethereum/ethereum/src/api.ts +++ b/src/chains/ethereum/ethereum/src/api.ts @@ -1117,7 +1117,7 @@ export default class EthereumApi implements Api { blockchain.common, Quantity.from((parentHeader.number.toBigInt() || 0n) + 1n), parentHeader.parentHash, - new Address(parentHeader.miner.toBuffer()), + new Address(parentHeader.miner.buf), tx.gas, parentHeader.gasUsed, parentHeader.timestamp, @@ -1971,7 +1971,7 @@ export default class EthereumApi implements Api { paddedPosBuff = posBuff.slice(-32); } - const addressBuf = Address.from(address).toBuffer(); + const addressBuf = Address.toBuffer(address); const addressData = await trie.get(addressBuf); // An address's stateRoot is stored in the 3rd rlp entry const addressStateRoot = decode(addressData)[2]; diff --git a/src/chains/ethereum/ethereum/src/blockchain.ts b/src/chains/ethereum/ethereum/src/blockchain.ts index e09d9230cb..a18ad120e0 100644 --- a/src/chains/ethereum/ethereum/src/blockchain.ts +++ b/src/chains/ethereum/ethereum/src/blockchain.ts @@ -734,7 +734,7 @@ export default class Blockchain extends Emittery { #commitAccounts = (accounts: Account[]) => { return Promise.all( accounts.map(account => - this.trie.put(account.address.toBuffer(), account.serialize()) + this.trie.put(account.address.buf, account.serialize()) ) ); }; @@ -1124,7 +1124,7 @@ export default class Blockchain extends Emittery { // subtract out the transaction's base fee from the gas limit before // simulating the tx, because `runCall` doesn't account for raw gas costs. const hasToAddress = transaction.to != null; - const to = hasToAddress ? new Address(transaction.to.toBuffer()) : null; + const to = hasToAddress ? new Address(transaction.to.buf) : null; //todo: getCommonForBlockNumber doesn't presently respect shanghai, so we just assume it's the same common as the fork // this won't work as expected if simulating on blocks before shanghai. @@ -1209,7 +1209,7 @@ export default class Blockchain extends Emittery { } }); - const caller = transaction.from.toBuffer(); + const caller = transaction.from.buf; const callerAddress = new Address(caller); if (common.isActivatedEIP(2929)) { diff --git a/src/chains/ethereum/ethereum/src/data-managers/account-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/account-manager.ts index 8aa238bd75..c03b1a2a85 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/account-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/account-manager.ts @@ -37,7 +37,7 @@ export default class AccountManager { trieCopy.setContext(stateRoot.toBuffer(), null, number); // get the account from the trie - return await trieCopy.get(address.toBuffer()); + return await trieCopy.get(address.buf); } public async getNonce( diff --git a/src/chains/ethereum/ethereum/src/data-managers/block-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/block-manager.ts index c2b0665898..109a595a61 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/block-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/block-manager.ts @@ -79,7 +79,7 @@ export default class BlockManager extends Manager { const header: EthereumRawBlockHeader = [ Data.toBuffer(json.parentHash), Data.toBuffer(json.sha3Uncles), - Address.from(json.miner).toBuffer(), + Address.toBuffer(json.miner), Data.toBuffer(json.stateRoot), Data.toBuffer(json.transactionsRoot), Data.toBuffer(json.receiptsRoot), diff --git a/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts b/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts index adaeb39990..e43fcdcdf6 100644 --- a/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts +++ b/src/chains/ethereum/ethereum/src/data-managers/transaction-receipt-manager.ts @@ -28,7 +28,7 @@ export default class TransactionReceiptManager extends Manager [ - Address.from(log.address).toBuffer(), + Address.toBuffer(log.address), log.topics.map(topic => Data.toBuffer(topic)), Array.isArray(log.data) ? log.data.map(data => Data.toBuffer(data)) @@ -38,7 +38,7 @@ export default class TransactionReceiptManager extends Manager Address.from(a.toLowerCase()).toBuffer() + a => Address.toBuffer(a.toLowerCase()) ) : []; const topics = filter.topics ? filter.topics : []; diff --git a/src/chains/ethereum/ethereum/src/wallet.ts b/src/chains/ethereum/ethereum/src/wallet.ts index 59d4d2b528..5e75ddb3a3 100644 --- a/src/chains/ethereum/ethereum/src/wallet.ts +++ b/src/chains/ethereum/ethereum/src/wallet.ts @@ -634,7 +634,7 @@ export default class Wallet { public createFakePrivateKey(address: string) { let fakePrivateKey: Buffer; - const addressBuf = Address.from(address).toBuffer(); + const addressBuf = Address.toBuffer(address); if (addressBuf.equals(ACCOUNT_ZERO)) { // allow signing with the 0x0 address... // always sign with the same fake key, a 31 `0`s followed by a single diff --git a/src/chains/ethereum/transaction/src/base-transaction.ts b/src/chains/ethereum/transaction/src/base-transaction.ts index 9068df855a..c3fa422fbc 100644 --- a/src/chains/ethereum/transaction/src/base-transaction.ts +++ b/src/chains/ethereum/transaction/src/base-transaction.ts @@ -129,8 +129,7 @@ export class BaseTransaction { } public calculateIntrinsicGas() { - const hasToAddress = - this.to != null && !this.to.toBuffer().equals(BUFFER_EMPTY); + const hasToAddress = this.to != null && !this.to.buf.equals(BUFFER_EMPTY); return calculateIntrinsicGas(this.data, hasToAddress, this.common); } } diff --git a/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts b/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts index 31f111edfb..a0a2e044f5 100644 --- a/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts +++ b/src/chains/ethereum/transaction/src/eip1559-fee-market-transaction.ts @@ -222,7 +222,7 @@ export class EIP1559FeeMarketTransaction extends RuntimeTransaction { this.maxPriorityFeePerGas.toBuffer(), this.maxFeePerGas.toBuffer(), this.gas.toBuffer(), - this.to ? this.to.toBuffer() : BUFFER_EMPTY, + this.to ? this.to.buf : BUFFER_EMPTY, this.value.toBuffer(), this.data.toBuffer(), this.accessList, diff --git a/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts b/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts index 52bb0b6f09..f02de9ede8 100644 --- a/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts +++ b/src/chains/ethereum/transaction/src/eip2930-access-list-transaction.ts @@ -207,7 +207,7 @@ export class EIP2930AccessListTransaction extends RuntimeTransaction { this.nonce.toBuffer(), this.gasPrice.toBuffer(), this.gas.toBuffer(), - this.to ? this.to.toBuffer() : BUFFER_EMPTY, + this.to ? this.to.buf : BUFFER_EMPTY, this.value.toBuffer(), this.data.toBuffer(), this.accessList, diff --git a/src/chains/ethereum/transaction/src/legacy-transaction.ts b/src/chains/ethereum/transaction/src/legacy-transaction.ts index e46f453f07..5bf422a570 100644 --- a/src/chains/ethereum/transaction/src/legacy-transaction.ts +++ b/src/chains/ethereum/transaction/src/legacy-transaction.ts @@ -204,7 +204,7 @@ export class LegacyTransaction extends RuntimeTransaction { this.nonce.toBuffer(), this.gasPrice.toBuffer(), this.gas.toBuffer(), - this.to ? this.to.toBuffer() : BUFFER_EMPTY, + this.to ? this.to.buf : BUFFER_EMPTY, this.value.toBuffer(), this.data.toBuffer(), v, diff --git a/src/chains/ethereum/transaction/src/runtime-transaction.ts b/src/chains/ethereum/transaction/src/runtime-transaction.ts index 88ba7a7a6d..2f5214f219 100644 --- a/src/chains/ethereum/transaction/src/runtime-transaction.ts +++ b/src/chains/ethereum/transaction/src/runtime-transaction.ts @@ -112,7 +112,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { // block it twice for each block save step. legacy ? this.raw : ([this.type.toBuffer(), ...this.raw] as any), [ - this.from.toBuffer(), + this.from.buf, this.hash.toBuffer(), blockHash.toBuffer(), blockNumber.toBuffer(), @@ -201,7 +201,7 @@ export abstract class RuntimeTransaction extends BaseTransaction { // and `s` values, make sure the `from` address matches if (data.from !== null) { const userFrom = toValidLengthAddress(data.from, "from"); - if (!from.toBuffer().equals(userFrom.toBuffer())) { + if (!from.buf.equals(userFrom.buf)) { throw new Error( "Transaction is signed and contains a `from` field, but the signature doesn't match." ); diff --git a/src/chains/ethereum/utils/src/things/blocklogs.ts b/src/chains/ethereum/utils/src/things/blocklogs.ts index fc8f0c0aec..0dc777af91 100644 --- a/src/chains/ethereum/utils/src/things/blocklogs.ts +++ b/src/chains/ethereum/utils/src/things/blocklogs.ts @@ -143,7 +143,7 @@ export class BlockLogs { const transactionHash = Data.from(log.transactionHash, 32); const transactionIndex = Quantity.from(log.transactionIndex); blockLogs.append(transactionIndex, transactionHash, [ - address.toBuffer(), // `address` + address.buf, topics, data ]);