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

feat(shwap): Integrate shrex into shwap #3554

Merged
merged 10 commits into from
Jul 30, 2024

Conversation

walldiss
Copy link
Member

@walldiss walldiss commented Jul 6, 2024

This PR add shrex integration with shwap. Key changes:

  • Shrex uses shwap-id to request data
  • Added shwap-id verification for bot client and server
  • bumped shrex version to prevent old clients from hitting new protocol servers
  • move shrex into shwap protocols folder (closer to bitswap)
  • move shrex getter into shwap/shrex
  • update shrex getter implementation and tests

This PR is meant to be broken on lint and test CI. It will be fixed in subsequent PR, that will integrate shrex into nodebuilder.

share/shwap/pb/shwap.proto Outdated Show resolved Hide resolved
share/shwap/namespace_data_id.go Outdated Show resolved Hide resolved
// ResetContextOnError returns a fresh context if the given context has an error.
func ResetContextOnError(ctx context.Context) context.Context {
if ctx.Err() != nil {
ctx = context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this is an old func, but should we change to something 'safer' ? context.WithTimeout(time.Second) by example. WDYT ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it makes sense, but not in this PR. Perhaps time.Second should be passed to function in. Like

NewContextOnContextErr(ctx, newTimeout time.Time)

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

nd review

share/shwap/p2p/shrex/shrexnd/client.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/params.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/client.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/server.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/exchange_test.go Outdated Show resolved Hide resolved
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

  • ctxOnError and utils moves feel competely unnecessary and could be avoided
  • general comment is to extract read(with validate)/write helpers to shwap pkg

libs/utils/close.go Show resolved Hide resolved
share/shwap/p2p/shrex/shrexeds/params.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrex_getter/shrex_test.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/server.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexeds/server.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexeds/server.go Outdated Show resolved Hide resolved
share/getters/cascade.go Show resolved Hide resolved
libs/utils/error.go Outdated Show resolved Hide resolved
share/shwap/eds_id.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/params.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexeds/params.go Outdated Show resolved Hide resolved
share/shwap/namespace_data.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/server.go Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/server.go Outdated Show resolved Hide resolved
share/shwap/p2p/shrex/shrexnd/server.go Outdated Show resolved Hide resolved
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

:shipit:

@walldiss walldiss merged commit c4e602a into celestiaorg:shwap Jul 30, 2024
15 of 18 checks passed
}
srv.metrics.ObserveRequests(ctx, 1, shrex.StatusSuccess)
if err = s.Close(); err != nil {
log.Debugw("server: closing stream", "err", err)
Copy link
Member

Choose a reason for hiding this comment

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

error

return
}
if err = s.Close(); err != nil {
log.Debugw("server: closing stream", "err", err)
Copy link
Member

Choose a reason for hiding this comment

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

error

@Wondertan Wondertan deleted the shrex-shwap branch July 30, 2024 20:21
}
}

func readEds(ctx context.Context, stream network.Stream, root *share.AxisRoots) (*rsmt2d.ExtendedDataSquare, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This whole helper should move to new_eds as ReadAccessor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feat Attached to feature PRs shwap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants