diff --git a/cmd/arc/services/blocktx.go b/cmd/arc/services/blocktx.go index cf6c44389..018b03b69 100644 --- a/cmd/arc/services/blocktx.go +++ b/cmd/arc/services/blocktx.go @@ -127,6 +127,7 @@ func StartBlockTx(logger *slog.Logger, arcConfig *config.ArcConfig) (func(), err blocktx.WithRegisterTxsInterval(btxConfig.RegisterTxsInterval), blocktx.WithMessageQueueClient(mqClient), blocktx.WithMaxBlockProcessingDuration(btxConfig.MaxBlockProcessingDuration), + blocktx.WithIncomingIsLongest(btxConfig.IncomingIsLongest), ) blockRequestCh := make(chan blocktx.BlockRequest, blockProcessingBuffer) diff --git a/config/config.go b/config/config.go index 04426964d..54ee8954e 100644 --- a/config/config.go +++ b/config/config.go @@ -127,6 +127,7 @@ type BlocktxConfig struct { MaxAllowedBlockHeightMismatch int `mapstructure:"maxAllowedBlockHeightMismatch"` MessageQueue *MessageQueueConfig `mapstructure:"mq"` P2pReadBufferSize int `mapstructure:"p2pReadBufferSize"` + IncomingIsLongest bool `mapstructure:"incomingIsLongest"` } type DbConfig struct { diff --git a/config/defaults.go b/config/defaults.go index e5047a70d..a6aea5696 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -128,6 +128,7 @@ func getBlocktxConfig() *BlocktxConfig { MaxBlockProcessingDuration: 5 * time.Minute, MessageQueue: &MessageQueueConfig{}, P2pReadBufferSize: 8 * 1024 * 1024, + IncomingIsLongest: false, } } diff --git a/config/example_config.yaml b/config/example_config.yaml index 27ff1c80d..e900d6e0b 100644 --- a/config/example_config.yaml +++ b/config/example_config.yaml @@ -105,6 +105,7 @@ blocktx: registerTxsInterval: 10s # time interval to read from the channel registered transactions maxBlockProcessingDuration: 5m # maximum time a blocktx can spend on processing a block before unlocking it to be requested again monitorPeers: false # if enabled, peers which do not receive alive signal from nodes will be restarted + incomingIsLongest: false # whether each new block received is considered to be from the longest blockchain. If there are a lot of block gaps in blocktx database it is advisable to set this to true fillGaps: enabled: true interval: 15m # time interval to check and fill gaps in processed blocks diff --git a/internal/blocktx/integration_test/fixtures/reorg/blocktx.block_transactions.yaml b/internal/blocktx/integration_test/fixtures/reorg/blocktx.block_transactions.yaml index 61a6a8bb3..cd25464fb 100644 --- a/internal/blocktx/integration_test/fixtures/reorg/blocktx.block_transactions.yaml +++ b/internal/blocktx/integration_test/fixtures/reorg/blocktx.block_transactions.yaml @@ -1,12 +1,12 @@ - block_id: 1002 hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 - merkle_tree_index: 3 + merkle_tree_index: 0 - block_id: 1999 # the same tx also in stale block hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 - merkle_tree_index: 999 + merkle_tree_index: 0 - block_id: 1999 # the same tx also in stale block hash: 0xcd3d2f97dfc0cdb6a07ec4b72df5e1794c9553ff2f62d90ed4add047e8088853 - merkle_tree_index: 999 + merkle_tree_index: 1 - block_id: 1004 hash: 0xece2b7e40d98749c03c551b783420d6e3fdc3c958244bbf275437839585829a6 - merkle_tree_index: 5 + merkle_tree_index: 0 diff --git a/internal/blocktx/integration_test/fixtures/reorg/blocktx.blocks.yaml b/internal/blocktx/integration_test/fixtures/reorg/blocktx.blocks.yaml index 58b3fddeb..af089a49b 100644 --- a/internal/blocktx/integration_test/fixtures/reorg/blocktx.blocks.yaml +++ b/internal/blocktx/integration_test/fixtures/reorg/blocktx.blocks.yaml @@ -1,6 +1,6 @@ - inserted_at: 2023-12-15 14:00:00 id: 1001 - hash: 0xf97e20396f02ab990ed31b9aec70c240f48b7e5ea239aa050000000000000000 + hash: 0x67708796ef57464ed9eaf2a663d3da32372e4c2fb65558020000000000000000 prevhash: 0xb71ab063c5f96cad71cdc59dcc94182a20a69cbd7eed2d070000000000000000 merkleroot: 0x7f4019eb006f5333cce752df387fa8443035c22291eb771ee5b16a02b81c8483 height: 822014 @@ -22,18 +22,6 @@ status: 10 is_longest: true chainwork: '62209952899966' -- inserted_at: 2023-12-15 14:30:00 - id: 1999 - hash: 0x82471bbf045ab13825a245b37de71d77ec12513b37e2524ec11551d18c19f7c3 - prevhash: 0x67708796ef57464ed9eaf2a663d3da32372e4c2fb65558020000000000000000 - merkleroot: 0x7382df1b717287ab87e5e3e25759697c4c45eea428f701cdd0c77ad3fc707257 - height: 822015 - processed_at: 2023-12-15 14:30:00 - size: 20160000 - tx_count: 6523 - status: 20 # STALE - competing block - is_longest: false - chainwork: '62209952899966' - inserted_at: 2023-12-15 14:40:00 id: 1003 hash: 0xe1df1273e6e7270f96b508545d7aa80aebda7d758dc82e080000000000000000 @@ -58,6 +46,23 @@ status: 10 is_longest: true chainwork: '62209952899966' + +# Stale +- inserted_at: 2023-12-15 14:30:00 + id: 1999 + hash: 0x82471bbf045ab13825a245b37de71d77ec12513b37e2524ec11551d18c19f7c3 + prevhash: 0x67708796ef57464ed9eaf2a663d3da32372e4c2fb65558020000000000000000 + merkleroot: 0x7382df1b717287ab87e5e3e25759697c4c45eea428f701cdd0c77ad3fc707257 + height: 822015 + processed_at: 2023-12-15 14:30:00 + size: 20160000 + tx_count: 6523 + status: 20 # STALE - competing block + is_longest: false + chainwork: '62209952899966' + + + - inserted_at: 2023-12-15 14:50:00 id: 10052 hash: 0x000000000000000003b15d668b54c4b91ae81a86298ee209d9f39fd7a769bcde diff --git a/internal/blocktx/integration_test/fixtures/reorg/blocktx.registered_transactions.yaml b/internal/blocktx/integration_test/fixtures/reorg/blocktx.registered_transactions.yaml new file mode 100644 index 000000000..2dab66118 --- /dev/null +++ b/internal/blocktx/integration_test/fixtures/reorg/blocktx.registered_transactions.yaml @@ -0,0 +1,8 @@ +- hash: 0xcd3d2f97dfc0cdb6a07ec4b72df5e1794c9553ff2f62d90ed4add047e8088853 + inserted_at: 2023-12-15 14:00:00 +- hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 + inserted_at: 2023-12-15 14:00:00 +- hash: 0x2ff4430eb883c6f6c0640a5d716b2d107bbc0efa5aeaa237aec796d4686b0a8f + inserted_at: 2023-12-15 14:00:00 +- hash: 0xece2b7e40d98749c03c551b783420d6e3fdc3c958244bbf275437839585829a6 + inserted_at: 2023-12-15 14:00:00 diff --git a/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.block_transactions.yaml b/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.block_transactions.yaml index f54d8d8c5..0d010ab7f 100644 --- a/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.block_transactions.yaml +++ b/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.block_transactions.yaml @@ -1,15 +1,15 @@ - block_id: 1002 hash: 0xcd3d2f97dfc0cdb6a07ec4b72df5e1794c9553ff2f62d90ed4add047e8088853 - merkle_tree_index: 1 + merkle_tree_index: 0 - block_id: 1002 hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 - merkle_tree_index: 3 + merkle_tree_index: 1 - block_id: 1004 hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 - merkle_tree_index: 3 + merkle_tree_index: 0 - block_id: 1003 hash: 0x2ff4430eb883c6f6c0640a5d716b2d107bbc0efa5aeaa237aec796d4686b0a8f - merkle_tree_index: 4 + merkle_tree_index: 0 - block_id: 1006 hash: 0xece2b7e40d98749c03c551b783420d6e3fdc3c958244bbf275437839585829a6 - merkle_tree_index: 5 + merkle_tree_index: 0 diff --git a/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.registered_transactions.yaml b/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.registered_transactions.yaml new file mode 100644 index 000000000..2dab66118 --- /dev/null +++ b/internal/blocktx/integration_test/fixtures/reorg_orphans/blocktx.registered_transactions.yaml @@ -0,0 +1,8 @@ +- hash: 0xcd3d2f97dfc0cdb6a07ec4b72df5e1794c9553ff2f62d90ed4add047e8088853 + inserted_at: 2023-12-15 14:00:00 +- hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 + inserted_at: 2023-12-15 14:00:00 +- hash: 0x2ff4430eb883c6f6c0640a5d716b2d107bbc0efa5aeaa237aec796d4686b0a8f + inserted_at: 2023-12-15 14:00:00 +- hash: 0xece2b7e40d98749c03c551b783420d6e3fdc3c958244bbf275437839585829a6 + inserted_at: 2023-12-15 14:00:00 diff --git a/internal/blocktx/integration_test/fixtures/stale_orphans/blocktx.block_transactions_map.yaml b/internal/blocktx/integration_test/fixtures/stale_orphans/blocktx.block_transactions_map.yaml deleted file mode 100644 index 4a64b5c89..000000000 --- a/internal/blocktx/integration_test/fixtures/stale_orphans/blocktx.block_transactions_map.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- block_id: 1002 - merkle_tree_index: 3 - inserted_at: 2023-12-10 14:00:00 - hash: 0xb16cea53fc823e146fbb9ae4ad3124f7c273f30562585ad6e4831495d609f430 -- block_id: 1005 - merkle_tree_index: 5 - inserted_at: 2023-12-10 14:00:00 - hash: 0xece2b7e40d98749c03c551b783420d6e3fdc3c958244bbf275437839585829a6 diff --git a/internal/blocktx/integration_test/reorg_integration_test.go b/internal/blocktx/integration_test/reorg_integration_test.go index ed754d4b2..31f9698ee 100644 --- a/internal/blocktx/integration_test/reorg_integration_test.go +++ b/internal/blocktx/integration_test/reorg_integration_test.go @@ -46,9 +46,6 @@ 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") - if testing.Short() { t.Skip("skipping integration test") } @@ -150,7 +147,7 @@ func TestReorg(t *testing.T) { blockHash822015Fork = "82471bbf045ab13825a245b37de71d77ec12513b37e2524ec11551d18c19f7c3" blockHash822016Fork = "032c3688bc7536b2d787f3a196b1145a09bf33183cd1448ff6b1a9dfbb022db8" - blockHash822014StartOfChain = "f97e20396f02ab990ed31b9aec70c240f48b7e5ea239aa050000000000000000" + blockHash822014StartOfChain = "67708796ef57464ed9eaf2a663d3da32372e4c2fb65558020000000000000000" blockHash822015 = "c9b4e1e4dcf9188416027511671b9346be8ef93c0ddf59060000000000000000" blockHash822016 = "e1df1273e6e7270f96b508545d7aa80aebda7d758dc82e080000000000000000" blockHash822017 = "76404890880cb36ce68100abb05b3a958e17c0ed274d5c0a0000000000000000" diff --git a/internal/blocktx/processor.go b/internal/blocktx/processor.go index 36c3613cb..f155db7dc 100644 --- a/internal/blocktx/processor.go +++ b/internal/blocktx/processor.go @@ -70,6 +70,7 @@ type Processor struct { tracingAttributes []attribute.KeyValue stats *processorStats statCollectionInterval time.Duration + incomingIsLongest bool now func() time.Time maxBlockProcessingDuration time.Duration @@ -416,7 +417,10 @@ func (p *Processor) processBlock(blockMsg *p2p.BlockMessage) (err error) { case blocktx_api.Status_STALE: longestTxs, staleTxs, ok = p.handleStaleBlock(ctx, block) case blocktx_api.Status_ORPHANED: + p.logger.Info("==== block status is orphaned - handle orphans", "hash", blockHash.String()) longestTxs, staleTxs, ok = p.handleOrphans(ctx, block) + + p.logger.Info("==== orphaned block handled", "hash", blockHash.String(), "longest txs", len(longestTxs), "stale txs", len(staleTxs)) default: return ErrUnexpectedBlockStatus } @@ -455,15 +459,18 @@ 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 } - // 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 - // } + if p.incomingIsLongest { + incomingBlock.Status = blocktx_api.Status_LONGEST + } else { + p.logger.Info("==== assign block status") + 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())) @@ -476,16 +483,17 @@ 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() { tracing.EndTracing(span, err) }() + p.logger.Info("==== get prev block", "hash", prevBlockHash.String()) prevBlock, _ := p.store.GetBlock(ctx, &prevBlockHash) if prevBlock == nil { + p.logger.Info("==== prev block is nil", "hash", prevBlockHash.String()) // This check is only in case there's a fresh, empty database // with no blocks, to mark the first block as the LONGEST chain var longestTipExists bool @@ -507,6 +515,7 @@ func (p *Processor) assignBlockStatus(ctx context.Context, block *blocktx_api.Bl } if prevBlock.Status == blocktx_api.Status_LONGEST { + p.logger.Info("==== prev block status longest", "hash", prevBlockHash.String()) var competingBlock *blocktx_api.Block competingBlock, err = p.store.GetLongestBlockByHeight(ctx, block.Height) if err != nil && !errors.Is(err, store.ErrBlockNotFound) { @@ -531,13 +540,13 @@ func (p *Processor) assignBlockStatus(ctx context.Context, block *blocktx_api.Bl return nil } + p.logger.Info("==== new block status", "hash", prevBlockHash.String(), "status", prevBlock.Status.String()) // ORPHANED or STALE block.Status = prevBlock.Status 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) { diff --git a/internal/blocktx/processor_opts.go b/internal/blocktx/processor_opts.go index fe0ac49ed..0099152f6 100644 --- a/internal/blocktx/processor_opts.go +++ b/internal/blocktx/processor_opts.go @@ -79,3 +79,9 @@ func WithMaxBlockProcessingDuration(d time.Duration) func(handler *Processor) { handler.maxBlockProcessingDuration = d } } + +func WithIncomingIsLongest(enabled bool) func(*Processor) { + return func(processor *Processor) { + processor.incomingIsLongest = enabled + } +} diff --git a/internal/blocktx/processor_test.go b/internal/blocktx/processor_test.go index d226fc794..8f23aaaa9 100644 --- a/internal/blocktx/processor_test.go +++ b/internal/blocktx/processor_test.go @@ -246,9 +246,6 @@ 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 diff --git a/internal/blocktx/store/postgresql/fixtures/insert_block_transactions/blocktx.registered_transactions.yaml b/internal/blocktx/store/postgresql/fixtures/insert_block_transactions/blocktx.registered_transactions.yaml index 1faee19e9..a1fb0d6fc 100644 --- a/internal/blocktx/store/postgresql/fixtures/insert_block_transactions/blocktx.registered_transactions.yaml +++ b/internal/blocktx/store/postgresql/fixtures/insert_block_transactions/blocktx.registered_transactions.yaml @@ -1,16 +1,16 @@ -#- hash: 0x76732b80598326a18d3bf0a86518adbdf95d0ddc6ff6693004440f4776168c3b -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0x164e85a5d5bc2b2372e8feaa266e5e4b7d0808f8d2b784fb1f7349c4726392b0 -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0xb4201cc6fc5768abff14adf75042ace6061da9176ee5bb943291b9ba7d7f5743 -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0x37bd6c87927e75faeb3b3c939f64721cda48e1bb98742676eebe83aceee1a669 -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0x952f80e20a0330f3b9c2dfd1586960064e797218b5c5df665cada221452c17eb -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0x861a281b27de016e50887288de87eab5ca56a1bb172cdff6dba965474ce0f608 -# inserted_at: 2023-12-15 14:00:00 -#- hash: 0x9421cc760c5405af950a76dc3e4345eaefd4e7322f172a3aee5e0ddc7b4f8313 -# inserted_at: 2023-12-15 14:00:00 +- hash: 0x76732b80598326a18d3bf0a86518adbdf95d0ddc6ff6693004440f4776168c3b + inserted_at: 2023-12-15 14:00:00 +- hash: 0x164e85a5d5bc2b2372e8feaa266e5e4b7d0808f8d2b784fb1f7349c4726392b0 + inserted_at: 2023-12-15 14:00:00 +- hash: 0xb4201cc6fc5768abff14adf75042ace6061da9176ee5bb943291b9ba7d7f5743 + inserted_at: 2023-12-15 14:00:00 +- hash: 0x37bd6c87927e75faeb3b3c939f64721cda48e1bb98742676eebe83aceee1a669 + inserted_at: 2023-12-15 14:00:00 +- hash: 0x952f80e20a0330f3b9c2dfd1586960064e797218b5c5df665cada221452c17eb + inserted_at: 2023-12-15 14:00:00 +- hash: 0x861a281b27de016e50887288de87eab5ca56a1bb172cdff6dba965474ce0f608 + inserted_at: 2023-12-15 14:00:00 +- hash: 0x9421cc760c5405af950a76dc3e4345eaefd4e7322f172a3aee5e0ddc7b4f8313 + inserted_at: 2023-12-15 14:00:00 - hash: 0x8b7d038db4518ac4c665abfc5aeaacbd2124ad8ca70daa8465ed2c4427c41b9b inserted_at: 2023-12-15 14:00:00 diff --git a/internal/blocktx/store/postgresql/postgres_test.go b/internal/blocktx/store/postgresql/postgres_test.go index 4ff579784..f5f36295d 100644 --- a/internal/blocktx/store/postgresql/postgres_test.go +++ b/internal/blocktx/store/postgresql/postgres_test.go @@ -137,8 +137,7 @@ func TestPostgresDB(t *testing.T) { blockHash1 := testutils.RevChainhash(t, "000000000000000001b8adefc1eb98896c80e30e517b9e2655f1f929d9958a48") blockHash2 := testutils.RevChainhash(t, "00000000000000000a081a539601645abe977946f8f6466a3c9e0c34d50be4a8") - // TODO: uncomment when all block gaps are filled - // blockHashViolating := testutils.RevChainhash(t, "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984") + blockHashViolating := testutils.RevChainhash(t, "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984") merkleRoot := testutils.RevChainhash(t, "31e25c5ac7c143687f55fc49caf0f552ba6a16d4f785e4c9a9a842179a085f0c") expectedBlock := &blocktx_api.Block{ Hash: blockHash2[:], @@ -148,14 +147,13 @@ func TestPostgresDB(t *testing.T) { Status: blocktx_api.Status_LONGEST, Processed: true, } - // TODO: uncomment when all block gaps are filled - // expectedBlockViolatingUniqueIndex := &blocktx_api.Block{ - // Hash: blockHashViolating[:], - // PreviousHash: blockHash1[:], - // MerkleRoot: merkleRoot[:], - // Height: 100, - // Status: blocktx_api.Status_LONGEST, - // } + expectedBlockViolatingUniqueIndex := &blocktx_api.Block{ + Hash: blockHashViolating[:], + PreviousHash: blockHash1[:], + MerkleRoot: merkleRoot[:], + Height: 100, + Status: blocktx_api.Status_LONGEST, + } expectedBlockOverrideStatus := &blocktx_api.Block{ Hash: blockHash2[:], PreviousHash: blockHash1[:], @@ -178,11 +176,10 @@ func TestPostgresDB(t *testing.T) { require.NoError(t, err) require.Equal(t, expectedBlock, actualBlockResp) - // TODO: uncomment when all block gaps are filled // when - // _, err = postgresDB.UpsertBlock(ctx, expectedBlockViolatingUniqueIndex) + _, err = postgresDB.UpsertBlock(ctx, expectedBlockViolatingUniqueIndex) // then - // require.ErrorIs(t, err, store.ErrFailedToInsertBlock) + require.ErrorIs(t, err, store.ErrFailedToInsertBlock) // when id, err = postgresDB.UpsertBlock(ctx, expectedBlockOverrideStatus) @@ -394,11 +391,10 @@ func TestPostgresDB(t *testing.T) { {Hash: hash4Stale[:], Status: blocktx_api.Status_LONGEST}, } - // TODO: uncomment when all block gaps are filled - // blockStatusUpdatesViolating := []store.BlockStatusUpdate{ - // // there is already a LONGEST block at that height - // {Hash: hash1Longest[:], Status: blocktx_api.Status_LONGEST}, - // } + blockStatusUpdatesViolating := []store.BlockStatusUpdate{ + // there is already a LONGEST block at that height + {Hash: hash1Longest[:], Status: blocktx_api.Status_LONGEST}, + } // when err := postgresDB.UpdateBlocksStatuses(ctx, blockStatusUpdates) @@ -421,10 +417,9 @@ func TestPostgresDB(t *testing.T) { require.NoError(t, err) require.Equal(t, blocktx_api.Status_LONGEST, stale4.Status) - // TODO: uncomment when all block gaps are filled // when - // err = postgresDB.UpdateBlocksStatuses(ctx, blockStatusUpdatesViolating) - // require.ErrorIs(t, err, store.ErrFailedToUpdateBlockStatuses) + err = postgresDB.UpdateBlocksStatuses(ctx, blockStatusUpdatesViolating) + require.ErrorIs(t, err, store.ErrFailedToUpdateBlockStatuses) }) t.Run("get mined txs", func(t *testing.T) { diff --git a/test/config/config.yaml b/test/config/config.yaml index f65539a5e..397566ff4 100644 --- a/test/config/config.yaml +++ b/test/config/config.yaml @@ -68,6 +68,7 @@ metamorph: checkSeenOnNetworkOlderThan: 3h checkSeenOnNetworkPeriod: 4h monitorPeers: true + incomingIsLongest: false profilerAddr: localhost:9992 health: serverDialAddr: localhost:8005 @@ -97,7 +98,7 @@ blocktx: registerTxsInterval: 200ms fillGaps: enabled: true - interval: 30s + interval: 1s # This allows e2e tests to pass as there will be no gaps when initial blocks are created maxAllowedBlockHeightMismatch: 3 api: diff --git a/test/init_test.go b/test/init_test.go index 061bbab8c..1b4f87378 100644 --- a/test/init_test.go +++ b/test/init_test.go @@ -25,7 +25,7 @@ func TestMain(m *testing.M) { } func setupSut() { - log.Printf("init tests") + log.Println("init tests") if os.Getenv("TEST_LOCAL") != "" { nodeHost = "localhost" diff --git a/test/submit_01_single_test.go b/test/submit_01_single_test.go index c5db2bdab..dfb7f7770 100644 --- a/test/submit_01_single_test.go +++ b/test/submit_01_single_test.go @@ -117,7 +117,8 @@ func TestSubmitSingle(t *testing.T) { t.Logf("Transaction status: %s", statusResponse.TxStatus) - node_client.Generate(t, bitcoind, 1) + blockHash := node_client.Generate(t, bitcoind, 1) + t.Logf("=== new block generated - hash: %s", blockHash) statusResponse = getRequest[TransactionResponse](t, statusURL) require.Equal(t, StatusMined, statusResponse.TxStatus) diff --git a/test/submit_05_reorg_test.go b/test/submit_05_reorg_test.go index 3badd0672..971e59b80 100644 --- a/test/submit_05_reorg_test.go +++ b/test/submit_05_reorg_test.go @@ -15,9 +15,6 @@ 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)