2022-01-07 16:47:33 +00:00
|
|
|
package execution_test
|
2021-12-14 09:18:27 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2022-01-07 16:47:33 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/execution"
|
2021-12-14 09:18:27 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/time"
|
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
|
|
|
)
|
|
|
|
|
2022-01-10 16:47:30 +00:00
|
|
|
func TestUpgradeToBellatrix(t *testing.T) {
|
2021-12-14 09:18:27 +00:00
|
|
|
st, _ := util.DeterministicGenesisStateAltair(t, params.BeaconConfig().MaxValidatorsPerCommittee)
|
|
|
|
preForkState := st.Copy()
|
2022-01-26 07:24:47 +00:00
|
|
|
mSt, err := execution.UpgradeToBellatrix(context.Background(), st)
|
2021-12-14 09:18:27 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, preForkState.GenesisTime(), mSt.GenesisTime())
|
2022-02-14 13:34:38 +00:00
|
|
|
require.DeepSSZEqual(t, preForkState.GenesisValidatorsRoot(), mSt.GenesisValidatorsRoot())
|
2021-12-14 09:18:27 +00:00
|
|
|
require.Equal(t, preForkState.Slot(), mSt.Slot())
|
|
|
|
require.DeepSSZEqual(t, preForkState.LatestBlockHeader(), mSt.LatestBlockHeader())
|
|
|
|
require.DeepSSZEqual(t, preForkState.BlockRoots(), mSt.BlockRoots())
|
|
|
|
require.DeepSSZEqual(t, preForkState.StateRoots(), mSt.StateRoots())
|
|
|
|
require.DeepSSZEqual(t, preForkState.HistoricalRoots(), mSt.HistoricalRoots())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Eth1Data(), mSt.Eth1Data())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Eth1DataVotes(), mSt.Eth1DataVotes())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Eth1DepositIndex(), mSt.Eth1DepositIndex())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Validators(), mSt.Validators())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Balances(), mSt.Balances())
|
|
|
|
require.DeepSSZEqual(t, preForkState.RandaoMixes(), mSt.RandaoMixes())
|
|
|
|
require.DeepSSZEqual(t, preForkState.Slashings(), mSt.Slashings())
|
|
|
|
require.DeepSSZEqual(t, preForkState.JustificationBits(), mSt.JustificationBits())
|
|
|
|
require.DeepSSZEqual(t, preForkState.PreviousJustifiedCheckpoint(), mSt.PreviousJustifiedCheckpoint())
|
|
|
|
require.DeepSSZEqual(t, preForkState.CurrentJustifiedCheckpoint(), mSt.CurrentJustifiedCheckpoint())
|
|
|
|
require.DeepSSZEqual(t, preForkState.FinalizedCheckpoint(), mSt.FinalizedCheckpoint())
|
|
|
|
numValidators := mSt.NumValidators()
|
|
|
|
p, err := mSt.PreviousEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepSSZEqual(t, make([]byte, numValidators), p)
|
|
|
|
p, err = mSt.CurrentEpochParticipation()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepSSZEqual(t, make([]byte, numValidators), p)
|
|
|
|
s, err := mSt.InactivityScores()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepSSZEqual(t, make([]uint64, numValidators), s)
|
|
|
|
|
|
|
|
f := mSt.Fork()
|
|
|
|
require.DeepSSZEqual(t, ðpb.Fork{
|
|
|
|
PreviousVersion: st.Fork().CurrentVersion,
|
2021-12-26 23:18:28 +00:00
|
|
|
CurrentVersion: params.BeaconConfig().BellatrixForkVersion,
|
2021-12-14 09:18:27 +00:00
|
|
|
Epoch: time.CurrentEpoch(st),
|
|
|
|
}, f)
|
|
|
|
csc, err := mSt.CurrentSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
nsc, err := mSt.NextSyncCommittee()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepSSZEqual(t, nsc, csc)
|
|
|
|
|
|
|
|
header, err := mSt.LatestExecutionPayloadHeader()
|
|
|
|
require.NoError(t, err)
|
|
|
|
wanted := ðpb.ExecutionPayloadHeader{
|
|
|
|
ParentHash: make([]byte, 32),
|
|
|
|
FeeRecipient: make([]byte, 20),
|
|
|
|
StateRoot: make([]byte, 32),
|
2022-04-16 13:18:07 +00:00
|
|
|
ReceiptsRoot: make([]byte, 32),
|
2021-12-14 09:18:27 +00:00
|
|
|
LogsBloom: make([]byte, 256),
|
2022-02-26 03:47:16 +00:00
|
|
|
PrevRandao: make([]byte, 32),
|
2021-12-14 09:18:27 +00:00
|
|
|
BlockNumber: 0,
|
|
|
|
GasLimit: 0,
|
|
|
|
GasUsed: 0,
|
|
|
|
Timestamp: 0,
|
|
|
|
BaseFeePerGas: make([]byte, 32),
|
|
|
|
BlockHash: make([]byte, 32),
|
|
|
|
TransactionsRoot: make([]byte, 32),
|
|
|
|
}
|
|
|
|
require.DeepEqual(t, wanted, header)
|
|
|
|
}
|