Fixed hive test on invalid transition payload (#4618)

* experiment #1

* experiment #2

* experiment #3

* experiment 4
This commit is contained in:
Giulio rebuffo 2022-07-03 17:36:39 +02:00 committed by GitHub
parent c422b8c4da
commit b980280785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 8 deletions

View File

@ -111,8 +111,25 @@ func (e *EngineImpl) ForkchoiceUpdatedV1(ctx context.Context, forkChoiceState *F
return nil, err
}
payloadStatus := convertPayloadStatus(reply.PayloadStatus)
if reply.PayloadStatus.Status == remote.EngineStatus_INVALID && payloadStatus["latestValidHash"] != nil {
tx, err := e.db.BeginRo(ctx)
if err != nil {
return nil, err
}
defer tx.Rollback()
latestValidHash := payloadStatus["latestValidHash"].(common.Hash)
isValidHashPos, err := rawdb.IsPosBlock(tx, latestValidHash)
if err != nil {
return nil, err
}
if !isValidHashPos {
payloadStatus["latestValidHash"] = common.Hash{}
}
}
json := map[string]interface{}{
"payloadStatus": convertPayloadStatus(reply.PayloadStatus),
"payloadStatus": payloadStatus,
}
if reply.PayloadId != 0 {
encodedPayloadId := make([]byte, 8)
@ -128,13 +145,6 @@ func (e *EngineImpl) ForkchoiceUpdatedV1(ctx context.Context, forkChoiceState *F
func (e *EngineImpl) NewPayloadV1(ctx context.Context, payload *ExecutionPayload) (map[string]interface{}, error) {
log.Trace("Received NewPayload", "height", uint64(payload.BlockNumber), "hash", payload.BlockHash)
tx, err := e.db.BeginRo(ctx)
if err != nil {
return nil, err
}
defer tx.Rollback()
var baseFee *uint256.Int
if payload.BaseFeePerGas != nil {
var overflow bool
@ -172,6 +182,12 @@ func (e *EngineImpl) NewPayloadV1(ctx context.Context, payload *ExecutionPayload
}
payloadStatus := convertPayloadStatus(res)
if payloadStatus["latestValidHash"] != nil {
tx, err := e.db.BeginRo(ctx)
if err != nil {
return nil, err
}
defer tx.Rollback()
latestValidHash := payloadStatus["latestValidHash"].(common.Hash)
isValidHashPos, err := rawdb.IsPosBlock(tx, latestValidHash)
if err != nil {

View File

@ -898,6 +898,9 @@ func (hi *HeaderInserter) FeedHeaderPoS(db kv.GetPut, header *types.Header, hash
return fmt.Errorf("[%s] failed to WriteTd: %w", hi.logPrefix, err)
}
rawdb.WriteHeader(db, header)
if err = rawdb.WriteHeaderNumber(db, hash, blockHeight); err != nil {
return err
}
hi.highest = blockHeight
hi.highestHash = hash