Skip to content

Commit

Permalink
fix(ARCO-313): temporarily stop reorg support handling to allow for p…
Browse files Browse the repository at this point in the history
…rocessing mined transactions when gaps are existing (#716)
  • Loading branch information
kuba-4chain authored Dec 17, 2024
1 parent d25932b commit ba20b1b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions internal/blocktx/integration_test/reorg_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func testmain(m *testing.M) int {
}

func TestReorg(t *testing.T) {
// TODO: remove the skip when gaps are filling quickly again
t.Skip("Skipping until gaps are being processed quickly again")

if testing.Short() {
t.Skip("skipping integration test")
}
Expand Down
14 changes: 9 additions & 5 deletions internal/blocktx/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,15 @@ func (p *Processor) verifyAndInsertBlock(ctx context.Context, blockMsg *p2p.Bloc
MerkleRoot: merkleRoot[:],
Height: blockMsg.Height,
Chainwork: calculateChainwork(blockMsg.Header.Bits).String(),
Status: blocktx_api.Status_LONGEST, // temporary fix (!), TODO: remove this when gaps are filling quickly again
}

err = p.assignBlockStatus(ctx, incomingBlock, previousBlockHash)
if err != nil {
p.logger.Error("unable to assign block status", slog.String("hash", blockHash.String()), slog.Uint64("height", incomingBlock.Height), slog.String("err", err.Error()))
return nil, err
}
// TODO: uncomment when gaps are filling quickly again
// err = p.assignBlockStatus(ctx, incomingBlock, previousBlockHash)
// if err != nil {
// p.logger.Error("unable to assign block status", slog.String("hash", blockHash.String()), slog.Uint64("height", incomingBlock.Height), slog.String("err", err.Error()))
// return nil, err
// }

p.logger.Info("Inserting block", slog.String("hash", blockHash.String()), slog.Uint64("height", incomingBlock.Height), slog.String("status", incomingBlock.Status.String()))

Expand All @@ -548,6 +550,7 @@ func (p *Processor) verifyAndInsertBlock(ctx context.Context, blockMsg *p2p.Bloc
return incomingBlock, nil
}

//lint:ignore U1000 Ignored until gaps are filling quickly again TODO: remove this ignore
func (p *Processor) assignBlockStatus(ctx context.Context, block *blocktx_api.Block, prevBlockHash chainhash.Hash) (err error) {
ctx, span := tracing.StartTracing(ctx, "assignBlockStatus", p.tracingEnabled, p.tracingAttributes...)
defer func() {
Expand Down Expand Up @@ -608,6 +611,7 @@ func (p *Processor) assignBlockStatus(ctx context.Context, block *blocktx_api.Bl
return nil
}

//lint:ignore U1000 Ignored until gaps are filling quickly again TODO: remove this ignore
func (p *Processor) longestTipExists(ctx context.Context) (bool, error) {
_, err := p.store.GetChainTip(ctx)
if err != nil && !errors.Is(err, store.ErrBlockNotFound) {
Expand Down
7 changes: 5 additions & 2 deletions internal/blocktx/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestHandleBlock(t *testing.T) {
require.NoError(t, err)

blockMessage := &p2p.BlockMessage{
//Hash: testdata.Block1Hash,
// Hash: testdata.Block1Hash,
Header: &wire.BlockHeader{
Version: 541065216,
PrevBlock: tc.prevBlockHash,
Expand Down Expand Up @@ -235,6 +235,9 @@ func TestHandleBlock(t *testing.T) {
}

func TestHandleBlockReorgAndOrphans(t *testing.T) {
// TODO: remove the skip when gaps are filling quickly again
t.Skip("Skipping until gaps are being processed quickly again")

testCases := []struct {
name string
blockAlreadyExists bool
Expand Down Expand Up @@ -439,7 +442,7 @@ func TestHandleBlockReorgAndOrphans(t *testing.T) {
require.NoError(t, err)

blockMessage := &p2p.BlockMessage{
//Hash: testdata.Block1Hash,
// Hash: testdata.Block1Hash,
Header: &wire.BlockHeader{
Version: 541065216,
MerkleRoot: *merkleRoot,
Expand Down
3 changes: 3 additions & 0 deletions test/submit_05_reorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
)

func TestReorg(t *testing.T) {
// TODO: remove the skip when gaps are filling quickly again
t.Skip("Skipping until gaps are being processed quickly again")

address, privateKey := node_client.FundNewWallet(t, bitcoind)

utxos := node_client.GetUtxos(t, bitcoind, address)
Expand Down

0 comments on commit ba20b1b

Please sign in to comment.