mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 11:10:38 +00:00
EIP-4844: rename "data hash" to "blob hash" (#7947)
See https://github.com/ethereum/EIPs/pull/7001
This commit is contained in:
parent
443757edbd
commit
03ac80ad2d
@ -836,6 +836,6 @@ func (m callMsg) Data() []byte { return m.CallMsg.Data }
|
||||
func (m callMsg) AccessList() types2.AccessList { return m.CallMsg.AccessList }
|
||||
func (m callMsg) IsFree() bool { return false }
|
||||
|
||||
func (m callMsg) BlobGas() uint64 { return misc.GetBlobGasUsed(len(m.CallMsg.DataHashes)) }
|
||||
func (m callMsg) BlobGas() uint64 { return misc.GetBlobGasUsed(len(m.CallMsg.BlobHashes)) }
|
||||
func (m callMsg) MaxFeePerBlobGas() *uint256.Int { return m.CallMsg.MaxFeePerBlobGas }
|
||||
func (m callMsg) DataHashes() []libcommon.Hash { return m.CallMsg.DataHashes }
|
||||
func (m callMsg) BlobHashes() []libcommon.Hash { return m.CallMsg.BlobHashes }
|
||||
|
@ -80,7 +80,7 @@ func NewEVMTxContext(msg Message) evmtypes.TxContext {
|
||||
return evmtypes.TxContext{
|
||||
Origin: msg.From(),
|
||||
GasPrice: msg.GasPrice(),
|
||||
DataHashes: msg.DataHashes(),
|
||||
BlobHashes: msg.BlobHashes(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ type Message interface {
|
||||
CheckNonce() bool
|
||||
Data() []byte
|
||||
AccessList() types2.AccessList
|
||||
DataHashes() []libcommon.Hash
|
||||
BlobHashes() []libcommon.Hash
|
||||
|
||||
IsFree() bool
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func (stx BlobTx) copy() *BlobTx {
|
||||
|
||||
func (stx BlobTx) Type() byte { return BlobTxType }
|
||||
|
||||
func (stx BlobTx) GetDataHashes() []libcommon.Hash {
|
||||
func (stx BlobTx) GetBlobHashes() []libcommon.Hash {
|
||||
return stx.BlobVersionedHashes
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ func (stx BlobTx) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Mes
|
||||
if err != nil {
|
||||
return Message{}, err
|
||||
}
|
||||
msg.dataHashes = stx.BlobVersionedHashes
|
||||
msg.blobHashes = stx.BlobVersionedHashes
|
||||
return msg, err
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ func (txw *BlobTxWrapper) GetFeeCap() *uint256.Int { return txw.Tx.GetFeeCap() }
|
||||
|
||||
func (txw *BlobTxWrapper) Cost() *uint256.Int { return txw.Tx.GetFeeCap() }
|
||||
|
||||
func (txw *BlobTxWrapper) GetDataHashes() []libcommon.Hash { return txw.Tx.GetDataHashes() }
|
||||
func (txw *BlobTxWrapper) GetBlobHashes() []libcommon.Hash { return txw.Tx.GetBlobHashes() }
|
||||
|
||||
func (txw *BlobTxWrapper) GetGas() uint64 { return txw.Tx.GetGas() }
|
||||
func (txw *BlobTxWrapper) GetBlobGas() uint64 { return txw.Tx.GetBlobGas() }
|
||||
|
@ -87,8 +87,8 @@ func (ct CommonTx) IsContractDeploy() bool {
|
||||
return ct.GetTo() == nil
|
||||
}
|
||||
|
||||
func (ct *CommonTx) GetDataHashes() []libcommon.Hash {
|
||||
// Only blob txs have data hashes
|
||||
func (ct *CommonTx) GetBlobHashes() []libcommon.Hash {
|
||||
// Only blob txs have blob hashes
|
||||
return []libcommon.Hash{}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ type Transaction interface {
|
||||
GetEffectiveGasTip(baseFee *uint256.Int) *uint256.Int
|
||||
GetFeeCap() *uint256.Int
|
||||
Cost() *uint256.Int
|
||||
GetDataHashes() []libcommon.Hash
|
||||
GetBlobHashes() []libcommon.Hash
|
||||
GetGas() uint64
|
||||
GetBlobGas() uint64
|
||||
GetValue() *uint256.Int
|
||||
@ -525,7 +525,7 @@ type Message struct {
|
||||
accessList types2.AccessList
|
||||
checkNonce bool
|
||||
isFree bool
|
||||
dataHashes []libcommon.Hash
|
||||
blobHashes []libcommon.Hash
|
||||
}
|
||||
|
||||
func NewMessage(from libcommon.Address, to *libcommon.Address, nonce uint64, amount *uint256.Int, gasLimit uint64,
|
||||
@ -593,13 +593,13 @@ func (m *Message) ChangeGas(globalGasCap, desiredGas uint64) {
|
||||
m.gasLimit = gas
|
||||
}
|
||||
|
||||
func (m Message) BlobGas() uint64 { return fixedgas.BlobGasPerBlob * uint64(len(m.dataHashes)) }
|
||||
func (m Message) BlobGas() uint64 { return fixedgas.BlobGasPerBlob * uint64(len(m.blobHashes)) }
|
||||
|
||||
func (m Message) MaxFeePerBlobGas() *uint256.Int {
|
||||
return &m.maxFeePerBlobGas
|
||||
}
|
||||
|
||||
func (m Message) DataHashes() []libcommon.Hash { return m.dataHashes }
|
||||
func (m Message) BlobHashes() []libcommon.Hash { return m.blobHashes }
|
||||
|
||||
func DecodeSSZ(data []byte, dest codec.Deserializable) error {
|
||||
err := dest.Deserialize(codec.NewDecodingReader(bytes.NewReader(data), uint64(len(data))))
|
||||
|
@ -125,7 +125,7 @@ func toBlobTxJSON(tx *BlobTx) *txJSON {
|
||||
enc.R = (*hexutil.Big)(tx.R.ToBig())
|
||||
enc.S = (*hexutil.Big)(tx.S.ToBig())
|
||||
enc.MaxFeePerBlobGas = (*hexutil.Big)(tx.MaxFeePerBlobGas.ToBig())
|
||||
enc.BlobVersionedHashes = tx.GetDataHashes()
|
||||
enc.BlobVersionedHashes = tx.GetBlobHashes()
|
||||
return &enc
|
||||
}
|
||||
|
||||
|
@ -243,22 +243,22 @@ func enable3860(jt *JumpTable) {
|
||||
jt[CREATE2].dynamicGas = gasCreate2Eip3860
|
||||
}
|
||||
|
||||
// enable4844 applies mini-danksharding (DATAHASH Opcode)
|
||||
// - Adds an opcode that returns the versioned data hash of the tx at a index.
|
||||
// enable4844 applies mini-danksharding (BLOBHASH opcode)
|
||||
// - Adds an opcode that returns the versioned blob hash of the tx at a index.
|
||||
func enable4844(jt *JumpTable) {
|
||||
jt[DATAHASH] = &operation{
|
||||
execute: opDataHash,
|
||||
jt[BLOBHASH] = &operation{
|
||||
execute: opBlobHash,
|
||||
constantGas: GasFastestStep,
|
||||
numPop: 1,
|
||||
numPush: 1,
|
||||
}
|
||||
}
|
||||
|
||||
// opDataHash implements DATAHASH opcode
|
||||
func opDataHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||
// opBlobHash implements the BLOBHASH opcode
|
||||
func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||
idx := scope.Stack.Peek()
|
||||
if idx.LtUint64(uint64(len(interpreter.evm.TxContext().DataHashes))) {
|
||||
hash := interpreter.evm.TxContext().DataHashes[idx.Uint64()]
|
||||
if idx.LtUint64(uint64(len(interpreter.evm.TxContext().BlobHashes))) {
|
||||
hash := interpreter.evm.TxContext().BlobHashes[idx.Uint64()]
|
||||
idx.SetBytes(hash.Bytes())
|
||||
} else {
|
||||
idx.Clear()
|
||||
|
@ -42,7 +42,7 @@ type TxContext struct {
|
||||
TxHash common.Hash
|
||||
Origin common.Address // Provides information for ORIGIN
|
||||
GasPrice *uint256.Int // Provides information for GASPRICE
|
||||
DataHashes []common.Hash // Provides versioned data hashes for DATAHASH
|
||||
BlobHashes []common.Hash // Provides versioned blob hashes for BLOBHASH
|
||||
}
|
||||
|
||||
type (
|
||||
|
@ -95,16 +95,16 @@ const (
|
||||
|
||||
// 0x40 range - block operations.
|
||||
const (
|
||||
BLOCKHASH OpCode = 0x40 + iota
|
||||
COINBASE
|
||||
TIMESTAMP
|
||||
NUMBER
|
||||
DIFFICULTY
|
||||
GASLIMIT
|
||||
BLOCKHASH OpCode = 0x40
|
||||
COINBASE OpCode = 0x41
|
||||
TIMESTAMP OpCode = 0x42
|
||||
NUMBER OpCode = 0x43
|
||||
DIFFICULTY OpCode = 0x44
|
||||
GASLIMIT OpCode = 0x45
|
||||
CHAINID OpCode = 0x46
|
||||
SELFBALANCE OpCode = 0x47
|
||||
BASEFEE OpCode = 0x48
|
||||
DATAHASH OpCode = 0x49
|
||||
BLOBHASH OpCode = 0x49
|
||||
)
|
||||
|
||||
// 0x50 range - 'storage' and execution.
|
||||
@ -281,7 +281,7 @@ var opCodeToString = map[OpCode]string{
|
||||
CHAINID: "CHAINID",
|
||||
SELFBALANCE: "SELFBALANCE",
|
||||
BASEFEE: "BASEFEE",
|
||||
DATAHASH: "DATAHASH",
|
||||
BLOBHASH: "BLOBHASH",
|
||||
|
||||
// 0x50 range - 'storage' and execution.
|
||||
POP: "POP",
|
||||
@ -436,7 +436,7 @@ var stringToOp = map[string]OpCode{
|
||||
"CALLDATACOPY": CALLDATACOPY,
|
||||
"CHAINID": CHAINID,
|
||||
"BASEFEE": BASEFEE,
|
||||
"DATAHASH": DATAHASH,
|
||||
"BLOBHASH": BLOBHASH,
|
||||
"DELEGATECALL": DELEGATECALL,
|
||||
"STATICCALL": STATICCALL,
|
||||
"CODESIZE": CODESIZE,
|
||||
|
@ -127,7 +127,7 @@ type CallMsg struct {
|
||||
FeeCap *uint256.Int // EIP-1559 fee cap per gas.
|
||||
Tip *uint256.Int // EIP-1559 tip per gas.
|
||||
AccessList types2.AccessList // EIP-2930 access list.
|
||||
DataHashes []libcommon.Hash // EIP-4844 versioned data hashes.
|
||||
BlobHashes []libcommon.Hash // EIP-4844 versioned blob hashes.
|
||||
}
|
||||
|
||||
// A ContractCaller provides contract calls, essentially transactions that are executed by
|
||||
|
@ -461,7 +461,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
|
||||
// if the transaction has been mined, compute the effective gas price
|
||||
result.GasPrice = computeGasPrice(tx, blockHash, baseFee)
|
||||
result.MaxFeePerBlobGas = (*hexutil.Big)(t.MaxFeePerBlobGas.ToBig())
|
||||
result.BlobVersionedHashes = t.GetDataHashes()
|
||||
result.BlobVersionedHashes = t.GetBlobHashes()
|
||||
}
|
||||
signer := types.LatestSignerForChainID(chainId.ToBig())
|
||||
var err error
|
||||
|
@ -207,7 +207,7 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
|
||||
if version >= clparams.DenebVersion {
|
||||
actualBlobHashes := []libcommon.Hash{}
|
||||
for _, tx := range transactions {
|
||||
actualBlobHashes = append(actualBlobHashes, tx.GetDataHashes()...)
|
||||
actualBlobHashes = append(actualBlobHashes, tx.GetBlobHashes()...)
|
||||
}
|
||||
if !reflect.DeepEqual(actualBlobHashes, expectedBlobHashes) {
|
||||
s.logger.Warn("[NewPayload] mismatch in blob hashes",
|
||||
|
@ -215,7 +215,7 @@ func (s *EngineServerExperimental) newPayload(ctx context.Context, req *engine_t
|
||||
if version >= clparams.DenebVersion {
|
||||
actualBlobHashes := []libcommon.Hash{}
|
||||
for _, tx := range transactions {
|
||||
actualBlobHashes = append(actualBlobHashes, tx.GetDataHashes()...)
|
||||
actualBlobHashes = append(actualBlobHashes, tx.GetBlobHashes()...)
|
||||
}
|
||||
if !reflect.DeepEqual(actualBlobHashes, expectedBlobHashes) {
|
||||
s.logger.Warn("[NewPayload] mismatch in blob hashes",
|
||||
|
@ -166,7 +166,7 @@ func (e *EthereumExecutionModule) GetAssembledBlock(ctx context.Context, req *ex
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected blob transaction to be type BlobTxWrapper, got: %T", blobTx)
|
||||
}
|
||||
versionedHashes, commitments, proofs, blobs := blobTx.GetDataHashes(), blobTx.Commitments, blobTx.Proofs, blobTx.Blobs
|
||||
versionedHashes, commitments, proofs, blobs := blobTx.GetBlobHashes(), blobTx.Commitments, blobTx.Proofs, blobTx.Blobs
|
||||
lenCheck := len(versionedHashes)
|
||||
if lenCheck != len(commitments) || lenCheck != len(proofs) || lenCheck != len(blobs) {
|
||||
return nil, fmt.Errorf("tx %d in block %s has inconsistent commitments (%d) / proofs (%d) / blobs (%d) / "+
|
||||
|
@ -765,7 +765,7 @@ func marshalReceipt(receipt *types.Receipt, txn types.Transaction, chainConfig *
|
||||
fields["contractAddress"] = receipt.ContractAddress
|
||||
}
|
||||
// Set derived blob related fields
|
||||
numBlobs := len(txn.GetDataHashes())
|
||||
numBlobs := len(txn.GetBlobHashes())
|
||||
if numBlobs > 0 {
|
||||
if header.ExcessBlobGas == nil {
|
||||
log.Warn("excess blob gas not set when trying to marshal blob tx")
|
||||
|
Loading…
Reference in New Issue
Block a user