|
33 | 33 | _ snowman.Block = (*wrappedBlock)(nil) |
34 | 34 | _ block.WithVerifyContext = (*wrappedBlock)(nil) |
35 | 35 |
|
36 | | - errInvalidParent = errors.New("parent header not found") |
37 | 36 | errMissingParentBlock = errors.New("missing parent block") |
38 | 37 | errInvalidGasUsedRelativeToCapacity = errors.New("invalid gas used relative to capacity") |
39 | 38 | errTotalIntrinsicGasCostExceedsClaimed = errors.New("total intrinsic gas cost is greater than claimed gas used") |
|
43 | 42 | var ( |
44 | 43 | errInvalidExcessBlobGasBeforeCancun = errors.New("invalid excessBlobGas before cancun") |
45 | 44 | errInvalidBlobGasUsedBeforeCancun = errors.New("invalid blobGasUsed before cancun") |
| 45 | + errInvalidParent = errors.New("parent header not found") |
46 | 46 | errInvalidParentBeaconRootBeforeCancun = errors.New("invalid parentBeaconRoot before cancun") |
47 | | - errMissingExcessBlobGas = errors.New("header is missing excessBlobGas") |
48 | | - errMissingBlobGasUsed = errors.New("header is missing blobGasUsed") |
| 47 | + errInvalidExcessBlobGas = errors.New("invalid excessBlobGas") |
49 | 48 | errMissingParentBeaconRoot = errors.New("header is missing parentBeaconRoot") |
50 | 49 | errParentBeaconRootNonEmpty = errors.New("invalid non-empty parentBeaconRoot") |
51 | 50 | errBlobGasUsedNilInCancun = errors.New("blob gas used must not be nil in Cancun") |
@@ -391,33 +390,29 @@ func (b *wrappedBlock) syntacticVerify() error { |
391 | 390 | } |
392 | 391 |
|
393 | 392 | // Verify the existence / non-existence of excessBlobGas |
394 | | - cancun := rules.IsCancun |
395 | | - if !cancun && ethHeader.ExcessBlobGas != nil { |
396 | | - return fmt.Errorf("%w: have %d, expected nil", errInvalidExcessBlobGasBeforeCancun, *ethHeader.ExcessBlobGas) |
397 | | - } |
398 | | - if !cancun && ethHeader.BlobGasUsed != nil { |
399 | | - return fmt.Errorf("%w: have %d, expected nil", errInvalidBlobGasUsedBeforeCancun, *ethHeader.BlobGasUsed) |
400 | | - } |
401 | | - if cancun && ethHeader.ExcessBlobGas == nil { |
402 | | - return errMissingExcessBlobGas |
403 | | - } |
404 | | - if cancun && ethHeader.BlobGasUsed == nil { |
405 | | - return errMissingBlobGasUsed |
406 | | - } |
407 | | - if !cancun && ethHeader.ParentBeaconRoot != nil { |
408 | | - return fmt.Errorf("%w: have %x, expected nil", errInvalidParentBeaconRootBeforeCancun, *ethHeader.ParentBeaconRoot) |
409 | | - } |
410 | | - if cancun { |
| 393 | + if rules.IsCancun { |
411 | 394 | switch { |
412 | 395 | case ethHeader.ParentBeaconRoot == nil: |
413 | 396 | return errMissingParentBeaconRoot |
414 | 397 | case *ethHeader.ParentBeaconRoot != (common.Hash{}): |
415 | 398 | return fmt.Errorf("%w: have %x, expected empty hash", errParentBeaconRootNonEmpty, ethHeader.ParentBeaconRoot) |
416 | | - } |
417 | | - if ethHeader.BlobGasUsed == nil { |
| 399 | + case ethHeader.BlobGasUsed == nil: |
418 | 400 | return errBlobGasUsedNilInCancun |
419 | | - } else if *ethHeader.BlobGasUsed > 0 { |
| 401 | + case *ethHeader.BlobGasUsed != 0: |
420 | 402 | return fmt.Errorf("%w: used %d blob gas, expected 0", errBlobsNotEnabled, *ethHeader.BlobGasUsed) |
| 403 | + case ethHeader.ExcessBlobGas == nil: |
| 404 | + return fmt.Errorf("%w: have nil, expected 0", errInvalidExcessBlobGas) |
| 405 | + case *ethHeader.ExcessBlobGas != 0: |
| 406 | + return fmt.Errorf("%w: have %d, expected 0", errInvalidExcessBlobGas, *ethHeader.ExcessBlobGas) |
| 407 | + } |
| 408 | + } else { |
| 409 | + switch { |
| 410 | + case ethHeader.ExcessBlobGas != nil: |
| 411 | + return fmt.Errorf("%w: have %d, expected nil", errInvalidExcessBlobGasBeforeCancun, *ethHeader.ExcessBlobGas) |
| 412 | + case ethHeader.BlobGasUsed != nil: |
| 413 | + return fmt.Errorf("%w: have %d, expected nil", errInvalidBlobGasUsedBeforeCancun, *ethHeader.BlobGasUsed) |
| 414 | + case ethHeader.ParentBeaconRoot != nil: |
| 415 | + return fmt.Errorf("%w: have %x, expected nil", errInvalidParentBeaconRootBeforeCancun, *ethHeader.ParentBeaconRoot) |
421 | 416 | } |
422 | 417 | } |
423 | 418 |
|
|
0 commit comments