• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版18f93fb4f92be3e1d5038e614e2c91e634245cfa (tree)
时间2020-03-02 12:23:33
作者ipqhjjybj <250657661@qq.c...>
Commiteripqhjjybj

Log Message

ro

更改概述

差异

--- a/test/rollback_test.go
+++ b/test/rollback_test.go
@@ -40,624 +40,1087 @@ func TestRollback(t *testing.T) {
4040 wantStoredConsensusResult []*state.ConsensusResult
4141 rollbackToTargetHeight uint64
4242 }{
43+ // {
44+ // desc: "rollback from height 1 to 0",
45+ // movStartHeight: 10,
46+ // RoundVoteBlockNums: 1200,
47+ // beforeBestBlockHeader: &types.BlockHeader{
48+ // Height: 1,
49+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
50+ // },
51+ // wantBestBlockHeader: &types.BlockHeader{
52+ // Height: 0,
53+ // },
54+ // beforeLastIrrBlockHeader: &types.BlockHeader{
55+ // Height: 1,
56+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
57+ // },
58+ // wantLastIrrBlockHeader: &types.BlockHeader{
59+ // Height: 0,
60+ // },
61+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
62+ // Entries: map[bc.Hash]*storage.UtxoEntry{
63+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
64+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
65+ // },
66+ // },
67+ // rollbackToTargetHeight: 0,
68+ // beforeStoredBlocks: []*types.Block{
69+ // {
70+ // BlockHeader: types.BlockHeader{
71+ // Height: 0,
72+ // },
73+ // Transactions: []*types.Tx{
74+ // types.NewTx(types.TxData{
75+ // Inputs: []*types.TxInput{
76+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
77+ // },
78+ // Outputs: []*types.TxOutput{
79+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
80+ // },
81+ // }),
82+ // },
83+ // },
84+ // {
85+ // BlockHeader: types.BlockHeader{
86+ // Height: 1,
87+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
88+ // },
89+ // Transactions: []*types.Tx{
90+ // types.NewTx(types.TxData{
91+ // Inputs: []*types.TxInput{
92+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
93+ // },
94+ // Outputs: []*types.TxOutput{
95+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
96+ // },
97+ // }),
98+ // },
99+ // },
100+ // },
101+ // wantStoredBlocks: []*types.Block{
102+ // {
103+ // BlockHeader: types.BlockHeader{
104+ // Height: 0,
105+ // },
106+ // Transactions: []*types.Tx{
107+ // types.NewTx(types.TxData{
108+ // Inputs: []*types.TxInput{
109+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
110+ // },
111+ // Outputs: []*types.TxOutput{
112+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
113+ // },
114+ // }),
115+ // },
116+ // },
117+ // },
118+ // beforeStoredConsensusResult: []*state.ConsensusResult{
119+ // {
120+ // Seq: 1,
121+ // NumOfVote: map[string]uint64{
122+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
123+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
124+ // },
125+ // BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
126+ // BlockHeight: 1,
127+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + 10000000000},
128+ // },
129+ // {
130+ // Seq: 0,
131+ // NumOfVote: map[string]uint64{
132+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
133+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
134+ // },
135+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
136+ // BlockHeight: 0,
137+ // CoinbaseReward: map[string]uint64{},
138+ // },
139+ // },
140+ // wantBestConsensusResult: &state.ConsensusResult{
141+ // Seq: 0,
142+ // NumOfVote: map[string]uint64{
143+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
144+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
145+ // },
146+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
147+ // BlockHeight: 0,
148+ // CoinbaseReward: map[string]uint64{},
149+ // },
150+ // wantUtxoViewPoint: &state.UtxoViewpoint{
151+ // Entries: map[bc.Hash]*storage.UtxoEntry{
152+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
153+ // },
154+ // },
155+ // wantStoredConsensusResult: []*state.ConsensusResult{
156+ // {
157+ // Seq: 0,
158+ // NumOfVote: map[string]uint64{
159+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
160+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
161+ // },
162+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
163+ // BlockHeight: 0,
164+ // CoinbaseReward: map[string]uint64{},
165+ // },
166+ // },
167+ // },
168+ // {
169+ // desc: "rollback from height 2 to 0",
170+ // movStartHeight: 10,
171+ // RoundVoteBlockNums: 1200,
172+ // beforeBestBlockHeader: &types.BlockHeader{
173+ // Height: 2,
174+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
175+ // },
176+ // wantBestBlockHeader: &types.BlockHeader{
177+ // Height: 0,
178+ // },
179+ // beforeLastIrrBlockHeader: &types.BlockHeader{
180+ // Height: 2,
181+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
182+ // },
183+ // wantLastIrrBlockHeader: &types.BlockHeader{
184+ // Height: 0,
185+ // },
186+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
187+ // Entries: map[bc.Hash]*storage.UtxoEntry{
188+ // testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
189+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
190+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
191+ // },
192+ // },
193+ // rollbackToTargetHeight: 0,
194+ // beforeStoredBlocks: []*types.Block{
195+ // {
196+ // BlockHeader: types.BlockHeader{
197+ // Height: 0,
198+ // },
199+ // Transactions: []*types.Tx{
200+ // types.NewTx(types.TxData{
201+ // Inputs: []*types.TxInput{
202+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
203+ // },
204+ // Outputs: []*types.TxOutput{
205+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
206+ // },
207+ // }),
208+ // },
209+ // },
210+ // {
211+ // BlockHeader: types.BlockHeader{
212+ // Height: 1,
213+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
214+ // },
215+ // Transactions: []*types.Tx{
216+ // types.NewTx(types.TxData{
217+ // Inputs: []*types.TxInput{
218+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
219+ // },
220+ // Outputs: []*types.TxOutput{
221+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
222+ // },
223+ // }),
224+ // },
225+ // },
226+ // {
227+ // BlockHeader: types.BlockHeader{
228+ // Height: 2,
229+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
230+ // },
231+ // Transactions: []*types.Tx{
232+ // types.NewTx(types.TxData{
233+ // Inputs: []*types.TxInput{
234+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
235+ // },
236+ // Outputs: []*types.TxOutput{
237+ // types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
238+ // },
239+ // }),
240+ // },
241+ // },
242+ // },
243+ // wantStoredBlocks: []*types.Block{
244+ // {
245+ // BlockHeader: types.BlockHeader{
246+ // Height: 0,
247+ // },
248+ // Transactions: []*types.Tx{
249+ // types.NewTx(types.TxData{
250+ // Inputs: []*types.TxInput{
251+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
252+ // },
253+ // Outputs: []*types.TxOutput{
254+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
255+ // },
256+ // }),
257+ // },
258+ // },
259+ // },
260+ // beforeStoredConsensusResult: []*state.ConsensusResult{
261+ // {
262+ // Seq: 1,
263+ // NumOfVote: map[string]uint64{
264+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
265+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
266+ // },
267+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
268+ // BlockHeight: 2,
269+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(2) + 10000000000},
270+ // },
271+ // {
272+ // Seq: 0,
273+ // NumOfVote: map[string]uint64{
274+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
275+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
276+ // },
277+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
278+ // BlockHeight: 0,
279+ // CoinbaseReward: map[string]uint64{},
280+ // },
281+ // },
282+ // wantBestConsensusResult: &state.ConsensusResult{
283+ // Seq: 0,
284+ // NumOfVote: map[string]uint64{
285+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
286+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
287+ // },
288+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
289+ // BlockHeight: 0,
290+ // CoinbaseReward: map[string]uint64{},
291+ // },
292+ // wantUtxoViewPoint: &state.UtxoViewpoint{
293+ // Entries: map[bc.Hash]*storage.UtxoEntry{
294+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
295+ // },
296+ // },
297+ // wantStoredConsensusResult: []*state.ConsensusResult{
298+ // {
299+ // Seq: 0,
300+ // NumOfVote: map[string]uint64{
301+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
302+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
303+ // },
304+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
305+ // BlockHeight: 0,
306+ // CoinbaseReward: map[string]uint64{},
307+ // },
308+ // },
309+ // },
310+ // {
311+ // desc: "rollback from height 2 to 1",
312+ // movStartHeight: 10,
313+ // RoundVoteBlockNums: 1200,
314+ // beforeBestBlockHeader: &types.BlockHeader{
315+ // Height: 2,
316+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
317+ // },
318+ // wantBestBlockHeader: &types.BlockHeader{
319+ // Height: 1,
320+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
321+ // },
322+ // beforeLastIrrBlockHeader: &types.BlockHeader{
323+ // Height: 2,
324+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
325+ // },
326+ // wantLastIrrBlockHeader: &types.BlockHeader{
327+ // Height: 1,
328+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
329+ // },
330+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
331+ // Entries: map[bc.Hash]*storage.UtxoEntry{
332+ // testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
333+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
334+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
335+ // },
336+ // },
337+ // rollbackToTargetHeight: 1,
338+ // beforeStoredBlocks: []*types.Block{
339+ // {
340+ // BlockHeader: types.BlockHeader{
341+ // Height: 0,
342+ // },
343+ // Transactions: []*types.Tx{
344+ // types.NewTx(types.TxData{
345+ // Inputs: []*types.TxInput{
346+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
347+ // },
348+ // Outputs: []*types.TxOutput{
349+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
350+ // },
351+ // }),
352+ // },
353+ // },
354+ // {
355+ // BlockHeader: types.BlockHeader{
356+ // Height: 1,
357+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
358+ // },
359+ // Transactions: []*types.Tx{
360+ // types.NewTx(types.TxData{
361+ // Inputs: []*types.TxInput{
362+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
363+ // },
364+ // Outputs: []*types.TxOutput{
365+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
366+ // },
367+ // }),
368+ // },
369+ // },
370+ // {
371+ // BlockHeader: types.BlockHeader{
372+ // Height: 2,
373+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
374+ // },
375+ // Transactions: []*types.Tx{
376+ // types.NewTx(types.TxData{
377+ // Inputs: []*types.TxInput{
378+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
379+ // },
380+ // Outputs: []*types.TxOutput{
381+ // types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
382+ // },
383+ // }),
384+ // },
385+ // },
386+ // },
387+ // wantStoredBlocks: []*types.Block{
388+ // {
389+ // BlockHeader: types.BlockHeader{
390+ // Height: 0,
391+ // },
392+ // Transactions: []*types.Tx{
393+ // types.NewTx(types.TxData{
394+ // Inputs: []*types.TxInput{
395+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
396+ // },
397+ // Outputs: []*types.TxOutput{
398+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
399+ // },
400+ // }),
401+ // },
402+ // },
403+ // {
404+ // BlockHeader: types.BlockHeader{
405+ // Height: 1,
406+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
407+ // },
408+ // Transactions: []*types.Tx{
409+ // types.NewTx(types.TxData{
410+ // Inputs: []*types.TxInput{
411+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
412+ // },
413+ // Outputs: []*types.TxOutput{
414+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
415+ // },
416+ // }),
417+ // },
418+ // },
419+ // },
420+ // beforeStoredConsensusResult: []*state.ConsensusResult{
421+ // {
422+ // Seq: 1,
423+ // NumOfVote: map[string]uint64{
424+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
425+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
426+ // },
427+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
428+ // BlockHeight: 2,
429+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 500},
430+ // },
431+ // {
432+ // Seq: 0,
433+ // NumOfVote: map[string]uint64{
434+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
435+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
436+ // },
437+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
438+ // BlockHeight: 0,
439+ // CoinbaseReward: map[string]uint64{},
440+ // },
441+ // },
442+ // wantBestConsensusResult: &state.ConsensusResult{
443+ // Seq: 1,
444+ // NumOfVote: map[string]uint64{
445+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
446+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
447+ // },
448+ // BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
449+ // BlockHeight: 1,
450+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1)},
451+ // },
452+ // wantUtxoViewPoint: &state.UtxoViewpoint{
453+ // Entries: map[bc.Hash]*storage.UtxoEntry{
454+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
455+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
456+ // },
457+ // },
458+ // wantStoredConsensusResult: []*state.ConsensusResult{
459+ // {
460+ // Seq: 0,
461+ // NumOfVote: map[string]uint64{
462+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
463+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
464+ // },
465+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
466+ // BlockHeight: 0,
467+ // CoinbaseReward: map[string]uint64{},
468+ // },
469+ // },
470+ // },
471+ // {
472+ // desc: "rollback from height 2 to 1, RoundVoteBlockNums is 2",
473+ // movStartHeight: 10,
474+ // RoundVoteBlockNums: 2,
475+ // beforeBestBlockHeader: &types.BlockHeader{
476+ // Height: 2,
477+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
478+ // },
479+ // wantBestBlockHeader: &types.BlockHeader{
480+ // Height: 1,
481+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
482+ // },
483+ // beforeLastIrrBlockHeader: &types.BlockHeader{
484+ // Height: 2,
485+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
486+ // },
487+ // wantLastIrrBlockHeader: &types.BlockHeader{
488+ // Height: 1,
489+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
490+ // },
491+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
492+ // Entries: map[bc.Hash]*storage.UtxoEntry{
493+ // testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
494+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
495+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
496+ // },
497+ // },
498+ // rollbackToTargetHeight: 1,
499+ // beforeStoredBlocks: []*types.Block{
500+ // {
501+ // BlockHeader: types.BlockHeader{
502+ // Height: 0,
503+ // },
504+ // Transactions: []*types.Tx{
505+ // types.NewTx(types.TxData{
506+ // Inputs: []*types.TxInput{
507+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
508+ // },
509+ // Outputs: []*types.TxOutput{
510+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
511+ // },
512+ // }),
513+ // },
514+ // },
515+ // {
516+ // BlockHeader: types.BlockHeader{
517+ // Height: 1,
518+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
519+ // },
520+ // Transactions: []*types.Tx{
521+ // types.NewTx(types.TxData{
522+ // Inputs: []*types.TxInput{
523+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
524+ // },
525+ // Outputs: []*types.TxOutput{
526+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
527+ // },
528+ // }),
529+ // },
530+ // },
531+ // {
532+ // BlockHeader: types.BlockHeader{
533+ // Height: 2,
534+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
535+ // },
536+ // Transactions: []*types.Tx{
537+ // types.NewTx(types.TxData{
538+ // Inputs: []*types.TxInput{
539+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
540+ // },
541+ // Outputs: []*types.TxOutput{
542+ // types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
543+ // },
544+ // }),
545+ // },
546+ // },
547+ // },
548+ // wantStoredBlocks: []*types.Block{
549+ // {
550+ // BlockHeader: types.BlockHeader{
551+ // Height: 0,
552+ // },
553+ // Transactions: []*types.Tx{
554+ // types.NewTx(types.TxData{
555+ // Inputs: []*types.TxInput{
556+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
557+ // },
558+ // Outputs: []*types.TxOutput{
559+ // types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
560+ // },
561+ // }),
562+ // },
563+ // },
564+ // {
565+ // BlockHeader: types.BlockHeader{
566+ // Height: 1,
567+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
568+ // },
569+ // Transactions: []*types.Tx{
570+ // types.NewTx(types.TxData{
571+ // Inputs: []*types.TxInput{
572+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
573+ // },
574+ // Outputs: []*types.TxOutput{
575+ // types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
576+ // },
577+ // }),
578+ // },
579+ // },
580+ // },
581+ // beforeStoredConsensusResult: []*state.ConsensusResult{
582+ // {
583+ // Seq: 1,
584+ // NumOfVote: map[string]uint64{
585+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
586+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
587+ // },
588+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
589+ // BlockHeight: 2,
590+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 500},
591+ // },
592+ // {
593+ // Seq: 0,
594+ // NumOfVote: map[string]uint64{
595+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
596+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
597+ // },
598+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
599+ // BlockHeight: 0,
600+ // CoinbaseReward: map[string]uint64{},
601+ // },
602+ // },
603+ // wantBestConsensusResult: &state.ConsensusResult{
604+ // Seq: 1,
605+ // NumOfVote: map[string]uint64{
606+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
607+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
608+ // },
609+ // BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
610+ // BlockHeight: 1,
611+ // CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1)},
612+ // },
613+ // wantUtxoViewPoint: &state.UtxoViewpoint{
614+ // Entries: map[bc.Hash]*storage.UtxoEntry{
615+ // testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
616+ // testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
617+ // },
618+ // },
619+ // wantStoredConsensusResult: []*state.ConsensusResult{
620+ // {
621+ // Seq: 0,
622+ // NumOfVote: map[string]uint64{
623+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
624+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
625+ // },
626+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
627+ // BlockHeight: 0,
628+ // CoinbaseReward: map[string]uint64{},
629+ // },
630+ // },
631+ // },
632+ // {
633+ // desc: "rollback from height 3 to 1, RoundVoteBlockNums is 2",
634+ // movStartHeight: 10,
635+ // RoundVoteBlockNums: 2,
636+ // beforeBestBlockHeader: &types.BlockHeader{
637+ // Height: 3,
638+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
639+ // },
640+ // wantBestBlockHeader: &types.BlockHeader{
641+ // Height: 1,
642+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
643+ // },
644+ // beforeLastIrrBlockHeader: &types.BlockHeader{
645+ // Height: 3,
646+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
647+ // },
648+ // wantLastIrrBlockHeader: &types.BlockHeader{
649+ // Height: 1,
650+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
651+ // },
652+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
653+ // Entries: map[bc.Hash]*storage.UtxoEntry{
654+ // testutil.MustDecodeHash("5b4d53fbc2a489847f34dd0e0c085797fe7cf0a3a9a2f3231d11bdad16dea2be"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
655+ // testutil.MustDecodeHash("4c2b719d10fc6b9c2a7c343491ddd8c0d6bd57f9c6680bfda557689c182cf685"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
656+ // testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
657+ // testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
658+ // },
659+ // },
660+ // rollbackToTargetHeight: 1,
661+ // beforeStoredBlocks: []*types.Block{
662+ // {
663+ // BlockHeader: types.BlockHeader{
664+ // Height: 0,
665+ // },
666+ // Transactions: []*types.Tx{
667+ // types.NewTx(types.TxData{
668+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
669+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
670+ // }),
671+ // types.NewTx(types.TxData{
672+ // Inputs: []*types.TxInput{
673+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
674+ // },
675+ // Outputs: []*types.TxOutput{
676+ // types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
677+ // },
678+ // }),
679+ // },
680+ // },
681+ // {
682+ // BlockHeader: types.BlockHeader{
683+ // Height: 1,
684+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
685+ // },
686+ // Transactions: []*types.Tx{
687+ // types.NewTx(types.TxData{
688+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
689+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
690+ // }),
691+ // types.NewTx(types.TxData{
692+ // Inputs: []*types.TxInput{
693+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
694+ // },
695+ // Outputs: []*types.TxOutput{
696+ // types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
697+ // },
698+ // }),
699+ // },
700+ // },
701+ // {
702+ // BlockHeader: types.BlockHeader{
703+ // Height: 2,
704+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
705+ // },
706+ // Transactions: []*types.Tx{
707+ // types.NewTx(types.TxData{
708+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
709+ // Outputs: []*types.TxOutput{
710+ // types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
711+ // },
712+ // }),
713+ // types.NewTx(types.TxData{
714+ // Inputs: []*types.TxInput{
715+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 300000000, 0, []byte{0, 1}),
716+ // },
717+ // Outputs: []*types.TxOutput{
718+ // types.NewVoteOutput(*consensus.BTMAssetID, 250000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
719+ // },
720+ // }),
721+ // },
722+ // },
723+ // {
724+ // BlockHeader: types.BlockHeader{
725+ // Height: 3,
726+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
727+ // },
728+ // Transactions: []*types.Tx{
729+ // types.NewTx(types.TxData{
730+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
731+ // Outputs: []*types.TxOutput{
732+ // types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
733+ // types.NewIntraChainOutput(bc.AssetID{}, consensus.BlockSubsidy(1)+consensus.BlockSubsidy(2)+50002000, []byte{0x51}),
734+ // },
735+ // }),
736+ // types.NewTx(types.TxData{
737+ // Inputs: []*types.TxInput{
738+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 400000000, 0, []byte{0, 1}),
739+ // },
740+ // Outputs: []*types.TxOutput{
741+ // types.NewVoteOutput(*consensus.BTMAssetID, 160000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
742+ // },
743+ // }),
744+ // },
745+ // },
746+ // },
747+ // wantStoredBlocks: []*types.Block{
748+ // {
749+ // BlockHeader: types.BlockHeader{
750+ // Height: 0,
751+ // },
752+ // Transactions: []*types.Tx{
753+ // types.NewTx(types.TxData{
754+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
755+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
756+ // }),
757+ // types.NewTx(types.TxData{
758+ // Inputs: []*types.TxInput{
759+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
760+ // },
761+ // Outputs: []*types.TxOutput{
762+ // types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
763+ // },
764+ // }),
765+ // },
766+ // },
767+ // {
768+ // BlockHeader: types.BlockHeader{
769+ // Height: 1,
770+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
771+ // },
772+ // Transactions: []*types.Tx{
773+ // types.NewTx(types.TxData{
774+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
775+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
776+ // }),
777+ // types.NewTx(types.TxData{
778+ // Inputs: []*types.TxInput{
779+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
780+ // },
781+ // Outputs: []*types.TxOutput{
782+ // types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
783+ // },
784+ // }),
785+ // },
786+ // },
787+ // },
788+ // beforeStoredConsensusResult: []*state.ConsensusResult{
789+ // {
790+ // Seq: 2,
791+ // NumOfVote: map[string]uint64{
792+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 609998000,
793+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
794+ // },
795+ // BlockHash: testutil.MustDecodeHash("0c1cd1c0a6e6161f437c382cca21ce28921234ed7c4f252f7e4bbc9a523b74ac"),
796+ // BlockHeight: 3,
797+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(3) + 240000000},
798+ // },
799+ // {
800+ // Seq: 1,
801+ // NumOfVote: map[string]uint64{
802+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 449998000,
803+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
804+ // },
805+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
806+ // BlockHeight: 2,
807+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 50002000},
808+ // },
809+ // {
810+ // Seq: 0,
811+ // NumOfVote: map[string]uint64{
812+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
813+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
814+ // },
815+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
816+ // BlockHeight: 0,
817+ // CoinbaseReward: map[string]uint64{},
818+ // },
819+ // },
820+ // wantBestConsensusResult: &state.ConsensusResult{
821+ // Seq: 1,
822+ // NumOfVote: map[string]uint64{
823+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000 + 100000000 - 2000,
824+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
825+ // },
826+ // BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
827+ // BlockHeight: 1,
828+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + 2000},
829+ // },
830+ // wantUtxoViewPoint: &state.UtxoViewpoint{
831+ // Entries: map[bc.Hash]*storage.UtxoEntry{
832+ // testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
833+ // testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
834+ // },
835+ // },
836+ // wantStoredConsensusResult: []*state.ConsensusResult{
837+ // {
838+ // Seq: 0,
839+ // NumOfVote: map[string]uint64{
840+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
841+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
842+ // },
843+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
844+ // BlockHeight: 0,
845+ // CoinbaseReward: map[string]uint64{},
846+ // },
847+ // },
848+ // },
849+ // {
850+ // desc: "rollback from height 3 to 2, RoundVoteBlockNums is 2",
851+ // movStartHeight: 10,
852+ // RoundVoteBlockNums: 2,
853+ // beforeBestBlockHeader: &types.BlockHeader{
854+ // Height: 3,
855+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
856+ // },
857+ // wantBestBlockHeader: &types.BlockHeader{
858+ // Height: 2,
859+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
860+ // },
861+ // beforeLastIrrBlockHeader: &types.BlockHeader{
862+ // Height: 3,
863+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
864+ // },
865+ // wantLastIrrBlockHeader: &types.BlockHeader{
866+ // Height: 2,
867+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
868+ // },
869+ // beforeUtxoViewPoint: &state.UtxoViewpoint{
870+ // Entries: map[bc.Hash]*storage.UtxoEntry{
871+ // testutil.MustDecodeHash("5b4d53fbc2a489847f34dd0e0c085797fe7cf0a3a9a2f3231d11bdad16dea2be"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
872+ // testutil.MustDecodeHash("4c2b719d10fc6b9c2a7c343491ddd8c0d6bd57f9c6680bfda557689c182cf685"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
873+ // testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
874+ // testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
875+ // },
876+ // },
877+ // rollbackToTargetHeight: 2,
878+ // beforeStoredBlocks: []*types.Block{
879+ // {
880+ // BlockHeader: types.BlockHeader{
881+ // Height: 0,
882+ // },
883+ // Transactions: []*types.Tx{
884+ // types.NewTx(types.TxData{
885+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
886+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
887+ // }),
888+ // types.NewTx(types.TxData{
889+ // Inputs: []*types.TxInput{
890+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
891+ // },
892+ // Outputs: []*types.TxOutput{
893+ // types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
894+ // },
895+ // }),
896+ // },
897+ // },
898+ // {
899+ // BlockHeader: types.BlockHeader{
900+ // Height: 1,
901+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
902+ // },
903+ // Transactions: []*types.Tx{
904+ // types.NewTx(types.TxData{
905+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
906+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
907+ // }),
908+ // types.NewTx(types.TxData{
909+ // Inputs: []*types.TxInput{
910+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
911+ // },
912+ // Outputs: []*types.TxOutput{
913+ // types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
914+ // },
915+ // }),
916+ // },
917+ // },
918+ // {
919+ // BlockHeader: types.BlockHeader{
920+ // Height: 2,
921+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
922+ // },
923+ // Transactions: []*types.Tx{
924+ // types.NewTx(types.TxData{
925+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
926+ // Outputs: []*types.TxOutput{
927+ // types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
928+ // },
929+ // }),
930+ // types.NewTx(types.TxData{
931+ // Inputs: []*types.TxInput{
932+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 300000000, 0, []byte{0, 1}),
933+ // },
934+ // Outputs: []*types.TxOutput{
935+ // types.NewVoteOutput(*consensus.BTMAssetID, 250000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
936+ // },
937+ // }),
938+ // },
939+ // },
940+ // {
941+ // BlockHeader: types.BlockHeader{
942+ // Height: 3,
943+ // PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
944+ // },
945+ // Transactions: []*types.Tx{
946+ // types.NewTx(types.TxData{
947+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
948+ // Outputs: []*types.TxOutput{
949+ // types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
950+ // types.NewIntraChainOutput(bc.AssetID{}, consensus.BlockSubsidy(1)+consensus.BlockSubsidy(2)+50002000, []byte{0x51}),
951+ // },
952+ // }),
953+ // types.NewTx(types.TxData{
954+ // Inputs: []*types.TxInput{
955+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 400000000, 0, []byte{0, 1}),
956+ // },
957+ // Outputs: []*types.TxOutput{
958+ // types.NewVoteOutput(*consensus.BTMAssetID, 160000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
959+ // },
960+ // }),
961+ // },
962+ // },
963+ // },
964+ // wantStoredBlocks: []*types.Block{
965+ // {
966+ // BlockHeader: types.BlockHeader{
967+ // Height: 0,
968+ // },
969+ // Transactions: []*types.Tx{
970+ // types.NewTx(types.TxData{
971+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
972+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
973+ // }),
974+ // types.NewTx(types.TxData{
975+ // Inputs: []*types.TxInput{
976+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
977+ // },
978+ // Outputs: []*types.TxOutput{
979+ // types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
980+ // },
981+ // }),
982+ // },
983+ // },
984+ // {
985+ // BlockHeader: types.BlockHeader{
986+ // Height: 1,
987+ // PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
988+ // },
989+ // Transactions: []*types.Tx{
990+ // types.NewTx(types.TxData{
991+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
992+ // Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
993+ // }),
994+ // types.NewTx(types.TxData{
995+ // Inputs: []*types.TxInput{
996+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
997+ // },
998+ // Outputs: []*types.TxOutput{
999+ // types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1000+ // },
1001+ // }),
1002+ // },
1003+ // },
1004+ // {
1005+ // BlockHeader: types.BlockHeader{
1006+ // Height: 2,
1007+ // PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
1008+ // },
1009+ // Transactions: []*types.Tx{
1010+ // types.NewTx(types.TxData{
1011+ // Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
1012+ // Outputs: []*types.TxOutput{
1013+ // types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
1014+ // },
1015+ // }),
1016+ // types.NewTx(types.TxData{
1017+ // Inputs: []*types.TxInput{
1018+ // types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 300000000, 0, []byte{0, 1}),
1019+ // },
1020+ // Outputs: []*types.TxOutput{
1021+ // types.NewVoteOutput(*consensus.BTMAssetID, 250000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1022+ // },
1023+ // }),
1024+ // },
1025+ // },
1026+ // },
1027+ // beforeStoredConsensusResult: []*state.ConsensusResult{
1028+ // {
1029+ // Seq: 2,
1030+ // NumOfVote: map[string]uint64{
1031+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 609998000,
1032+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
1033+ // },
1034+ // BlockHash: testutil.MustDecodeHash("0c1cd1c0a6e6161f437c382cca21ce28921234ed7c4f252f7e4bbc9a523b74ac"),
1035+ // BlockHeight: 3,
1036+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(3) + 240000000},
1037+ // },
1038+ // {
1039+ // Seq: 1,
1040+ // NumOfVote: map[string]uint64{
1041+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 449998000,
1042+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
1043+ // },
1044+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
1045+ // BlockHeight: 2,
1046+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 50002000},
1047+ // },
1048+ // {
1049+ // Seq: 0,
1050+ // NumOfVote: map[string]uint64{
1051+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
1052+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
1053+ // },
1054+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
1055+ // BlockHeight: 0,
1056+ // CoinbaseReward: map[string]uint64{},
1057+ // },
1058+ // },
1059+ // wantBestConsensusResult: &state.ConsensusResult{
1060+ // Seq: 1,
1061+ // NumOfVote: map[string]uint64{
1062+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000 + 100000000 - 2000 + 250000000,
1063+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
1064+ // },
1065+ // BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
1066+ // BlockHeight: 2,
1067+ // CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 50002000},
1068+ // },
1069+ // wantUtxoViewPoint: &state.UtxoViewpoint{
1070+ // Entries: map[bc.Hash]*storage.UtxoEntry{
1071+ // testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
1072+ // testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
1073+ // testutil.MustDecodeHash("4c2b719d10fc6b9c2a7c343491ddd8c0d6bd57f9c6680bfda557689c182cf685"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
1074+ // },
1075+ // },
1076+ // wantStoredConsensusResult: []*state.ConsensusResult{
1077+ // {
1078+ // Seq: 0,
1079+ // NumOfVote: map[string]uint64{
1080+ // "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
1081+ // "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
1082+ // },
1083+ // BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
1084+ // BlockHeight: 0,
1085+ // CoinbaseReward: map[string]uint64{},
1086+ // },
1087+ // },
1088+ // },
431089 {
44- desc: "rollback from height 1 to 0",
45- movStartHeight: 10,
46- RoundVoteBlockNums: 1200,
47- beforeBestBlockHeader: &types.BlockHeader{
48- Height: 1,
49- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
50- },
51- wantBestBlockHeader: &types.BlockHeader{
52- Height: 0,
53- },
54- beforeLastIrrBlockHeader: &types.BlockHeader{
55- Height: 1,
56- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
57- },
58- wantLastIrrBlockHeader: &types.BlockHeader{
59- Height: 0,
60- },
61- beforeUtxoViewPoint: &state.UtxoViewpoint{
62- Entries: map[bc.Hash]*storage.UtxoEntry{
63- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
64- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
65- },
66- },
67- rollbackToTargetHeight: 0,
68- beforeStoredBlocks: []*types.Block{
69- {
70- BlockHeader: types.BlockHeader{
71- Height: 0,
72- },
73- Transactions: []*types.Tx{
74- types.NewTx(types.TxData{
75- Inputs: []*types.TxInput{
76- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
77- },
78- Outputs: []*types.TxOutput{
79- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
80- },
81- }),
82- },
83- },
84- {
85- BlockHeader: types.BlockHeader{
86- Height: 1,
87- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
88- },
89- Transactions: []*types.Tx{
90- types.NewTx(types.TxData{
91- Inputs: []*types.TxInput{
92- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
93- },
94- Outputs: []*types.TxOutput{
95- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
96- },
97- }),
98- },
99- },
100- },
101- wantStoredBlocks: []*types.Block{
102- {
103- BlockHeader: types.BlockHeader{
104- Height: 0,
105- },
106- Transactions: []*types.Tx{
107- types.NewTx(types.TxData{
108- Inputs: []*types.TxInput{
109- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
110- },
111- Outputs: []*types.TxOutput{
112- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
113- },
114- }),
115- },
116- },
117- },
118- beforeStoredConsensusResult: []*state.ConsensusResult{
119- {
120- Seq: 1,
121- NumOfVote: map[string]uint64{
122- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
123- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
124- },
125- BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
126- BlockHeight: 1,
127- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + 10000000000},
128- },
129- {
130- Seq: 0,
131- NumOfVote: map[string]uint64{
132- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
133- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
134- },
135- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
136- BlockHeight: 0,
137- CoinbaseReward: map[string]uint64{},
138- },
139- },
140- wantBestConsensusResult: &state.ConsensusResult{
141- Seq: 0,
142- NumOfVote: map[string]uint64{
143- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
144- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
145- },
146- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
147- BlockHeight: 0,
148- CoinbaseReward: map[string]uint64{},
149- },
150- wantUtxoViewPoint: &state.UtxoViewpoint{
151- Entries: map[bc.Hash]*storage.UtxoEntry{
152- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
153- },
154- },
155- wantStoredConsensusResult: []*state.ConsensusResult{
156- {
157- Seq: 0,
158- NumOfVote: map[string]uint64{
159- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
160- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
161- },
162- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
163- BlockHeight: 0,
164- CoinbaseReward: map[string]uint64{},
165- },
166- },
167- },
168- {
169- desc: "rollback from height 2 to 0",
170- movStartHeight: 10,
171- RoundVoteBlockNums: 1200,
172- beforeBestBlockHeader: &types.BlockHeader{
173- Height: 2,
174- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
175- },
176- wantBestBlockHeader: &types.BlockHeader{
177- Height: 0,
178- },
179- beforeLastIrrBlockHeader: &types.BlockHeader{
180- Height: 2,
181- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
182- },
183- wantLastIrrBlockHeader: &types.BlockHeader{
184- Height: 0,
185- },
186- beforeUtxoViewPoint: &state.UtxoViewpoint{
187- Entries: map[bc.Hash]*storage.UtxoEntry{
188- testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
189- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
190- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
191- },
192- },
193- rollbackToTargetHeight: 0,
194- beforeStoredBlocks: []*types.Block{
195- {
196- BlockHeader: types.BlockHeader{
197- Height: 0,
198- },
199- Transactions: []*types.Tx{
200- types.NewTx(types.TxData{
201- Inputs: []*types.TxInput{
202- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
203- },
204- Outputs: []*types.TxOutput{
205- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
206- },
207- }),
208- },
209- },
210- {
211- BlockHeader: types.BlockHeader{
212- Height: 1,
213- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
214- },
215- Transactions: []*types.Tx{
216- types.NewTx(types.TxData{
217- Inputs: []*types.TxInput{
218- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
219- },
220- Outputs: []*types.TxOutput{
221- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
222- },
223- }),
224- },
225- },
226- {
227- BlockHeader: types.BlockHeader{
228- Height: 2,
229- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
230- },
231- Transactions: []*types.Tx{
232- types.NewTx(types.TxData{
233- Inputs: []*types.TxInput{
234- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
235- },
236- Outputs: []*types.TxOutput{
237- types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
238- },
239- }),
240- },
241- },
242- },
243- wantStoredBlocks: []*types.Block{
244- {
245- BlockHeader: types.BlockHeader{
246- Height: 0,
247- },
248- Transactions: []*types.Tx{
249- types.NewTx(types.TxData{
250- Inputs: []*types.TxInput{
251- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
252- },
253- Outputs: []*types.TxOutput{
254- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
255- },
256- }),
257- },
258- },
259- },
260- beforeStoredConsensusResult: []*state.ConsensusResult{
261- {
262- Seq: 1,
263- NumOfVote: map[string]uint64{
264- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
265- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
266- },
267- BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
268- BlockHeight: 2,
269- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(2) + 10000000000},
270- },
271- {
272- Seq: 0,
273- NumOfVote: map[string]uint64{
274- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
275- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
276- },
277- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
278- BlockHeight: 0,
279- CoinbaseReward: map[string]uint64{},
280- },
281- },
282- wantBestConsensusResult: &state.ConsensusResult{
283- Seq: 0,
284- NumOfVote: map[string]uint64{
285- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
286- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
287- },
288- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
289- BlockHeight: 0,
290- CoinbaseReward: map[string]uint64{},
291- },
292- wantUtxoViewPoint: &state.UtxoViewpoint{
293- Entries: map[bc.Hash]*storage.UtxoEntry{
294- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
295- },
296- },
297- wantStoredConsensusResult: []*state.ConsensusResult{
298- {
299- Seq: 0,
300- NumOfVote: map[string]uint64{
301- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
302- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
303- },
304- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
305- BlockHeight: 0,
306- CoinbaseReward: map[string]uint64{},
307- },
308- },
309- },
310- {
311- desc: "rollback from height 2 to 1",
312- movStartHeight: 10,
313- RoundVoteBlockNums: 1200,
314- beforeBestBlockHeader: &types.BlockHeader{
315- Height: 2,
316- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
317- },
318- wantBestBlockHeader: &types.BlockHeader{
319- Height: 1,
320- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
321- },
322- beforeLastIrrBlockHeader: &types.BlockHeader{
323- Height: 2,
324- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
325- },
326- wantLastIrrBlockHeader: &types.BlockHeader{
327- Height: 1,
328- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
329- },
330- beforeUtxoViewPoint: &state.UtxoViewpoint{
331- Entries: map[bc.Hash]*storage.UtxoEntry{
332- testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
333- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
334- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
335- },
336- },
337- rollbackToTargetHeight: 1,
338- beforeStoredBlocks: []*types.Block{
339- {
340- BlockHeader: types.BlockHeader{
341- Height: 0,
342- },
343- Transactions: []*types.Tx{
344- types.NewTx(types.TxData{
345- Inputs: []*types.TxInput{
346- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
347- },
348- Outputs: []*types.TxOutput{
349- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
350- },
351- }),
352- },
353- },
354- {
355- BlockHeader: types.BlockHeader{
356- Height: 1,
357- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
358- },
359- Transactions: []*types.Tx{
360- types.NewTx(types.TxData{
361- Inputs: []*types.TxInput{
362- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
363- },
364- Outputs: []*types.TxOutput{
365- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
366- },
367- }),
368- },
369- },
370- {
371- BlockHeader: types.BlockHeader{
372- Height: 2,
373- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
374- },
375- Transactions: []*types.Tx{
376- types.NewTx(types.TxData{
377- Inputs: []*types.TxInput{
378- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
379- },
380- Outputs: []*types.TxOutput{
381- types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
382- },
383- }),
384- },
385- },
386- },
387- wantStoredBlocks: []*types.Block{
388- {
389- BlockHeader: types.BlockHeader{
390- Height: 0,
391- },
392- Transactions: []*types.Tx{
393- types.NewTx(types.TxData{
394- Inputs: []*types.TxInput{
395- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
396- },
397- Outputs: []*types.TxOutput{
398- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
399- },
400- }),
401- },
402- },
403- {
404- BlockHeader: types.BlockHeader{
405- Height: 1,
406- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
407- },
408- Transactions: []*types.Tx{
409- types.NewTx(types.TxData{
410- Inputs: []*types.TxInput{
411- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
412- },
413- Outputs: []*types.TxOutput{
414- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
415- },
416- }),
417- },
418- },
419- },
420- beforeStoredConsensusResult: []*state.ConsensusResult{
421- {
422- Seq: 1,
423- NumOfVote: map[string]uint64{
424- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
425- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
426- },
427- BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
428- BlockHeight: 2,
429- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 500},
430- },
431- {
432- Seq: 0,
433- NumOfVote: map[string]uint64{
434- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
435- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
436- },
437- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
438- BlockHeight: 0,
439- CoinbaseReward: map[string]uint64{},
440- },
441- },
442- wantBestConsensusResult: &state.ConsensusResult{
443- Seq: 1,
444- NumOfVote: map[string]uint64{
445- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
446- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
447- },
448- BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
449- BlockHeight: 1,
450- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1)},
451- },
452- wantUtxoViewPoint: &state.UtxoViewpoint{
453- Entries: map[bc.Hash]*storage.UtxoEntry{
454- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
455- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
456- },
457- },
458- wantStoredConsensusResult: []*state.ConsensusResult{
459- {
460- Seq: 0,
461- NumOfVote: map[string]uint64{
462- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
463- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
464- },
465- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
466- BlockHeight: 0,
467- CoinbaseReward: map[string]uint64{},
468- },
469- },
470- },
471- {
472- desc: "rollback from height 2 to 1, RoundVoteBlockNums is 2",
473- movStartHeight: 10,
474- RoundVoteBlockNums: 2,
475- beforeBestBlockHeader: &types.BlockHeader{
476- Height: 2,
477- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
478- },
479- wantBestBlockHeader: &types.BlockHeader{
480- Height: 1,
481- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
482- },
483- beforeLastIrrBlockHeader: &types.BlockHeader{
484- Height: 2,
485- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
486- },
487- wantLastIrrBlockHeader: &types.BlockHeader{
488- Height: 1,
489- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
490- },
491- beforeUtxoViewPoint: &state.UtxoViewpoint{
492- Entries: map[bc.Hash]*storage.UtxoEntry{
493- testutil.MustDecodeHash("afee09925bea1695424450a91ad082a378f20534627fa5cb63f036846347ee08"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
494- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
495- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
496- },
497- },
498- rollbackToTargetHeight: 1,
499- beforeStoredBlocks: []*types.Block{
500- {
501- BlockHeader: types.BlockHeader{
502- Height: 0,
503- },
504- Transactions: []*types.Tx{
505- types.NewTx(types.TxData{
506- Inputs: []*types.TxInput{
507- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
508- },
509- Outputs: []*types.TxOutput{
510- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
511- },
512- }),
513- },
514- },
515- {
516- BlockHeader: types.BlockHeader{
517- Height: 1,
518- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
519- },
520- Transactions: []*types.Tx{
521- types.NewTx(types.TxData{
522- Inputs: []*types.TxInput{
523- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
524- },
525- Outputs: []*types.TxOutput{
526- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
527- },
528- }),
529- },
530- },
531- {
532- BlockHeader: types.BlockHeader{
533- Height: 2,
534- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
535- },
536- Transactions: []*types.Tx{
537- types.NewTx(types.TxData{
538- Inputs: []*types.TxInput{
539- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 3000, 0, []byte{0, 1}),
540- },
541- Outputs: []*types.TxOutput{
542- types.NewVoteOutput(*consensus.BTMAssetID, 2500, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
543- },
544- }),
545- },
546- },
547- },
548- wantStoredBlocks: []*types.Block{
549- {
550- BlockHeader: types.BlockHeader{
551- Height: 0,
552- },
553- Transactions: []*types.Tx{
554- types.NewTx(types.TxData{
555- Inputs: []*types.TxInput{
556- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 1000, 0, []byte{0, 1}),
557- },
558- Outputs: []*types.TxOutput{
559- types.NewVoteOutput(*consensus.BTMAssetID, 1000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
560- },
561- }),
562- },
563- },
564- {
565- BlockHeader: types.BlockHeader{
566- Height: 1,
567- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
568- },
569- Transactions: []*types.Tx{
570- types.NewTx(types.TxData{
571- Inputs: []*types.TxInput{
572- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 2000, 0, []byte{0, 1}),
573- },
574- Outputs: []*types.TxOutput{
575- types.NewVoteOutput(*consensus.BTMAssetID, 2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
576- },
577- }),
578- },
579- },
580- },
581- beforeStoredConsensusResult: []*state.ConsensusResult{
582- {
583- Seq: 1,
584- NumOfVote: map[string]uint64{
585- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100004500,
586- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
587- },
588- BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
589- BlockHeight: 2,
590- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 500},
591- },
592- {
593- Seq: 0,
594- NumOfVote: map[string]uint64{
595- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
596- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
597- },
598- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
599- BlockHeight: 0,
600- CoinbaseReward: map[string]uint64{},
601- },
602- },
603- wantBestConsensusResult: &state.ConsensusResult{
604- Seq: 1,
605- NumOfVote: map[string]uint64{
606- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100002000,
607- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
608- },
609- BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
610- BlockHeight: 1,
611- CoinbaseReward: map[string]uint64{"0001": consensus.BlockSubsidy(1)},
612- },
613- wantUtxoViewPoint: &state.UtxoViewpoint{
614- Entries: map[bc.Hash]*storage.UtxoEntry{
615- testutil.MustDecodeHash("51f538be366172bed5359a016dce26b952024c9607caf6af609ad723982c2e06"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
616- testutil.MustDecodeHash("e2370262a129b90174195a76c298d872a56af042eae17657e154bcc46d41b3ba"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
617- },
618- },
619- wantStoredConsensusResult: []*state.ConsensusResult{
620- {
621- Seq: 0,
622- NumOfVote: map[string]uint64{
623- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
624- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
625- },
626- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
627- BlockHeight: 0,
628- CoinbaseReward: map[string]uint64{},
629- },
630- },
631- },
632- {
633- desc: "rollback from height 3 to 1, RoundVoteBlockNums is 2",
1090+ desc: "rollback from height 4 to 2, there is two chain ",
6341091 movStartHeight: 10,
6351092 RoundVoteBlockNums: 2,
6361093 beforeBestBlockHeader: &types.BlockHeader{
637- Height: 3,
638- PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
1094+ Height: 5,
1095+ Timestamp: uint64(1528945008),
1096+ PreviousBlockHash: testutil.MustDecodeHash("64a41230412f26a5c0a1734515d9e177bd3573be2ae1d55c4533509a7c9cce8e"),
6391097 },
6401098 wantBestBlockHeader: &types.BlockHeader{
641- Height: 1,
642- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
1099+ Height: 2,
1100+ PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
6431101 },
6441102 beforeLastIrrBlockHeader: &types.BlockHeader{
645- Height: 3,
646- PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
1103+ Height: 5,
1104+ Timestamp: uint64(1528945008),
1105+ PreviousBlockHash: testutil.MustDecodeHash("64a41230412f26a5c0a1734515d9e177bd3573be2ae1d55c4533509a7c9cce8e"),
6471106 },
6481107 wantLastIrrBlockHeader: &types.BlockHeader{
649- Height: 1,
650- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
1108+ Height: 2,
1109+ PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
6511110 },
6521111 beforeUtxoViewPoint: &state.UtxoViewpoint{
6531112 Entries: map[bc.Hash]*storage.UtxoEntry{
654- testutil.MustDecodeHash("5b4d53fbc2a489847f34dd0e0c085797fe7cf0a3a9a2f3231d11bdad16dea2be"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
1113+ testutil.MustDecodeHash("3c07f3159d4e2a0527129d644a8fcd09ce26555e94c9c7f348464120ef463275"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 5, Spent: true},
1114+ testutil.MustDecodeHash("927144d2a391e17dc12184f5ae163b994984132ad72c34d854bb9009b68cd4cc"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 4, Spent: true},
1115+ testutil.MustDecodeHash("fa43f4ca43bcb0e94d43b52c56d1740dea1329b59a44f6ee045d70446881c514"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
1116+ testutil.MustDecodeHash("f081ccd0c97ae34bc5580a0405d9b1ed0b0ed9e1410f1786b7112b348a412e3d"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 4, Spent: true},
1117+ testutil.MustDecodeHash("2704fa67c76e020b08ffa3f93a500acebcaf68b45ba43d8b3b08b68c5bb1eff1"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
6551118 testutil.MustDecodeHash("4c2b719d10fc6b9c2a7c343491ddd8c0d6bd57f9c6680bfda557689c182cf685"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
6561119 testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
6571120 testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
6581121 },
6591122 },
660- rollbackToTargetHeight: 1,
1123+ rollbackToTargetHeight: 2,
6611124 beforeStoredBlocks: []*types.Block{
6621125 {
6631126 BlockHeader: types.BlockHeader{
@@ -723,6 +1186,7 @@ func TestRollback(t *testing.T) {
7231186 {
7241187 BlockHeader: types.BlockHeader{
7251188 Height: 3,
1189+ Timestamp: uint64(1528945000),
7261190 PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
7271191 },
7281192 Transactions: []*types.Tx{
@@ -735,7 +1199,7 @@ func TestRollback(t *testing.T) {
7351199 }),
7361200 types.NewTx(types.TxData{
7371201 Inputs: []*types.TxInput{
738- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 400000000, 0, []byte{0, 1}),
1202+ types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 440000000, 0, []byte{0, 1}),
7391203 },
7401204 Outputs: []*types.TxOutput{
7411205 types.NewVoteOutput(*consensus.BTMAssetID, 160000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
@@ -743,182 +1207,58 @@ func TestRollback(t *testing.T) {
7431207 }),
7441208 },
7451209 },
746- },
747- wantStoredBlocks: []*types.Block{
7481210 {
7491211 BlockHeader: types.BlockHeader{
750- Height: 0,
1212+ Height: 4,
1213+ Timestamp: uint64(1528945005),
1214+ PreviousBlockHash: testutil.MustDecodeHash("bec3dd0d6fecb80a6f3a0373ec2ae676cc1ce72af83546f3d4672231c9b080e6"),
7511215 },
7521216 Transactions: []*types.Tx{
7531217 types.NewTx(types.TxData{
754- Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
755- Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
756- }),
757- types.NewTx(types.TxData{
758- Inputs: []*types.TxInput{
759- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
760- },
1218+ Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
7611219 Outputs: []*types.TxOutput{
762- types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
1220+ types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
7631221 },
7641222 }),
765- },
766- },
767- {
768- BlockHeader: types.BlockHeader{
769- Height: 1,
770- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
771- },
772- Transactions: []*types.Tx{
773- types.NewTx(types.TxData{
774- Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
775- Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
776- }),
7771223 types.NewTx(types.TxData{
7781224 Inputs: []*types.TxInput{
779- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
1225+ types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 500000000, 0, []byte{0, 1}),
7801226 },
7811227 Outputs: []*types.TxOutput{
782- types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1228+ types.NewVoteOutput(*consensus.BTMAssetID, 160000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
7831229 },
7841230 }),
7851231 },
7861232 },
787- },
788- beforeStoredConsensusResult: []*state.ConsensusResult{
789- {
790- Seq: 2,
791- NumOfVote: map[string]uint64{
792- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 609998000,
793- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
794- },
795- BlockHash: testutil.MustDecodeHash("0c1cd1c0a6e6161f437c382cca21ce28921234ed7c4f252f7e4bbc9a523b74ac"),
796- BlockHeight: 3,
797- CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(3) + 240000000},
798- },
799- {
800- Seq: 1,
801- NumOfVote: map[string]uint64{
802- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 449998000,
803- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
804- },
805- BlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
806- BlockHeight: 2,
807- CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + consensus.BlockSubsidy(2) + 50002000},
808- },
809- {
810- Seq: 0,
811- NumOfVote: map[string]uint64{
812- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
813- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
814- },
815- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
816- BlockHeight: 0,
817- CoinbaseReward: map[string]uint64{},
818- },
819- },
820- wantBestConsensusResult: &state.ConsensusResult{
821- Seq: 1,
822- NumOfVote: map[string]uint64{
823- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000 + 100000000 - 2000,
824- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
825- },
826- BlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
827- BlockHeight: 1,
828- CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(1) + 2000},
829- },
830- wantUtxoViewPoint: &state.UtxoViewpoint{
831- Entries: map[bc.Hash]*storage.UtxoEntry{
832- testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
833- testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
834- },
835- },
836- wantStoredConsensusResult: []*state.ConsensusResult{
837- {
838- Seq: 0,
839- NumOfVote: map[string]uint64{
840- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 100000000,
841- "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 100002000,
842- },
843- BlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
844- BlockHeight: 0,
845- CoinbaseReward: map[string]uint64{},
846- },
847- },
848- },
849- {
850- desc: "rollback from height 3 to 2, RoundVoteBlockNums is 2",
851- movStartHeight: 10,
852- RoundVoteBlockNums: 2,
853- beforeBestBlockHeader: &types.BlockHeader{
854- Height: 3,
855- PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
856- },
857- wantBestBlockHeader: &types.BlockHeader{
858- Height: 2,
859- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
860- },
861- beforeLastIrrBlockHeader: &types.BlockHeader{
862- Height: 3,
863- PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
864- },
865- wantLastIrrBlockHeader: &types.BlockHeader{
866- Height: 2,
867- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
868- },
869- beforeUtxoViewPoint: &state.UtxoViewpoint{
870- Entries: map[bc.Hash]*storage.UtxoEntry{
871- testutil.MustDecodeHash("5b4d53fbc2a489847f34dd0e0c085797fe7cf0a3a9a2f3231d11bdad16dea2be"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 3, Spent: true},
872- testutil.MustDecodeHash("4c2b719d10fc6b9c2a7c343491ddd8c0d6bd57f9c6680bfda557689c182cf685"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 2, Spent: true},
873- testutil.MustDecodeHash("9fb6f213e3130810e755675707d0e9870c79a91c575638a580fae65568ca9e99"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 1, Spent: true},
874- testutil.MustDecodeHash("3d1617908e624a2042c23be4f671b261d5b8a2a61b8421ee6a702c6e071428a8"): &storage.UtxoEntry{Type: storage.VoteUTXOType, BlockHeight: 0, Spent: true},
875- },
876- },
877- rollbackToTargetHeight: 2,
878- beforeStoredBlocks: []*types.Block{
8791233 {
8801234 BlockHeader: types.BlockHeader{
881- Height: 0,
1235+ Height: 3,
1236+ Timestamp: uint64(1528945001),
1237+ PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
8821238 },
8831239 Transactions: []*types.Tx{
8841240 types.NewTx(types.TxData{
885- Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
886- Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
887- }),
888- types.NewTx(types.TxData{
889- Inputs: []*types.TxInput{
890- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 100000000, 0, []byte{0, 1}),
891- },
1241+ Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
8921242 Outputs: []*types.TxOutput{
893- types.NewVoteOutput(*consensus.BTMAssetID, 100000000, []byte{0, 1}, testutil.MustDecodeHexString("36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67")),
1243+ types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
1244+ types.NewIntraChainOutput(bc.AssetID{}, consensus.BlockSubsidy(1)+consensus.BlockSubsidy(2)+50002000, []byte{0x51}),
8941245 },
8951246 }),
896- },
897- },
898- {
899- BlockHeader: types.BlockHeader{
900- Height: 1,
901- PreviousBlockHash: testutil.MustDecodeHash("39dee75363127a2857f554d2ad2706eb876407a2e09fbe0338683ca4ad4c2f90"),
902- },
903- Transactions: []*types.Tx{
904- types.NewTx(types.TxData{
905- Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
906- Outputs: []*types.TxOutput{types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51})},
907- }),
9081247 types.NewTx(types.TxData{
9091248 Inputs: []*types.TxInput{
910- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 200000000, 0, []byte{0, 1}),
1249+ types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 402000000, 0, []byte{0, 1}),
9111250 },
9121251 Outputs: []*types.TxOutput{
913- types.NewVoteOutput(*consensus.BTMAssetID, 200000000-2000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1252+ types.NewVoteOutput(*consensus.BTMAssetID, 200000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
9141253 },
9151254 }),
9161255 },
9171256 },
9181257 {
9191258 BlockHeader: types.BlockHeader{
920- Height: 2,
921- PreviousBlockHash: testutil.MustDecodeHash("52463075c66259098f2a1fa711288cf3b866d7c57b4a7a78cd22a1dcd69a0514"),
1259+ Height: 4,
1260+ Timestamp: uint64(1528945006),
1261+ PreviousBlockHash: testutil.MustDecodeHash("1d2d01a97d1239de51b4e7d0fb522f71771d2d4f9a0a559154519859cc44a230"),
9221262 },
9231263 Transactions: []*types.Tx{
9241264 types.NewTx(types.TxData{
@@ -929,33 +1269,34 @@ func TestRollback(t *testing.T) {
9291269 }),
9301270 types.NewTx(types.TxData{
9311271 Inputs: []*types.TxInput{
932- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 300000000, 0, []byte{0, 1}),
1272+ types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 410000000, 0, []byte{0, 1}),
9331273 },
9341274 Outputs: []*types.TxOutput{
935- types.NewVoteOutput(*consensus.BTMAssetID, 250000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1275+ types.NewVoteOutput(*consensus.BTMAssetID, 170000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
9361276 },
9371277 }),
9381278 },
9391279 },
9401280 {
9411281 BlockHeader: types.BlockHeader{
942- Height: 3,
943- PreviousBlockHash: testutil.MustDecodeHash("699d3f59d4afe7eea85df31814628d7d34ace7f5e76d6c9ebf4c54482d2cd333"),
1282+ Height: 5,
1283+ Timestamp: uint64(1528945008),
1284+ PreviousBlockHash: testutil.MustDecodeHash("64a41230412f26a5c0a1734515d9e177bd3573be2ae1d55c4533509a7c9cce8e"),
9441285 },
9451286 Transactions: []*types.Tx{
9461287 types.NewTx(types.TxData{
9471288 Inputs: []*types.TxInput{types.NewCoinbaseInput([]byte{0x01})},
9481289 Outputs: []*types.TxOutput{
9491290 types.NewIntraChainOutput(bc.AssetID{}, 0, []byte{0x51}),
950- types.NewIntraChainOutput(bc.AssetID{}, consensus.BlockSubsidy(1)+consensus.BlockSubsidy(2)+50002000, []byte{0x51}),
1291+ types.NewIntraChainOutput(bc.AssetID{}, consensus.BlockSubsidy(3)+consensus.BlockSubsidy(4)+520000000, []byte{0x51}),
9511292 },
9521293 }),
9531294 types.NewTx(types.TxData{
9541295 Inputs: []*types.TxInput{
955- types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 400000000, 0, []byte{0, 1}),
1296+ types.NewSpendInput(nil, bc.NewHash([32]byte{8}), *consensus.BTMAssetID, 400004000, 0, []byte{0, 1}),
9561297 },
9571298 Outputs: []*types.TxOutput{
958- types.NewVoteOutput(*consensus.BTMAssetID, 160000000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
1299+ types.NewVoteOutput(*consensus.BTMAssetID, 160004000, []byte{0, 1}, testutil.MustDecodeHexString("b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9")),
9591300 },
9601301 }),
9611302 },
@@ -1026,14 +1367,24 @@ func TestRollback(t *testing.T) {
10261367 },
10271368 beforeStoredConsensusResult: []*state.ConsensusResult{
10281369 {
1370+ Seq: 3,
1371+ NumOfVote: map[string]uint64{
1372+ "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 980002000,
1373+ "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
1374+ },
1375+ BlockHash: testutil.MustDecodeHash("075ce54f7d4c1b524474265219be52238beec98138f0c0a4d21f1a6b0047914a"),
1376+ BlockHeight: 5,
1377+ CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(5) + 240000000},
1378+ },
1379+ {
10291380 Seq: 2,
10301381 NumOfVote: map[string]uint64{
1031- "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 609998000,
1382+ "b7f463446a31b3792cd168d52b7a89b3657bca3e25d6854db1488c389ab6fc8d538155c25c1ee6975cc7def19710908c7d9b7463ca34a22058b456b45e498db9": 819998000,
10321383 "36695997983028c279c3360ca345a90e3af1f9e3df2506119fca31cdc844be31630f9a421f4d1658e15d67a15ce29c36332dd45020d2a0147fcce4949ccd9a67": 200000000,
10331384 },
1034- BlockHash: testutil.MustDecodeHash("0c1cd1c0a6e6161f437c382cca21ce28921234ed7c4f252f7e4bbc9a523b74ac"),
1035- BlockHeight: 3,
1036- CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(3) + 240000000},
1385+ BlockHash: testutil.MustDecodeHash("64a41230412f26a5c0a1734515d9e177bd3573be2ae1d55c4533509a7c9cce8e"),
1386+ BlockHeight: 4,
1387+ CoinbaseReward: map[string]uint64{"51": consensus.BlockSubsidy(3) + consensus.BlockSubsidy(4) + 442000000},
10371388 },
10381389 {
10391390 Seq: 1,
Show on old repository browser