-
Notifications
You must be signed in to change notification settings - Fork 5
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: add KeyringKeyname #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ type DAConfig struct { | |
NamespaceId string `koanf:"namespace-id" ` | ||
AuthToken string `koanf:"auth-token" reload:"hot"` | ||
ReadAuthToken string `koanf:"read-auth-token" reload:"hot"` | ||
KeyringKeyname string `koanf:"keyring-keyname" reload:"hot"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added these in this spot of the struct so that DA-related auth stuff is near each other. Totally cool to move elsewhere if it makes more sense |
||
NoopWriter bool `koanf:"noop-writer" reload:"hot"` | ||
ValidatorConfig *ValidatorConfig `koanf:"validator-config"` | ||
ReorgOnReadFailure bool `koanf:"dangerous-reorg-on-read-failure"` | ||
|
@@ -108,6 +109,7 @@ func CelestiaDAConfigAddOptions(prefix string, f *pflag.FlagSet) { | |
f.String(prefix+".namespace-id", "", "Celestia Namespace to post data to") | ||
f.String(prefix+".auth-token", "", "Auth token for Celestia Node") | ||
f.String(prefix+".read-auth-token", "", "Auth token for Celestia Node") | ||
f.String(prefix+".keyring-keyname", "", "Keyring keyname for Celestia Node for blobs submission") | ||
f.Bool(prefix+".noop-writer", false, "Noop writer (disable posting to celestia)") | ||
f.String(prefix+".validator-config"+".tendermint-rpc", "", "Tendermint RPC endpoint, only used for validation") | ||
f.String(prefix+".validator-config"+".eth-rpc", "", "L1 Websocket connection, only used for validation") | ||
|
@@ -147,6 +149,17 @@ func NewCelestiaDA(cfg *DAConfig, ethClient *ethclient.Client) (*CelestiaDA, err | |
return nil, err | ||
} | ||
|
||
if cfg.KeyringKeyname == "" { | ||
return nil, errors.New("keyring keyname cannot be blank") | ||
} | ||
if !isValidKeyringKeyname(cfg.KeyringKeyname) { | ||
return nil, fmt.Errorf("invalid keyring keyname format: %s", cfg.KeyringKeyname) | ||
} | ||
err = daClient.SetKeyringKeyname(cfg.KeyringKeyname) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to set keyring keyname: %w", err) | ||
} | ||
|
||
if cfg.ValidatorConfig != nil { | ||
trpc, err := http.New(cfg.ValidatorConfig.TendermintRPC, "/websocket") | ||
if err != nil { | ||
|
@@ -704,3 +717,8 @@ func (c *CelestiaDA) returnErrorHelper(err error) (*ReadResult, error) { | |
|
||
return nil, err | ||
} | ||
|
||
// Validate that the KeyringKeyname is a alphanumeric string of length > 0 | ||
func isValidKeyringKeyname(name string) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we need this tbh! |
||
return len(name) > 0 && regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(name) | ||
} |
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.
This is just to improve UX of the readme and avoid people sidescrolling, so they can see things at once