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!: using celestia RPC instead of Rest API #544

Conversation

mtsitrin
Copy link
Contributor

PR Standards

Opening a pull request should be able to meet the following requirements


For Author:

  • Targeted PR against correct branch
  • included the correct type prefix in the PR title
  • Linked to Github issue with discussion and accepted design
  • Targets only one github issue
  • Wrote unit and integration tests
  • All CI checks have passed
  • Added relevant godoc comments

For Reviewer:

  • confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • confirmed all author checklist items have been addressed

After reviewer approval:

  • In case targets main branch, PR should be squashed and merged.
  • In case PR targets a release branch, PR should be rebased.

}
blobs := []*blob.Blob{blockBlob}

estimatedGas := DefaultEstimateGas(uint32(len(data)))
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we estimate here the len(blobs) vs len(data)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it's the same as in celestia-node

if txResponse.Code != 0 {
c.logger.Error("Failed to submit DA batch. Emitting health event and trying again", "txResponse", txResponse.RawLog, "code", txResponse.Code)
res, err := da.SubmitBatchHealthEventHelper(c.pubsubServer, c.ctx, false, errors.New(txResponse.RawLog))
if txResponse == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we can skip this response and the next (txresponse.Code) as they are doing it currently in their new api: https://github.com/celestiaorg/celestia-node/blob/ccf9b56317ae8941f91c5d09f24fe8422bbe64bb/state/core_access.go#L256

Copy link
Contributor Author

Choose a reason for hiding this comment

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

validating txResponse != nil is good practice to avoid possible panics.
i'll remove the code check

daHeight := uint64(txResponse.Height)
if daHeight == 0 {
c.logger.Debug("Failed to receive DA batch inclusion result. Waiting for inclusion", "txHash", txResponse.TxHash)
daHeight, err = c.waitForTXInclusion(txResponse.TxHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we remove the inclusion test?
the submitPayForBlock broadcasts the tx in sync mode which means it's not necessarily gonna get included in a block.
Also from their docs: https://docs.celestia.org/nodes/transaction-resubmission#transaction-resubmission

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's actually in block mode and by their docs it will fail after 75 sec, and the caller expected to retry.
this implementation is not relevant IMO

We do plan to get the inclusion proof/commitment, we have separate issue for it.

@mtsitrin mtsitrin marked this pull request as ready for review December 28, 2023 15:40
@mtsitrin mtsitrin requested a review from a team as a code owner December 28, 2023 15:40
…o-use-rpc-client-as-api-gateway-is-gonna-get-deprecated-for-writing-to-celestia
return res
err := errors.New("txResponse is nil")
c.logger.Error("Failed to submit DA batch", "error", err)
return da.ResultSubmitBatch{
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we returning here and not retrying and submitting an health event? the node will simply panic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well it's not supposed to happen, so IMO panic is the right choice (similar to invariant break)
WDYT

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see it as an invariant broken or a bug so I don't think we should panic, especially if retry could help (which is why we added it in the previous version as it was the celestia's network instability/response).

Also if we panic and restart don't see why would it change anything if it depends on the celestia network.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not depend on the network
it's part of the API contract. u don't suppose to get nil resp and nil err

but ok I'll change it

@omritoptix
Copy link
Contributor

tests failing

Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 90 lines in your changes are missing coverage. Please review.

Comparison is base (14ae6fd) 52.43% compared to head (65fa5c9) 48.17%.
Report is 1 commits behind head on main.

Files Patch % Lines
da/celestia/celestia.go 32.30% 41 Missing and 3 partials ⚠️
mocks/da/celestia/CelestiaRPCClient.go 50.00% 12 Missing and 13 partials ⚠️
da/celestia/rpc.go 0.00% 8 Missing ⚠️
settlement/dymension/dymension.go 41.66% 5 Missing and 2 partials ⚠️
da/celestia/config.go 69.23% 2 Missing and 2 partials ⚠️
settlement/base.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #544      +/-   ##
==========================================
- Coverage   52.43%   48.17%   -4.27%     
==========================================
  Files         100       98       -2     
  Lines       14764    14484     -280     
==========================================
- Hits         7742     6978     -764     
- Misses       5911     6535     +624     
+ Partials     1111      971     -140     

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

@mtsitrin mtsitrin merged commit 379b93e into main Jan 1, 2024
3 of 5 checks passed
@mtsitrin mtsitrin deleted the mtsitrin/398-change-to-use-rpc-client-as-api-gateway-is-gonna-get-deprecated-for-writing-to-celestia branch January 1, 2024 08:01
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.

Change to use rpc client as api gateway is gonna get deprecated for writing to celestia
2 participants