mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-01 17:43:45 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
61509f1dc0
11 changed files with 55 additions and 43 deletions
|
|
@ -106,7 +106,10 @@ func TestCreation(t *testing.T) {
|
|||
{1735370, 0, ID{Hash: checksumToBytes(0xfe3366e7), Next: 1735371}}, // Last London block
|
||||
{1735371, 0, ID{Hash: checksumToBytes(0xb96cbd13), Next: 1677557088}}, // First MergeNetsplit block
|
||||
{1735372, 1677557087, ID{Hash: checksumToBytes(0xb96cbd13), Next: 1677557088}}, // Last MergeNetsplit block
|
||||
{1735372, 1677557088, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 0}}, // First Shanghai block
|
||||
{1735372, 1677557088, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 1706655072}}, // First Shanghai block
|
||||
{1735372, 1706655071, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 1706655072}}, // Last Shanghai block
|
||||
{1735372, 1706655072, ID{Hash: checksumToBytes(0x88cf81d9), Next: 0}}, // First Cancun block
|
||||
{1735372, 2706655072, ID{Hash: checksumToBytes(0x88cf81d9), Next: 0}}, // Future Cancun block
|
||||
},
|
||||
},
|
||||
// Holesky test cases
|
||||
|
|
@ -114,9 +117,12 @@ func TestCreation(t *testing.T) {
|
|||
params.HoleskyChainConfig,
|
||||
core.DefaultHoleskyGenesisBlock().ToBlock(),
|
||||
[]testcase{
|
||||
{0, 0, ID{Hash: checksumToBytes(0xc61a6098), Next: 1696000704}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris block
|
||||
{123, 0, ID{Hash: checksumToBytes(0xc61a6098), Next: 1696000704}}, // First MergeNetsplit block
|
||||
{123, 1696000704, ID{Hash: checksumToBytes(0xfd4f016b), Next: 0}}, // Last MergeNetsplit block
|
||||
{0, 0, ID{Hash: checksumToBytes(0xc61a6098), Next: 1696000704}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London, Paris block
|
||||
{123, 0, ID{Hash: checksumToBytes(0xc61a6098), Next: 1696000704}}, // First MergeNetsplit block
|
||||
{123, 1696000704, ID{Hash: checksumToBytes(0xfd4f016b), Next: 1707305664}}, // First Shanghai block
|
||||
{123, 1707305663, ID{Hash: checksumToBytes(0xfd4f016b), Next: 1707305664}}, // Last Shanghai block
|
||||
{123, 1707305664, ID{Hash: checksumToBytes(0x9b192ad0), Next: 0}}, // First Cancun block
|
||||
{123, 2707305664, ID{Hash: checksumToBytes(0x9b192ad0), Next: 0}}, // Future Cancun block
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
cmath "github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
|
|
@ -324,9 +325,8 @@ func (st *StateTransition) preCheck() error {
|
|||
return ErrMissingBlobHashes
|
||||
}
|
||||
for i, hash := range msg.BlobHashes {
|
||||
if hash[0] != params.BlobTxHashVersion {
|
||||
return fmt.Errorf("blob %d hash version mismatch (have %d, supported %d)",
|
||||
i, hash[0], params.BlobTxHashVersion)
|
||||
if !kzg4844.IsValidVersionedHash(hash[:]) {
|
||||
return fmt.Errorf("blob %d has invalid hash version", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,21 +51,9 @@ var (
|
|||
emptyBlob = kzg4844.Blob{}
|
||||
emptyBlobCommit, _ = kzg4844.BlobToCommitment(emptyBlob)
|
||||
emptyBlobProof, _ = kzg4844.ComputeBlobProof(emptyBlob, emptyBlobCommit)
|
||||
emptyBlobVHash = blobHash(emptyBlobCommit)
|
||||
emptyBlobVHash = kzg4844.CalcBlobHashV1(sha256.New(), &emptyBlobCommit)
|
||||
)
|
||||
|
||||
func blobHash(commit kzg4844.Commitment) common.Hash {
|
||||
hasher := sha256.New()
|
||||
hasher.Write(commit[:])
|
||||
hash := hasher.Sum(nil)
|
||||
|
||||
var vhash common.Hash
|
||||
vhash[0] = params.BlobTxHashVersion
|
||||
copy(vhash[1:], hash[1:])
|
||||
|
||||
return vhash
|
||||
}
|
||||
|
||||
// Chain configuration with Cancun enabled.
|
||||
//
|
||||
// TODO(karalabe): replace with params.MainnetChainConfig after Cancun.
|
||||
|
|
|
|||
|
|
@ -143,17 +143,10 @@ func validateBlobSidecar(hashes []common.Hash, sidecar *types.BlobTxSidecar) err
|
|||
// Blob quantities match up, validate that the provers match with the
|
||||
// transaction hash before getting to the cryptography
|
||||
hasher := sha256.New()
|
||||
for i, want := range hashes {
|
||||
hasher.Write(sidecar.Commitments[i][:])
|
||||
hash := hasher.Sum(nil)
|
||||
hasher.Reset()
|
||||
|
||||
var vhash common.Hash
|
||||
vhash[0] = params.BlobTxHashVersion
|
||||
copy(vhash[1:], hash[1:])
|
||||
|
||||
if vhash != want {
|
||||
return fmt.Errorf("blob %d: computed hash %#x mismatches transaction one %#x", i, vhash, want)
|
||||
for i, vhash := range hashes {
|
||||
computed := kzg4844.CalcBlobHashV1(hasher, &sidecar.Commitments[i])
|
||||
if vhash != computed {
|
||||
return fmt.Errorf("blob %d: computed hash %#x mismatches transaction one %#x", i, computed, vhash)
|
||||
}
|
||||
}
|
||||
// Blob commitments match with the hashes in the transaction, verify the
|
||||
|
|
|
|||
|
|
@ -61,9 +61,10 @@ type BlobTxSidecar struct {
|
|||
|
||||
// BlobHashes computes the blob hashes of the given blobs.
|
||||
func (sc *BlobTxSidecar) BlobHashes() []common.Hash {
|
||||
hasher := sha256.New()
|
||||
h := make([]common.Hash, len(sc.Commitments))
|
||||
for i := range sc.Blobs {
|
||||
h[i] = blobHash(&sc.Commitments[i])
|
||||
h[i] = kzg4844.CalcBlobHashV1(hasher, &sc.Commitments[i])
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
|
@ -235,12 +236,3 @@ func (tx *BlobTx) decode(input []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func blobHash(commit *kzg4844.Commitment) common.Hash {
|
||||
hasher := sha256.New()
|
||||
hasher.Write(commit[:])
|
||||
var vhash common.Hash
|
||||
hasher.Sum(vhash[:0])
|
||||
vhash[0] = params.BlobTxHashVersion
|
||||
return vhash
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package kzg4844
|
|||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"hash"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
|
|
@ -108,3 +109,21 @@ func VerifyBlobProof(blob Blob, commitment Commitment, proof Proof) error {
|
|||
}
|
||||
return gokzgVerifyBlobProof(blob, commitment, proof)
|
||||
}
|
||||
|
||||
// CalcBlobHashV1 calculates the 'versioned blob hash' of a commitment.
|
||||
// The given hasher must be a sha256 hash instance, otherwise the result will be invalid!
|
||||
func CalcBlobHashV1(hasher hash.Hash, commit *Commitment) (vh [32]byte) {
|
||||
if hasher.Size() != 32 {
|
||||
panic("wrong hash size")
|
||||
}
|
||||
hasher.Reset()
|
||||
hasher.Write(commit[:])
|
||||
hasher.Sum(vh[:0])
|
||||
vh[0] = 0x01 // version
|
||||
return vh
|
||||
}
|
||||
|
||||
// IsValidVersionedHash checks that h is a structurally-valid versioned blob hash.
|
||||
func IsValidVersionedHash(h []byte) bool {
|
||||
return len(h) == 32 && h[0] == 0x01
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/prque"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
|
|
@ -810,7 +811,7 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
|
|||
return errInvalidBody
|
||||
}
|
||||
for _, hash := range tx.BlobHashes() {
|
||||
if hash[0] != params.BlobTxHashVersion {
|
||||
if !kzg4844.IsValidVersionedHash(hash[:]) {
|
||||
return errInvalidBody
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -662,6 +662,9 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
|||
if msg.GasTipCap != nil {
|
||||
arg["maxPriorityFeePerGas"] = (*hexutil.Big)(msg.GasTipCap)
|
||||
}
|
||||
if msg.AccessList != nil {
|
||||
arg["accessList"] = msg.AccessList
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,6 +236,15 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
|||
if msg.GasPrice != nil {
|
||||
arg["gasPrice"] = (*hexutil.Big)(msg.GasPrice)
|
||||
}
|
||||
if msg.GasFeeCap != nil {
|
||||
arg["maxFeePerGas"] = (*hexutil.Big)(msg.GasFeeCap)
|
||||
}
|
||||
if msg.GasTipCap != nil {
|
||||
arg["maxPriorityFeePerGas"] = (*hexutil.Big)(msg.GasTipCap)
|
||||
}
|
||||
if msg.AccessList != nil {
|
||||
arg["accessList"] = msg.AccessList
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ var (
|
|||
TerminalTotalDifficultyPassed: true,
|
||||
MergeNetsplitBlock: nil,
|
||||
ShanghaiTime: newUint64(1696000704),
|
||||
CancunTime: newUint64(1707305664),
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
|
||||
|
|
@ -105,6 +106,7 @@ var (
|
|||
TerminalTotalDifficultyPassed: true,
|
||||
MergeNetsplitBlock: big.NewInt(1735371),
|
||||
ShanghaiTime: newUint64(1677557088),
|
||||
CancunTime: newUint64(1706655072),
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ const (
|
|||
|
||||
BlobTxBytesPerFieldElement = 32 // Size in bytes of a field element
|
||||
BlobTxFieldElementsPerBlob = 4096 // Number of field elements stored in a single data blob
|
||||
BlobTxHashVersion = 0x01 // Version byte of the commitment hash
|
||||
BlobTxBlobGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size)
|
||||
BlobTxMinBlobGasprice = 1 // Minimum gas price for data blobs
|
||||
BlobTxBlobGaspriceUpdateFraction = 3338477 // Controls the maximum rate of change for blob gas price
|
||||
|
|
|
|||
Loading…
Reference in a new issue