Return historical roots in Capella state (#12642)

* Return historical roots in Capella state

* test fix

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka 2023-07-20 19:00:05 +02:00 committed by GitHub
parent 405cd6ed86
commit 2217b45e16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -851,6 +851,10 @@ func BeaconStateCapellaToProto(st state.BeaconState) (*ethpbv2.BeaconStateCapell
StateSummaryRoot: summary.StateSummaryRoot,
}
}
hRoots, err := st.HistoricalRoots()
if err != nil {
return nil, errors.Wrap(err, "could not get historical roots")
}
result := &ethpbv2.BeaconStateCapella{
GenesisTime: st.GenesisTime(),
@ -925,6 +929,7 @@ func BeaconStateCapellaToProto(st state.BeaconState) (*ethpbv2.BeaconStateCapell
NextWithdrawalIndex: sourceNextWithdrawalIndex,
NextWithdrawalValidatorIndex: sourceNextWithdrawalValIndex,
HistoricalSummaries: sourceHistoricalSummaries,
HistoricalRoots: hRoots,
}
return result, nil

View File

@ -727,6 +727,8 @@ func TestBeaconStateCapellaToProto(t *testing.T) {
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
assert.Equal(t, 8192, len(result.StateRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
assert.Equal(t, 1, len(result.HistoricalRoots))
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
resultEth1Data := result.Eth1Data
require.NotNil(t, resultEth1Data)
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)