mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
flip dev to cancun
This commit is contained in:
parent
0b4adbc4a6
commit
a8b9fd90d2
2 changed files with 23 additions and 39 deletions
|
|
@ -151,32 +151,20 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
|
||||||
c.feeRecipientLock.Unlock()
|
c.feeRecipientLock.Unlock()
|
||||||
|
|
||||||
// Reset to CurrentBlock in case of the chain was rewound
|
// Reset to CurrentBlock in case of the chain was rewound
|
||||||
var (
|
if header := c.eth.BlockChain().CurrentBlock(); c.curForkchoiceState.HeadBlockHash != header.Hash() {
|
||||||
header = c.eth.BlockChain().CurrentBlock()
|
|
||||||
number = new(big.Int).Add(header.Number, big.NewInt(1))
|
|
||||||
isCancun = c.eth.BlockChain().Config().IsCancun(number, timestamp)
|
|
||||||
)
|
|
||||||
if c.curForkchoiceState.HeadBlockHash != header.Hash() {
|
|
||||||
finalizedHash := c.finalizedBlockHash(header.Number.Uint64())
|
finalizedHash := c.finalizedBlockHash(header.Number.Uint64())
|
||||||
c.setCurrentState(header.Hash(), *finalizedHash)
|
c.setCurrentState(header.Hash(), *finalizedHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
var random [32]byte
|
var random [32]byte
|
||||||
rand.Read(random[:])
|
rand.Read(random[:])
|
||||||
var (
|
fcResponse, err := c.engineAPI.forkchoiceUpdated(c.curForkchoiceState, &engine.PayloadAttributes{
|
||||||
payloadVersion = engine.PayloadV2
|
Timestamp: timestamp,
|
||||||
attrs = &engine.PayloadAttributes{
|
SuggestedFeeRecipient: feeRecipient,
|
||||||
Timestamp: timestamp,
|
Withdrawals: withdrawals,
|
||||||
SuggestedFeeRecipient: feeRecipient,
|
Random: random,
|
||||||
Withdrawals: withdrawals,
|
BeaconRoot: &common.Hash{},
|
||||||
Random: random,
|
}, engine.PayloadV3, true)
|
||||||
}
|
|
||||||
)
|
|
||||||
if isCancun {
|
|
||||||
payloadVersion = engine.PayloadV3
|
|
||||||
attrs.BeaconRoot = &common.Hash{}
|
|
||||||
}
|
|
||||||
fcResponse, err := c.engineAPI.forkchoiceUpdated(c.curForkchoiceState, attrs, payloadVersion, true)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -200,27 +188,22 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the payload as canon
|
// Independently calculate the blob hashes from sidecars.
|
||||||
if isCancun {
|
blobHashes := make([]common.Hash, 0)
|
||||||
blobHashes := make([]common.Hash, 0)
|
if envelope.BlobsBundle != nil {
|
||||||
if envelope.BlobsBundle != nil {
|
hasher := sha256.New()
|
||||||
hasher := sha256.New()
|
for _, commit := range envelope.BlobsBundle.Commitments {
|
||||||
for _, commit := range envelope.BlobsBundle.Commitments {
|
var c kzg4844.Commitment
|
||||||
var c kzg4844.Commitment
|
if len(commit) != len(c) {
|
||||||
if len(commit) != len(c) {
|
return errors.New("invalid commitment length")
|
||||||
return errors.New("invalid commitment length")
|
|
||||||
}
|
|
||||||
copy(c[:], commit)
|
|
||||||
blobHashes = append(blobHashes, kzg4844.CalcBlobHashV1(hasher, &c))
|
|
||||||
}
|
}
|
||||||
|
copy(c[:], commit)
|
||||||
|
blobHashes = append(blobHashes, kzg4844.CalcBlobHashV1(hasher, &c))
|
||||||
}
|
}
|
||||||
if _, err = c.engineAPI.NewPayloadV3(*payload, blobHashes, &common.Hash{}); err != nil {
|
}
|
||||||
return err
|
// Mark the payload as canon
|
||||||
}
|
if _, err = c.engineAPI.NewPayloadV3(*payload, blobHashes, &common.Hash{}); err != nil {
|
||||||
} else {
|
return err
|
||||||
if _, err = c.engineAPI.NewPayloadV2(*payload); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.setCurrentState(payload.BlockHash, finalizedHash)
|
c.setCurrentState(payload.BlockHash, finalizedHash)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,7 @@ var (
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: big.NewInt(0),
|
||||||
ShanghaiTime: newUint64(0),
|
ShanghaiTime: newUint64(0),
|
||||||
|
CancunTime: newUint64(0),
|
||||||
TerminalTotalDifficulty: big.NewInt(0),
|
TerminalTotalDifficulty: big.NewInt(0),
|
||||||
TerminalTotalDifficultyPassed: true,
|
TerminalTotalDifficultyPassed: true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue