-
Notifications
You must be signed in to change notification settings - Fork 421
Clarify TxConfig initialization in golang-client-tutorial.md #2097
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
base: main
Are you sure you want to change the base?
Conversation
Improved the explanation of TxConfig creation using `NewTxConfig` with default gas price settings.
WalkthroughThe Golang client tutorial was updated to use a default transaction configuration object when submitting a blob, replacing the previous use of nil. The import section now includes the state package, and comments were added to explain the rationale behind this change. No changes were made to control flow or error handling. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GolangClientTutorial
participant CelestiaClient
participant State
User->>GolangClientTutorial: Call SubmitBlob()
GolangClientTutorial->>State: Create TxConfig (NewTxConfig)
GolangClientTutorial->>CelestiaClient: Submit(blob, namespace, TxConfig)
CelestiaClient-->>GolangClientTutorial: Return result/error
GolangClientTutorial-->>User: Return result/error
Possibly related PRs
Suggested reviewers
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tutorials/golang-client-tutorial.md (1)
83-89
: Use default TxConfig to prevent nil-related panicsReplacing
nil
withstate.NewTxConfig()
ensuresDefaultGasPrice
andDefaultMaxGasPrice
are initialized before submission.Consider showing how to pass custom options, e.g.:
options := state.NewTxConfig( state.WithGasPrice(customPrice), state.WithMaxGasPrice(customMax), )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tutorials/golang-client-tutorial.md
(3 hunks)
🔇 Additional comments (2)
tutorials/golang-client-tutorial.md (2)
57-61
: Correctly added state package importThe import of
github.com/celestiaorg/celestia-node/state
is required to accessstate.NewTxConfig()
. It aligns with the existing import style and supports the updated example.
313-319
: Mirror default TxConfig initialization in complete exampleThe
main.go
snippet correctly initializesoptions := state.NewTxConfig()
to use safe defaults, matching the tutorial.
let's also update the CI/CD that was added in #2069 for this |
Overview
This PR improves the documentation of the
NewTxConfig
function ingolang-client-tutorial.md
.The updated comment explains that
NewTxConfig()
initializes a transaction configuration with default gas settings (DefaultGasPrice
,DefaultMaxGasPrice
) and that it can optionally take variadic options to customize its behavior.This change is important because passing
nil
as theTxConfig
can lead to runtime errors. For example, when callingclient.Blob.Submit(ctx, []*blob.Blob{...}, nil)
, althoughnil
is accepted by the function signature, it may cause internal panics due to uninitialized fields in the transaction context. Using a defaultTxConfig
avoids this and ensures stability.Context
While following the Go client tutorial, I encountered a runtime error when submitting a blob using
nil
for theSubmitOptions
. This was resolved by explicitly initializing aTxConfig
usingstate.NewTxConfig()
. This PR updates the guide to help future developers avoid the same pitfall.Checklist
Summary by CodeRabbit