Skip to content
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

chore: add iavl as params #37

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/datagen/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
babylonPathFlag = "babylon-path"
totalDelegationsFlag = "total-delegations"
numPubRandFlag = "num-public-randomness"
iavlDisabledFastnode = "iavl-disabled-fastnode"
iavlCacheSize = "iavl-cache-size"
)

// CommandGenerate generates data
Expand All @@ -32,6 +34,8 @@ func CommandGenerate() *cobra.Command {
f.Int(totalDelegationsFlag, 0, "Number of delegations to run this cmd, after it we will exit. (optional, 0 for indefinite)")
f.Int(totalStakersFlag, 100, "Number of stakers to run (optional)")
f.Uint32(numPubRandFlag, 150_000, "Number of pub randomness to commit, should be a high value (optional)")
f.Bool(iavlDisabledFastnode, true, "IAVL disabled fast node (additional fast node cache) (optional)")
f.Uint(iavlCacheSize, 0, "IAVL cache size, note cache too big can cause OOM, 100k -> ~20 GB of RAM (optional)")

return cmd
}
Expand Down Expand Up @@ -63,12 +67,24 @@ func cmdGenerate(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("failed to read flag %s: %w", numPubRandFlag, err)
}

iavlCache, err := flags.GetUint(iavlCacheSize)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", iavlCacheSize, err)
}

disabledFastnode, err := flags.GetBool(iavlDisabledFastnode)
if err != nil {
return fmt.Errorf("failed to read flag %s: %w", iavlDisabledFastnode, err)
}

cfg := config.Config{
NumPubRand: numPubRand,
TotalStakers: totalStakers,
TotalFinalityProviders: totalFps,
TotalDelegations: totalDelegations,
BabylonPath: babylonPath,
IavlCacheSize: iavlCache,
IavlDisableFastnode: disabledFastnode,
}

if err := cfg.Validate(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type Config struct {
TotalFinalityProviders int
TotalDelegations int
BabylonPath string
IavlDisableFastnode bool
IavlCacheSize uint
}

func (c *Config) Validate() error {
Expand Down
21 changes: 14 additions & 7 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func (m *Manager) RunBabylondResource(
baseHeaderHex string,
slashingPkScript string,
epochInterval uint,
iavlDisableFastnode bool,
iavlCacheSize uint,
) (*dockertest.Resource, *dockertest.Resource, error) {
network, err := m.pool.Client.CreateNetwork(docker.CreateNetworkOptions{
Name: "babylon",
Expand All @@ -224,11 +226,14 @@ func (m *Manager) RunBabylondResource(
"--covenant-quorum=1 --covenant-pks=%s "+
"--min-signed-per-window=0 && "+ // never jail sluggish fps
"chmod -R 777 /home && "+
"sed -i -e 's/iavl-cache-size = 0/iavl-cache-size = 100000/' /home/node0/babylond/config/app.toml && "+ // disable the cache otherwise we go OOM
//"sed -i -e 's/iavl-disable-fastnode = false/iavl-disable-fastnode = true/' /home/node0/babylond/config/app.toml && "+
"sed -i -e 's/iavl-cache-size = 0/iavl-cache-size = %d/' /home/node0/babylond/config/app.toml && "+
"sed -i -e 's/iavl-disable-fastnode = true/iavl-disable-fastnode = %s/' /home/node0/babylond/config/app.toml && "+
`sed -i -e 's/timeout_commit = "5s"/timeout_commit = "2s"/' /home/node0/babylond/config/config.toml &&`+
"babylond start --home=/home/node0/babylond --rpc.pprof_laddr=0.0.0.0:6060",
epochInterval, slashingPkScript, baseHeaderHex, bbn.NewBIP340PubKeyFromBTCPK(CovenantPubKey).MarshalHex()),
epochInterval, slashingPkScript, baseHeaderHex,
bbn.NewBIP340PubKeyFromBTCPK(CovenantPubKey).MarshalHex(),
iavlCacheSize,
fmt.Sprintf("%t", iavlDisableFastnode)),
}

resourceFirstNode, err := m.pool.RunWithOptions(
Expand Down Expand Up @@ -278,11 +283,13 @@ func (m *Manager) RunBabylondResource(

cmd2 := []string{
"sh", "-c", fmt.Sprintf(
"chmod -R 777 /home && ls -la &&" +
"sed -i -e 's/iavl-cache-size = 0/iavl-cache-size = 100000/' /home/node1/babylond/config/app.toml && " + // disable the cache otherwise we go OOM
//"sed -i -e 's/iavl-disable-fastnode = false/iavl-disable-fastnode = true/' /home/node1/babylond/config/app.toml && " +
`sed -i -e 's/timeout_commit = "5s"/timeout_commit = "2s"/' /home/node1/babylond/config/config.toml &&` +
"chmod -R 777 /home && ls -la &&"+
"sed -i -e 's/iavl-cache-size = 0/iavl-cache-size = %d/' /home/node1/babylond/config/app.toml && "+
"sed -i -e 's/iavl-disable-fastnode = true/iavl-disable-fastnode = %s/' /home/node1/babylond/config/app.toml && "+
`sed -i -e 's/timeout_commit = "5s"/timeout_commit = "2s"/' /home/node1/babylond/config/config.toml &&`+
"babylond start --home=/home/node1/babylond --rpc.pprof_laddr=0.0.0.0:6060",
iavlCacheSize,
fmt.Sprintf("%t", iavlDisableFastnode),
),
}

Expand Down
9 changes: 8 additions & 1 deletion harness/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ func StartManager(ctx context.Context, outputsInWallet uint32, epochInterval uin
babylonDir = runCfg.BabylonPath // override with cfg
}

babylond, babylondNode1, err := manager.RunBabylondResource(babylonDir, baseHeaderHex, hex.EncodeToString(pkScript), epochInterval)
babylond, babylondNode1, err := manager.RunBabylondResource(
babylonDir,
baseHeaderHex,
hex.EncodeToString(pkScript),
epochInterval,
runCfg.IavlDisableFastnode,
runCfg.IavlCacheSize,
)
if err != nil {
return nil, err
}
Expand Down