Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services: add new block fetching from NeoFS service #3515

Merged
merged 5 commits into from
Sep 12, 2024
Merged

Conversation

AliceInHunterland
Copy link
Contributor

@AliceInHunterland AliceInHunterland commented Jul 16, 2024

  • documentation update
  • tests

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 36.58537% with 312 lines in your changes missing coverage. Please review.

Project coverage is 85.21%. Comparing base (d9a6a7c) to head (0b31a29).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/blockfetcher/blockfetcher.go 18.29% 199 Missing and 2 partials ⚠️
pkg/services/oracle/neofs/neofs.go 15.87% 50 Missing and 3 partials ⚠️
pkg/network/server.go 56.36% 16 Missing and 8 partials ⚠️
cli/server/dump_bin.go 64.00% 9 Missing and 9 partials ⚠️
pkg/network/bqueue/queue.go 60.00% 12 Missing ⚠️
pkg/config/application_config.go 50.00% 1 Missing and 1 partial ⚠️
pkg/config/config.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3515      +/-   ##
==========================================
- Coverage   85.79%   85.21%   -0.59%     
==========================================
  Files         330      333       +3     
  Lines       38536    38953     +417     
==========================================
+ Hits        33062    33192     +130     
- Misses       3928     4192     +264     
- Partials     1546     1569      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
case ps[0] == headerCmd:
res.ReadCloser, err = getHeader(ctx, s, c, objectAddr)
case ps[0] == hashCmd:
res.ReadCloser, err = getHash(ctx, s, c, objectAddr, ps[1:]...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/config/oracle_config.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/oracle/neofs/neofs.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
@AliceInHunterland AliceInHunterland force-pushed the block-fetcher branch 3 times, most recently from 29559e3 to 416c04e Compare August 15, 2024 19:09
@AliceInHunterland AliceInHunterland marked this pull request as ready for review August 15, 2024 19:19
config/protocol.testnet.yml Outdated Show resolved Hide resolved
pkg/config/application_config.go Outdated Show resolved Hide resolved
config/protocol.testnet.yml Outdated Show resolved Hide resolved
pkg/config/neofs.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/oid_obj_experiments.go Outdated Show resolved Hide resolved
pkg/services/oracle/neofs/neofs.go Outdated Show resolved Hide resolved
pkg/services/oracle/neofs/neofs.go Outdated Show resolved Hide resolved
pkg/services/oracle/neofs/neofs.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Show resolved Hide resolved
@@ -105,6 +106,13 @@ func NewCommands() []*cli.Command {
Action: dumpDB,
Flags: cfgCountOutFlags,
},
{
Name: "dump-bin",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not dump, but fetch.

Copy link
Member

@AnnaShaleva AnnaShaleva Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-khimov, why fetch? This command saves dump of every block to a separate file, it doesn't fetch them from the network.

config/protocol.testnet.yml Outdated Show resolved Hide resolved
pkg/config/application_config.go Outdated Show resolved Hide resolved
Comment on lines 304 to 311
if s.ServerConfig.NeoFSCfg.Restore {
done := make(chan struct{})
s.blockFetcher.Start(
func() {
s.log.Info("BlockFetcher service finished")
close(done)
})
<-done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may we postpone the StateSync integration to a separate issue and prohibit to enable BlockFetcher and StateSync simultaneously in the node config?

Let's do it here, header objects were always meant to be stored as well.

We can decouple some of the network server logic to detect sync/non-sync and then try various fetching strategies (NeoFS/P2P) depending on the state. But NeoFS sync is mostly for the initial one, then P2P is sufficient. Anyway, bqueue.Queue should be reused, it handles blocks nicely already.

if err != nil {
return nil, err
}
rc, err := neofs.GetWithClient(ctx, bfs.client, privateKey, u, bfs.Nodes[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pool?

pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first part of comments, I'll left the second part soon.

cli/server/dump_bin.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing a retry mechanism (for cases when some object was failed to load or when some block was failed to be added into the blockqueue), but it will be implemented later. Let's now focus on finalisation of two BlockFetcher operation modes to be able to benchmark them.

pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Outdated Show resolved Hide resolved
cli/server/dump_bin.go Show resolved Hide resolved
config/protocol.testnet.yml Outdated Show resolved Hide resolved
internal/fakechain/fakechain.go Outdated Show resolved Hide resolved
pkg/config/application_config.go Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
@AnnaShaleva
Copy link
Member

Still have something to fix in BlockFetcher before benchmarks.

@AliceInHunterland AliceInHunterland force-pushed the block-fetcher branch 2 times, most recently from 70cfc5a to cdbaff1 Compare August 23, 2024 10:12
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AliceInHunterland BlockFetcher is missing at least some basic tests for those things that can be tested without network. E.g. isActive, service constructors, default parameters validation and etc.

pkg/network/bqueue/queue.go Outdated Show resolved Hide resolved
docs/neofs-blockstorage.md Outdated Show resolved Hide resolved
docs/neofs-blockstorage.md Outdated Show resolved Hide resolved
docs/neofs-blockstorage.md Outdated Show resolved Hide resolved
docs/neofs-blockstorage.md Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher_test.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
pkg/services/blockfetcher/blockfetcher.go Outdated Show resolved Hide resolved
If Blocking mode is on PutBlock will block until there is enough space
in the queue.

Co-authored-by: Anna Shaleva <[email protected]>
Signed-off-by: Ekaterina Pavlova <[email protected]>
@AliceInHunterland
Copy link
Contributor Author

Filename ms Block Height Avg ms/1K Blocks Timeout Logs
SkipIndexFilesSearch: false
neogo-oib-10000-bq-10000-w10000.log 1803435 465820 3871.53 30m Logs
neogo-oib-10000-bq-40000.log 1800326 470979 3822.52 30m
neogo-oib-10000-bq-10000-w1000.log 1823734 467954 3897.25 30m
neogo-oib-8000-bq-40000-w1000.log 1825217 461961 3951.02 30m
neogo-oib-8000-bq-8000-w500.log 1810582 469292 3858.11 30m
neogo-oib-8000-bq-8000-w500.log 1800650 486261 3703.05 30m
neogo-oib-8000-bq-40000-w500.log 1799876 447389 4023.07 30m
neogo-oib-100k-bq-200k-w500.log 1799919 412022 4368.50 30m
neogo-oib-1000-bq-2000-w500.log 672935 216737 3104.85 fail
neogo-oib-1000-bq-2000-w100.log 1801330 465058 3873.34 30m
neogo-oib-8000-bq-32000-w500_60min.log 2902400 837815 3464.25 60m
SkipIndexFilesSearch: true
neogo-index-oib-16000-bq-40000-w2000.log 1805766 476710 3787.98 30m
neogo-oib-index-8000-bq-8000-w500.log 1800670 487830 3691.18 30m
neogo-oib-index-8000-bq-40000-w500.log 1810972 490053 3695.46 30m
neogo-oib-index-8000-bq-32000-w500.log 1802607 502887 3584.52 30m
neogo-oib-index-8000-bq-16000-w500.log 1799940 487605 3691.39 30m
neogo-oib-index-8000-bq-32000-w500_2.log 2399943 923247 2599.46 40m BlockDownloader: block height mismatch then p2p
neogo-oib-index-8000-bq-32000-w500_3.log 2409762 681271 3537.16 40m
neogo-oib-index-8000-bq-32000-w500_4.log 2442571 723872 3374.31 40m
neogo-oib-index-8000-bq-32000-w500_5.log 2405396 712686 3375.11 40m
neogo-oib-index-8000-bq-32000-w500_6.log Failed to objectGet block {"error": "header: status: code = 1024 message = storage engine is closed"} at the beginning
Enabled: false
neogo-p2p.log 1243070 408989 3039.37 30m
neogo-p2p2.log 1799885 345093 5215.65 30m Overall time in logs
neogo-p2p2.log 1252662 345093 3629.93 30m Time until the last persist
neogo-p2p3.log 2399849 866092 2770.89 40m
neogo-p2p-60.log 2527980 935500 2702.28 60m

@AnnaShaleva AnnaShaleva force-pushed the block-fetcher branch 3 times, most recently from d41946b to 9f186ce Compare September 10, 2024 07:03
IDs in binary form ordered by block index. Each index file is marked with the
following attributes:
- index file identifier with consecutive file index value (`oid:0`)
- the number of OIDs included into index file (`size:128000`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-khimov, do we need size:128000 attribute?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as an option, various index files size for different schemas.

pkg/services/blockfetcher/blockfetcher_test.go Outdated Show resolved Hide resolved
@AnnaShaleva
Copy link
Member

AnnaShaleva commented Sep 10, 2024

@roman-khimov, ready for review&merge from my side.

return fmt.Errorf("failed to fetch '%s' object with index %d: %w", bfs.cfg.IndexFileAttribute, startIndex, err)
}

err = bfs.streamBlockOIDs(oidsRC, int(skip))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible problem that I see with current design is that when we're getting OIDs from index files, a connection to storage node remains opened. We read OID files step-by-step and if destination channel is full then streamBlockOIDs will wait with opened connection to NeoFS storage node. Timeout may happen here.

Copy link
Contributor Author

@AliceInHunterland AliceInHunterland Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry probably will help?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a design problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref. #3585.

@AnnaShaleva
Copy link
Member

AnnaShaleva commented Sep 10, 2024

@AliceInHunterland, windows tests are failing.

2024-09-10T08:10:22.6955777Z === RUN   TestDumpBin/output_directory_with_no_write_permission
2024-09-10T08:10:22.6956902Z INFO	initial gas supply is not set or wrong, setting default value	{"InitialGASSupply": "52000000"}
2024-09-10T08:10:22.6958532Z INFO	P2PNotaryRequestPayloadPool size is not set or wrong, setting default value	{"P2PNotaryRequestPayloadPoolSize": 1000}
2024-09-10T08:10:22.6960052Z INFO	MaxBlockSize is not set or wrong, setting default value	{"MaxBlockSize": 262144}
2024-09-10T08:10:22.6961634Z INFO	MaxBlockSystemFee is not set or wrong, setting default value	{"MaxBlockSystemFee": 900000000000}
2024-09-10T08:10:22.6963145Z INFO	MaxTransactionsPerBlock is not set or wrong, using default value	{"MaxTransactionsPerBlock": 512}
2024-09-10T08:10:22.6964772Z INFO	MaxValidUntilBlockIncrement is not set or wrong, using default value	{"MaxValidUntilBlockIncrement": 5760}
2024-09-10T08:10:22.6965947Z INFO	restoring blockchain	{"version": "0.2.12"}
2024-09-10T08:10:22.6967091Z INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2024-09-10T08:10:22.6968618Z INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2024-09-10T08:10:22.6969523Z     executor.go:279: 
2024-09-10T08:10:22.6970634Z         	Error Trace:	D:/a/neo-go/neo-go/internal/testcli/executor.go:279
2024-09-10T08:10:22.6972184Z         	            				D:/a/neo-go/neo-go/cli/server/dump_bin_test.go:77
2024-09-10T08:10:22.6973157Z         	Error:      	An error is expected but got nil.
2024-09-10T08:10:22.6974475Z         	Test:       	TestDumpBin/output_directory_with_no_write_permission
2024-09-10T08:10:22.6975776Z === RUN   TestDumpBin/zero_blocks_(full_chain_dump)
2024-09-10T08:10:22.6977384Z INFO	initial gas supply is not set or wrong, setting default value	{"InitialGASSupply": "52000000"}
2024-09-10T08:10:22.6979761Z INFO	P2PNotaryRequestPayloadPool size is not set or wrong, setting default value	{"P2PNotaryRequestPayloadPoolSize": 1000}
2024-09-10T08:10:22.6981493Z INFO	MaxBlockSize is not set or wrong, setting default value	{"MaxBlockSize": 262144}
2024-09-10T08:10:22.6982912Z INFO	MaxBlockSystemFee is not set or wrong, setting default value	{"MaxBlockSystemFee": 900000000000}
2024-09-10T08:10:22.6984399Z INFO	MaxTransactionsPerBlock is not set or wrong, using default value	{"MaxTransactionsPerBlock": 512}
2024-09-10T08:10:22.6986102Z INFO	MaxValidUntilBlockIncrement is not set or wrong, using default value	{"MaxValidUntilBlockIncrement": 5760}
2024-09-10T08:10:22.6988631Z INFO	restoring blockchain	{"version": "0.2.12"}
2024-09-10T08:10:22.6990087Z INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2024-09-10T08:10:22.6991347Z INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2024-09-10T08:10:22.6992432Z === RUN   TestDumpBin/invalid_config_file
2024-09-10T08:10:22.6993594Z config 'invalid-config-path' doesn't exist and no matching embedded config was found
2024-09-10T08:10:22.6994705Z --- FAIL: TestDumpBin (0.66s)
2024-09-10T08:10:22.6995597Z     --- PASS: TestDumpBin/missing_output_directory (0.05s)
2024-09-10T08:10:22.6996568Z     --- PASS: TestDumpBin/successful_dump (0.06s)
2024-09-10T08:10:22.6997516Z     --- PASS: TestDumpBin/invalid_block_range (0.05s)
2024-09-10T08:10:22.6998678Z     --- FAIL: TestDumpBin/output_directory_with_no_write_permission (0.06s)
2024-09-10T08:10:22.6999901Z     --- PASS: TestDumpBin/zero_blocks_(full_chain_dump) (0.21s)
2024-09-10T08:10:22.7000930Z     --- PASS: TestDumpBin/invalid_config_file (0.00s)

Dump blocks (starting with the genesis or specified block) to the
directory in binary format.

Signed-off-by: Ekaterina Pavlova <[email protected]>
Could be used for operation with neofs.

Signed-off-by: Ekaterina Pavlova <[email protected]>
@AnnaShaleva
Copy link
Member

@AliceInHunterland, another test is failing on Win:

2024-09-10T09:41:30.9508836Z === RUN   TestServiceConstructor/invalid_wallet
2024-09-10T09:41:30.9509095Z     blockfetcher_test.go:97: 
2024-09-10T09:41:30.9510116Z         	Error Trace:	D:/a/neo-go/neo-go/pkg/services/blockfetcher/blockfetcher_test.go:97
2024-09-10T09:41:30.9511759Z         	Error:      	"open wallet: open invalid/path/to/wallet.json: The system cannot find the path specified." does not contain "no such file or directory"
2024-09-10T09:41:30.9512252Z         	Test:       	TestServiceConstructor/invalid_wallet
2024-09-10T09:41:30.9512552Z --- FAIL: TestServiceConstructor (0.01s)
2024-09-10T09:41:30.9513103Z     --- PASS: TestServiceConstructor/empty_configuration (0.00s)
2024-09-10T09:41:30.9513567Z     --- PASS: TestServiceConstructor/no_addresses (0.00s)
2024-09-10T09:41:30.9514038Z     --- PASS: TestServiceConstructor/default_values (0.00s)
2024-09-10T09:41:30.9514540Z     --- PASS: TestServiceConstructor/SDK_client (0.00s)
2024-09-10T09:41:30.9515017Z     --- FAIL: TestServiceConstructor/invalid_wallet (0.00s)
2024-09-10T09:41:30.9515139Z FAIL
2024-09-10T09:41:30.9515641Z FAIL	github.com/nspcc-dev/neo-go/pkg/services/blockfetcher	0.063s

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

pkg/config/application_config.go Show resolved Hide resolved
Close #3496

Co-authored-by: Anna Shaleva <[email protected]>
Signed-off-by: Ekaterina Pavlova <[email protected]>
@AnnaShaleva AnnaShaleva merged commit e1d5ac8 into master Sep 12, 2024
18 of 20 checks passed
@AnnaShaleva AnnaShaleva deleted the block-fetcher branch September 12, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants