Fix IsExecutionEnabled for blinded blocks (#11076)

* Fix IsExecutionEnabled for blinded blocks

The TransactionsRoot of a blinded block may be non-zero, anyway we do
not insert the header in the state until IsExecutionEnabled is true.
This last check was failing on blinded blocks because it was actively
checking that the root should be zero, when it needn't be.

Superseeds #11068

* fix test

* test case

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Potuz
2022-07-19 17:45:45 -03:00
committed by GitHub
parent 82ae4caca8
commit 4b083c2ca9
4 changed files with 1 additions and 33 deletions

View File

@@ -101,15 +101,6 @@ func Test_IsMergeComplete(t *testing.T) {
}(),
want: true,
},
{
name: "has tx root",
payload: func() *enginev1.ExecutionPayloadHeader {
h := emptyPayloadHeader()
h.TransactionsRoot = bytesutil.PadTo([]byte{'a'}, fieldparams.RootLength)
return h
}(),
want: true,
},
{
name: "has extra data",
payload: func() *enginev1.ExecutionPayloadHeader {

View File

@@ -87,5 +87,4 @@ type ExecutionData interface {
BaseFeePerGas() []byte
BlockHash() []byte
Transactions() ([][]byte, error)
TransactionsRoot() ([]byte, error)
}

View File

@@ -398,8 +398,6 @@ func TestBellatrixBeaconBlock_ExecutionPayloadHeader(t *testing.T) {
}
wsb, err := wrapper.WrappedSignedBeaconBlock(sb)
require.NoError(t, err)
exec, err := wsb.Block().Body().Execution()
_, err = wsb.Block().Body().Execution()
require.NoError(t, err)
_, err = exec.TransactionsRoot()
require.ErrorContains(t, "unsupported field for block type", err)
}

View File

@@ -139,11 +139,6 @@ func (e executionPayload) Transactions() ([][]byte, error) {
return e.p.Transactions, nil
}
// TransactionsRoot --
func (executionPayload) TransactionsRoot() ([]byte, error) {
return nil, ErrUnsupportedField
}
// executionPayloadHeader is a convenience wrapper around a blinded beacon block body's execution header data structure
// This wrapper allows us to conform to a common interface so that beacon
// blocks for future forks can also be applied across Prysm without issues.
@@ -270,11 +265,6 @@ func (executionPayloadHeader) Transactions() ([][]byte, error) {
return nil, ErrUnsupportedField
}
// TransactionsRoot --
func (e executionPayloadHeader) TransactionsRoot() ([]byte, error) {
return e.p.TransactionsRoot, nil
}
// PayloadToHeader converts `payload` into execution payload header format.
func PayloadToHeader(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeader, error) {
txs, err := payload.Transactions()
@@ -342,16 +332,6 @@ func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error) {
}
}
txsRoot, err := data.TransactionsRoot()
switch {
case errors.Is(err, ErrUnsupportedField):
case err != nil:
return false, err
default:
if !bytes.Equal(txsRoot, make([]byte, fieldparams.RootLength)) {
return false, nil
}
}
if len(data.ExtraData()) != 0 {
return false, nil
}