Skip to content

Commit

Permalink
fix: config of applyPool & queryPool (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeNinjaX authored Jan 17, 2024
1 parent 7b1dba6 commit de63da8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func NewArtela(
)

// set the runner cache capacity of aspect-runtime
aspecttypes.InitRuntimePool(cast.ToInt32(appOpts.Get(srvflags.AspectPoolSize)))
aspecttypes.InitRuntimePool(cast.ToInt32(appOpts.Get(srvflags.ApplyPoolSize)), cast.ToInt32(appOpts.Get(srvflags.QueryPoolSize)))

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
Expand Down
20 changes: 14 additions & 6 deletions ethereum/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ type EVMConfig struct {

// AspectConfig defines the application configuration values for Aspect.
type AspectConfig struct {
// PoolSize defines capacity of aspect runtime instance pool
PoolSize int32
// ApplyPoolSize defines capacity of aspect runtime instance pool for applying txs
ApplyPoolSize int32
// QueryPoolSize defines capacity of aspect runtime instance pool for querying txs
QueryPoolSize int32
}

// JSONRPCConfig defines configuration for the EVM RPC server.
Expand Down Expand Up @@ -291,14 +293,19 @@ func (c EVMConfig) Validate() error {
// DefaultAspectConfig returns the default Aspect configuration
func DefaultAspectConfig() *AspectConfig {
return &AspectConfig{
PoolSize: aspecttypes.DefaultAspectPoolSize,
ApplyPoolSize: aspecttypes.DefaultAspectPoolSize,
QueryPoolSize: aspecttypes.DefaultAspectPoolSize,
}
}

// Validate returns an error if the tracer type is invalid.
func (a AspectConfig) Validate() error {
if a.PoolSize < 0 {
return errors.New("Aspect pool-size cannot be negative")
if a.ApplyPoolSize < 0 {
return errors.New("Aspect apply-pool-size cannot be negative")
}

if a.QueryPoolSize < 0 {
return errors.New("Aspect query-pool-size cannot be negative")
}

return nil
Expand Down Expand Up @@ -452,7 +459,8 @@ func GetConfig(v *viper.Viper) (Config, error) {
KeyPath: v.GetString("tls.key-path"),
},
Aspect: AspectConfig{
PoolSize: v.GetInt32("aspect.pool-size"),
ApplyPoolSize: v.GetInt32("aspect.apply-pool-size"),
QueryPoolSize: v.GetInt32("aspect.query-pool-size"),
},
}, nil
}
Expand Down
3 changes: 2 additions & 1 deletion ethereum/server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ key-path = "{{ .TLS.KeyPath }}"
### Aspect Configuration ###
###############################################################################
[aspect]
pool-size = {{ .Aspect.PoolSize }}
apply-pool-size = {{ .Aspect.ApplyPoolSize }}
query-pool-size = {{ .Aspect.QueryPoolSize }}
`
3 changes: 2 additions & 1 deletion ethereum/server/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const (

// Aspect flags
const (
AspectPoolSize = "aspect.pool-size"
ApplyPoolSize = "aspect.apply-pool-size"
QueryPoolSize = "aspect.query-pool-size"
)

// TLS flags
Expand Down
3 changes: 2 additions & 1 deletion ethereum/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ is performed. Note, when enabled, gRPC will also be automatically enabled.
cmd.Flags().String(artelaflag.TLSCertPath, "", "the cert.pem file path for the server TLS configuration")
cmd.Flags().String(artelaflag.TLSKeyPath, "", "the key.pem file path for the server TLS configuration")

cmd.Flags().Uint64(artelaflag.AspectPoolSize, aspecttypes.DefaultAspectPoolSize, "the cache pool size for runtime instances of the aspect")
cmd.Flags().Uint64(artelaflag.ApplyPoolSize, aspecttypes.DefaultAspectPoolSize, "the cache pool size for runtime instances for applying message")
cmd.Flags().Uint64(artelaflag.QueryPoolSize, aspecttypes.DefaultAspectPoolSize, "the cache pool size for runtime instances for querying message")

// add support for all Tendermint-specific command line options
tcmd.AddNodeFlags(cmd)
Expand Down
2 changes: 0 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.artelad/config/app.toml
sed -i '' 's/127.0.0.1:8545/0.0.0.0:8545/g' $HOME/.artelad/config/app.toml
sed -i '' 's/allow-unprotected-txs = false/allow-unprotected-txs = true/g' $HOME/.artelad/config/app.toml
sed -i '' 's/pool-size = 0/pool-size = 10/g' $HOME/.artelad/config/app.toml

# set prunning options
sed -i '' 's/pruning = "default"/pruning = "custom"/g' $HOME/.artelad/config/app.toml
Expand All @@ -96,7 +95,6 @@ else
sed -i 's/enabled = false/enabled = true/g' $HOME/.artelad/config/app.toml
sed -i 's/127.0.0.1:8545/0.0.0.0:8545/g' $HOME/.artelad/config/app.toml
sed -i 's/allow-unprotected-txs = false/allow-unprotected-txs = true/g' $HOME/.artelad/config/app.toml
sed -i 's/pool-size = 0/pool-size = 10/g' $HOME/.artelad/config/app.toml

# set prunning options
sed -i 's/pruning = "default"/pruning = "custom"/g' $HOME/.artelad/config/app.toml
Expand Down

0 comments on commit de63da8

Please sign in to comment.