forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
da: add get timeout to da client
- Loading branch information
Showing
15 changed files
with
162 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package celestia | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
opservice "github.com/ethereum-optimism/optimism/op-service" | ||
) | ||
|
||
const ( | ||
DaRpcFlagName = "da.rpc" | ||
) | ||
|
||
var ( | ||
defaultDaRpc = "localhost:26650" | ||
) | ||
|
||
func CLIFlags(envPrefix string) []cli.Flag { | ||
return []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: DaRpcFlagName, | ||
Usage: "dial address of data availability grpc client", | ||
Value: defaultDaRpc, | ||
EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_RPC"), | ||
}, | ||
} | ||
} | ||
|
||
type Config struct { | ||
DaRpc string | ||
} | ||
|
||
func (c Config) Check() error { | ||
if c.DaRpc == "" { | ||
c.DaRpc = defaultDaRpc | ||
} | ||
|
||
if _, err := url.Parse(c.DaRpc); err != nil { | ||
return fmt.Errorf("invalid da rpc: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
type CLIConfig struct { | ||
DaRpc string | ||
} | ||
|
||
func (c CLIConfig) Check() error { | ||
if c.DaRpc == "" { | ||
c.DaRpc = defaultDaRpc | ||
} | ||
|
||
if _, err := url.Parse(c.DaRpc); err != nil { | ||
return fmt.Errorf("invalid da rpc: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func NewCLIConfig() CLIConfig { | ||
return CLIConfig{ | ||
DaRpc: defaultDaRpc, | ||
} | ||
} | ||
|
||
func ReadCLIConfig(ctx *cli.Context) CLIConfig { | ||
return CLIConfig{ | ||
DaRpc: ctx.String(DaRpcFlagName), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package celestia | ||
|
||
// DerivationVersionCelestia is a byte marker for celestia references submitted | ||
// to the batch inbox address as calldata. | ||
// Mnemonic 0xce = celestia | ||
// version 0xce references are encoded as: | ||
// [8]byte block height ++ [32]byte commitment | ||
// in little-endian encoding. | ||
// see: https://github.com/rollkit/celestia-da/blob/1f2df375fd2fcc59e425a50f7eb950daa5382ef0/celestia.go#L141-L160 | ||
const DerivationVersionCelestia = 0xce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.