2023-10-03 20:41:55 +00:00
|
|
|
package state_native_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/config/params"
|
|
|
|
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
2023-10-03 20:41:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkAppendEth1DataVotes(b *testing.B) {
|
|
|
|
st, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{})
|
|
|
|
require.NoError(b, err)
|
|
|
|
|
|
|
|
max := params.BeaconConfig().Eth1DataVotesLength()
|
|
|
|
|
|
|
|
if max < 2 {
|
|
|
|
b.Fatalf("Eth1DataVotesLength is less than 2")
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := uint64(0); i < max-2; i++ {
|
|
|
|
err := st.AppendEth1DataVotes(ðpb.Eth1Data{
|
|
|
|
DepositCount: i,
|
|
|
|
DepositRoot: make([]byte, 64),
|
|
|
|
BlockHash: make([]byte, 64),
|
|
|
|
})
|
|
|
|
require.NoError(b, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ref := st.Copy()
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
err := ref.AppendEth1DataVotes(ð.Eth1Data{DepositCount: uint64(i)})
|
|
|
|
require.NoError(b, err)
|
|
|
|
ref = st.Copy()
|
|
|
|
}
|
|
|
|
}
|