-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3302 from NomicFoundation/add-flag-to-ignore-unkn…
…own-eip-2718-hh-998 Process transactions with unknown tx types
- Loading branch information
Showing
3 changed files
with
182 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"hardhat": patch | ||
--- | ||
|
||
Fixed an issue when forking networks like Arbitrum Nitro that use non-standard transaction types (#2995, #3194). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
...src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { Common } from "@nomicfoundation/ethereumjs-common"; | ||
import { Transaction, TxData, TxOptions } from "@nomicfoundation/ethereumjs-tx"; | ||
import { Address } from "@nomicfoundation/ethereumjs-util"; | ||
|
||
import { InternalError } from "../../../core/providers/errors"; | ||
|
||
/* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */ | ||
|
||
/** | ||
* This class is like `ReadOnlyValidTransaction` but for | ||
* a transaction with an unknown tx type. | ||
*/ | ||
export class ReadOnlyValidUnknownTypeTransaction extends Transaction { | ||
public static fromTxData(_txData: TxData, _opts?: TxOptions): never { | ||
throw new InternalError( | ||
"`fromTxData` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public static fromSerializedTx( | ||
_serialized: Buffer, | ||
_opts?: TxOptions | ||
): never { | ||
throw new InternalError( | ||
"`fromSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public static fromRlpSerializedTx( | ||
_serialized: Buffer, | ||
_opts?: TxOptions | ||
): never { | ||
throw new InternalError( | ||
"`fromRlpSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public static fromValuesArray(_values: Buffer[], _opts?: TxOptions): never { | ||
throw new InternalError( | ||
"`fromRlpSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public readonly common: Common; | ||
|
||
private readonly _sender: Address; | ||
private readonly _actualType: number; | ||
|
||
constructor(sender: Address, type: number, data: TxData = {}) { | ||
super(data, { freeze: false }); | ||
|
||
this.common = this._getCommon(); | ||
this._sender = sender; | ||
this._actualType = type; | ||
} | ||
|
||
public get type(): number { | ||
return this._actualType; | ||
} | ||
|
||
public verifySignature(): boolean { | ||
return true; | ||
} | ||
|
||
public getSenderAddress(): Address { | ||
return this._sender; | ||
} | ||
|
||
public sign(): never { | ||
throw new InternalError( | ||
"`sign` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getDataFee(): never { | ||
throw new InternalError( | ||
"`getDataFee` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getBaseFee(): never { | ||
throw new InternalError( | ||
"`getBaseFee` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getUpfrontCost(): never { | ||
throw new InternalError( | ||
"`getUpfrontCost` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public validate(_stringError?: false): never; | ||
public validate(_stringError: true): never; | ||
public validate(_stringError: boolean = false): never { | ||
throw new InternalError( | ||
"`validate` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public toCreationAddress(): never { | ||
throw new InternalError( | ||
"`toCreationAddress` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getSenderPublicKey(): never { | ||
throw new InternalError( | ||
"`getSenderPublicKey` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getMessageToVerifySignature(): never { | ||
throw new InternalError( | ||
"`getMessageToVerifySignature` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
|
||
public getMessageToSign(): never { | ||
throw new InternalError( | ||
"`getMessageToSign` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
} | ||
} | ||
|
||
// Override private methods | ||
|
||
const ReadOnlyValidUnknownTypeTransactionPrototype: any = | ||
ReadOnlyValidUnknownTypeTransaction.prototype; | ||
|
||
ReadOnlyValidUnknownTypeTransactionPrototype._validateTxV = function ( | ||
_v: any, | ||
common: any | ||
) { | ||
return this._getCommon(common); | ||
}; | ||
|
||
ReadOnlyValidUnknownTypeTransactionPrototype._signedTxImplementsEIP155 = | ||
function () { | ||
throw new InternalError( | ||
"`_signedTxImplementsEIP155` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
}; | ||
|
||
ReadOnlyValidUnknownTypeTransactionPrototype._unsignedTxImplementsEIP155 = | ||
function () { | ||
throw new InternalError( | ||
"`_unsignedTxImplementsEIP155` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
}; | ||
|
||
ReadOnlyValidUnknownTypeTransactionPrototype._getMessageToSign = function () { | ||
throw new InternalError( | ||
"`_getMessageToSign` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
}; | ||
|
||
ReadOnlyValidUnknownTypeTransactionPrototype._processSignature = function () { | ||
throw new InternalError( | ||
"`_processSignature` is not implemented in ReadOnlyValidUnknownTypeTransaction" | ||
); | ||
}; |