Skip to content

Commit

Permalink
feat(tools): more examples for blocketa and blockheight (#3842)
Browse files Browse the repository at this point in the history
## Description

1. Add more examples for both tools `blockheight` and `blocketa`
2. Use the times + heights for the v2 activation height on each network
  • Loading branch information
rootulp committed Sep 5, 2024
1 parent 588ea98 commit 4b34f8b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
11 changes: 9 additions & 2 deletions tools/blocketa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ const (
// blockTime is the observed average time between blocks. You can update this
// value based on the block time on https://www.mintscan.io/celestia/block/ or
// the output from the blocktime tool.
blockTime = 12.05 // seconds between blocks for Mocha
blockTime = 11.75 // seconds between blocks on Mainnet Beta.

// exampleArabicaRPC is an example node RPC endpoint for the Arabica testnet.
exampleArabicaRPC = "https://rpc.celestia-arabica-11.com:443"

// exampleMochaRPC is an example node RPC endpoint for the Mocha testnet.
exampleMochaRPC = "https://celestia-mocha-rpc.publicnode.com:443"

// exampleMainnetHeight is an example node RPC endpoint for Mainnet Beta.
exampleMainnetRPC = "https://celestia-rpc.publicnode.com:443"

// exampleArabicaHeight is an example block height for the Arabica testnet.
exampleArabicaHeight = 1751707

// exampleMochaHeight is an example block height for the Mocha testnet.
exampleMochaHeight = 2585031

// exampleMainnetHeight is an example block height for Mainnet Beta.
exampleMainnetHeight = 2371495
)

func main() {
Expand All @@ -40,6 +46,7 @@ func Run() error {
fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMainnetRPC, exampleMainnetHeight)
return nil
}

Expand All @@ -65,7 +72,7 @@ func Run() error {
}
diffInBlockHeight := targetBlockHeight - currentHeight
diffInSeconds := blockTime * float64(diffInBlockHeight)
diffInTime, err := time.ParseDuration(fmt.Sprintf("%vs", diffInSeconds))
diffInTime, err := time.ParseDuration(fmt.Sprintf("%.0fs", diffInSeconds))
if err != nil {
return err
}
Expand Down
26 changes: 20 additions & 6 deletions tools/blockheight/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@ const (
// blockTime is the observed average time between blocks. You can update this
// value based on the block time on https://www.mintscan.io/celestia/block/ or
// the output from the blocktime tool.
blockTime = 11.30 // seconds between blocks for Arabica
blockTime = 11.75 // seconds between blocks on Mainnet Beta.

// exampleNodeRPC is an example node RPC endpoint for the Arabica testnet.
exampleNodeRPC = "https://rpc.celestia-arabica-11.com:443"
// exampleArabicaRPC is an example node RPC endpoint for the Arabica testnet.
exampleArabicaRPC = "https://rpc.celestia-arabica-11.com:443"

// targetTime is an example target time for the block height prediction.
targetTime = "2024-08-14T14:00:00"
// exampleMochaRPC is an example node RPC endpoint for the Mocha testnet.
exampleMochaRPC = "https://celestia-mocha-rpc.publicnode.com:443"

// exampleMainnetHeight is an example node RPC endpoint for Mainnet Beta.
exampleMainnetRPC = "https://celestia-rpc.publicnode.com:443"

// exampleArabicaTime is an example target time for the block height prediction.
exampleArabicaTime = "2024-08-19T14:00:00"

// exampleMochaTime is an example target time for the block height prediction.
exampleMochaTime = "2024-08-28T14:00:00"

// exampleMainnetTime is an example target time for the block height prediction.
exampleMainnetTime = "2024-09-18T14:00:00"

// layout is the expected time format for targetTime.
layout = "2006-01-02T15:04:05"
Expand All @@ -35,7 +47,9 @@ func main() {
func Run() error {
if len(os.Args) < 3 {
fmt.Printf("Usage: %s <node_rpc> <target_time>\n", os.Args[0])
fmt.Printf("Example: %s %s %s\n", os.Args[0], exampleNodeRPC, targetTime)
fmt.Printf("Example: %s %s %s\n", os.Args[0], exampleArabicaRPC, exampleArabicaTime)
fmt.Printf("Example: %s %s %s\n", os.Args[0], exampleMochaRPC, exampleMochaTime)
fmt.Printf("Example: %s %s %s\n", os.Args[0], exampleMainnetRPC, exampleMainnetTime)
return nil
}

Expand Down

0 comments on commit 4b34f8b

Please sign in to comment.