-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for raw blob txs in automine mode #341
Add support for raw blob txs in automine mode #341
Comments
Example of a raw blob transaction: blob.json This was generated with private key It has a single blob that starts with
|
@fvictorio should See execution-spec and geth PR |
I'd say that can be done as a separate issue. I opened #390 for it. |
@fvictorio Is this a blob transaction request or a signed transaction?
|
Signed. You should be able to send it with |
@fvictorio do you happen to have the blob, commitment, proof, and blob hash for the example? That'd make my test case easier :) |
Assuming I didn't make a mistake: |
I get this caller address when I recover it from the signature |
I tried to recover the address using viem and I also got the wrong address at first (albeit a different one). This is the code I used: import * as viem from "viem";
import fs from "fs"
const serializedTransaction = JSON.parse(fs.readFileSync("blob.json", "utf8"))
const transaction = viem.parseTransaction(serializedTransaction)
const signature =
viem.signatureToHex({
r: transaction.r,
s: transaction.s,
v: transaction.v,
yParity: transaction.yParity,
})
const serialized = viem.serializeTransaction({
...transaction,
r: undefined,
s: undefined,
v: undefined,
yParity: undefined,
})
console.log(await viem.recoverAddress({
hash: viem.keccak256(serialized),
signature,
})) Then I made this change and got the right address: diff --git a/index.mjs b/index.mjs
index caa31e4..2283676 100644
--- a/index.mjs
+++ b/index.mjs
@@ -19,6 +19,7 @@ const serialized = viem.serializeTransaction({
s: undefined,
v: undefined,
yParity: undefined,
+ sidecars: undefined,
})
console.log(await viem.recoverAddress({ Maybe that helps? This means that the fields involved in the hash are:
which matches what the EIP says. |
Hash of that tx: |
Transaction with 4 blobs: Same parameters as in #341 (comment), except that it has four blobs. |
This issue is about adding support for blob transactions in a limited context:
eth_sendRawTransaction
methodDefinition of done
eth_sendRawTransaction
BLOBHASH
opcode can be used to access the blobs in the transactioneth_sendTransaction
is used to send a blob tx, we show an error that includes a link to Add support for blob transactions sent witheth_sendTransaction
hardhat#5023eth_getTransaction*
methodsblobGasUsed
andexcessBlobGas
).eth_blobBaseFee
method that returns the current blob base fee.ReplayBlock
tool should be updated to take blobs into consideration.Blob transactions
A blob transaction can have between 1 and 6 blobs. The EIP doesn't forbid blob transactions with 0 blobs AFAICT, but geth rejects them with a "blobless blob transaction" error.
BLOBHASH
opcodeThe
BLOBHASH
opcode can be used to read the blob hashes of the transaction that is being executed.Given this contract:
whose deployment bytecode is
Sending a blob transaction to its address with input data
0x2069b0c7
(the selector ofreadBlobs()
) should set the respective storage slots to the blob hashes it received.If an index that doesn't correspond to a blob is used, the opcode returns 32 bytes of zeroes.
Fetched blob transactions
The result of fething a blob transaction looks like this:
This is just like an EIP-1559 transaction with two extra fields:
maxFeePerBlobGas
andblobVersionedHashes
.Fetched receipts
Receipts from blob transactions don't have anything different from receipts from other transaction types.
Block header fields
The two important block header fields related to blob transactions are
blobGasUsed
andexcessBlobGas
.blobGasUsed
is simple: it's basicallyblobs_in_block * 0x20000
, because each blob usesexcessBlobGas
is a cumulative measure, which is computed like this (taken directly from geth's code, but self-explanatory):The target blocb gas per block is something that can change between hardforks, but right now is 0x60000. This means that blocks with 3 or fewer blobs will be under the target. Some examples might clarify this:
Blob base fee update
The blob base fee grows exponentially with the excess blob gas in the block. If the excess blob gas is 0 or low, then the base fee is just 1. But as the excess blob gas accumulates, the base fee starts to grow.
The fee is computed using an integer approximation. Here's the typescript code:
(Here's geth's version, in case it also helps.)
The constants come from the EIP, and we can take them from REVM's primitives.
BLOBBASEFEE
opcode neweth_blobBaseFee
methodThese two are (hopefully) self-explanatory. In both cases you don't specify the block number; the value is the "current" blob base fee, which means the blob base fee computed from the latest block's fields.
The text was updated successfully, but these errors were encountered: