Skip to content

Commit

Permalink
allowing BTC Block and L2 Keystone generation rates to be configurabl…
Browse files Browse the repository at this point in the history
…e in local network

when running your local network via docker-compose, you can set the following env variables to configure the rates at which BTC Blocks and L2 Keystones are generated, respectively.

* HEMI_LOCAL_BTC_RATE_SECONDS
* HEMI_LOCAL_L2K_RATE_SECONDS
  • Loading branch information
ClaytonNorthey92 committed Mar 1, 2024
1 parent 7875a89 commit 7ed86b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 3 additions & 2 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
deploy:
restart_policy:
condition: any
delay: 5s
delay: "${HEMI_LOCAL_BTC_RATE_SECONDS:-5}s"
depends_on:
- bitcoind

Expand Down Expand Up @@ -74,7 +74,7 @@ services:
context: ./..
environment:
BFG_POSTGRES_URI: postgres://postgres@postgres:5432/bfg?sslmode=disable
BFG_BTC_START_HEIGHT: "100"
BFG_BTC_START_HEIGHT: "1"
BFG_EXBTC_ADDRESS: electrumx:50001
BFG_LOG_LEVEL: TRACE
BFG_PUBLIC_ADDRESS: ":8383"
Expand Down Expand Up @@ -115,6 +115,7 @@ services:
context: ./..
environment:
MOCKTIMISM_BSS_URL: http://bssd:8081/v1/ws
MOCKTIMISM_L2K_RATE_SECONDS: ${HEMI_LOCAL_L2K_RATE_SECONDS}
depends_on:
- bssd

18 changes: 17 additions & 1 deletion e2e/mocktimism/mocktimism.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package main

import (
"context"
"fmt"
"os"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -89,7 +91,7 @@ func main() {
l2Keystone.L1BlockNumber++
l2Keystone.L2BlockNumber++

time.Sleep(1 * time.Second)
time.Sleep(time.Duration(l2BlockCreationSeconds()) * time.Second)

err = bssapi.Write(ctx, bws.conn, "someotherid", bssapi.PopPayoutsRequest{
L2BlockForPayout: firstL2Keystone[:],
Expand Down Expand Up @@ -122,3 +124,17 @@ func fillOutBytes(prefix string, size int) []byte {

return result
}

func l2BlockCreationSeconds() int {
v := os.Getenv("MOCKTIMISM_L2K_RATE_SECONDS")
if v == "" {
return 1
}

i, err := strconv.Atoi(v)
if err != nil {
panic(fmt.Sprintf("invalid value for seconds: %s", v))
}

return i
}

0 comments on commit 7ed86b5

Please sign in to comment.