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

[release-v0.7] sync with main #593

Merged
merged 18 commits into from
Mar 11, 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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
testGroupID=$(id -g)
cp test/acceptance/docker-compose.override.yml.example test/acceptance/docker-compose.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/acceptance/docker-compose.override.yml
KACT_LOG_LEVEL=warn task test:act:nb -- -parallel-mode -parallel 1
KACT_LOG_LEVEL=warn task test:act:nb

- name: Run integration test
# without kgw test, probably should disable this ?
Expand All @@ -167,7 +167,7 @@ jobs:
testGroupID=$(id -g)
cp test/integration/docker-compose.override.yml.example test/integration/docker-compose.override.yml
sed -i "s/\${UID}:\${GID}/${testUserID}:${testGroupID}/g" test/integration/docker-compose.override.yml
KIT_LOG_LEVEL=warn task test:it:nb -- -parallel-mode -parallel 1
KIT_LOG_LEVEL=warn task test:it:nb

- name: Move cache
run: |
Expand All @@ -177,3 +177,7 @@ jobs:
- name: Prune Docker
if: ${{ always() }}
run: docker rm $(docker ps -a -q) -f ; docker network prune -f ; docker volume prune -f || true

- name: Show error log
if: ${{ failure() }}
run: grep -C 20 -s -i -r -e 'kwild version' -e 'error' -e 'warn' /tmp/TestKwilAct*/*.log /tmp/TestKwilInt*/*.log /tmp/TestKwilInt*/*/*.log
12 changes: 1 addition & 11 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,5 @@ checksum:
name_template: 'checksums.txt'

release:
prerelease: auto
github:
owner: kwilteam
name: kwil-cli
draft: true
replace_existing_draft: true
ids:
- kwil-cli
- kwild
- kwil-admin

universal_binaries:
- replace: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ configuration changes. Start it by running the following from the

```sh
cd deployments/compose/kwil
docker compose up -d
docker compose up --build -d
```

With the `-d` option, the service(s) will be started as background processes. To
Expand Down
13 changes: 3 additions & 10 deletions cmd/kwil-admin/nodecfg/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ var (
genesisValidatorGas, _ = big.NewInt(0).SetString("10000000000000000000000", 10)
)

type EthDepositOracle struct {
Enabled bool
Endpoint string
EscrowAddress string
RequiredConfirmations string
}

type NodeGenerateConfig struct {
ChainID string
BlockInterval time.Duration
Expand Down Expand Up @@ -177,7 +170,7 @@ func GenerateNodeFiles(outputDir string, originalCfg *config.KwildConfig, silenc
}

cfg.AppCfg.PrivateKeyPath = config.PrivateKeyFileName
err = writeConfigFile(filepath.Join(rootDir, config.ConfigFileName), cfg)
err = WriteConfigFile(filepath.Join(rootDir, config.ConfigFileName), cfg)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -350,7 +343,7 @@ func GenerateTestnetConfig(genCfg *TestnetGenerateConfig, opts *ConfigOpts) erro

cfg.AppCfg.PrivateKeyPath = config.PrivateKeyFileName // not abs/rooted because this might be run in a container

// oracle config
// extension config
if i < genCfg.NValidators {
if genCfg.Extensions != nil {
if len(genCfg.Extensions) != genCfg.NValidators {
Expand All @@ -362,7 +355,7 @@ func GenerateTestnetConfig(genCfg *TestnetGenerateConfig, opts *ConfigOpts) erro
}
}

writeConfigFile(filepath.Join(nodeDir, config.ConfigFileName), cfg)
WriteConfigFile(filepath.Join(nodeDir, config.ConfigFileName), cfg)
}

fmt.Printf("Successfully initialized %d node directories: %s\n",
Expand Down
17 changes: 8 additions & 9 deletions cmd/kwil-admin/nodecfg/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func arrayFormatter(items []string) string {
return "[" + strings.Join(formattedStrings, ", ") + "]"
}

// writeConfigFile writes the config to a file.
func writeConfigFile(configFilePath string, cfg *config.KwildConfig) error {
// WriteConfigFile writes the config to a file.
func WriteConfigFile(configFilePath string, cfg *config.KwildConfig) error {
var buffer bytes.Buffer

if err := configTemplate.Execute(&buffer, cfg); err != nil {
Expand All @@ -47,15 +47,12 @@ func writeConfigFile(configFilePath string, cfg *config.KwildConfig) error {
}

const defaultConfigTemplate = `
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml

# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or
# relative to the home directory (e.g. "data")

# Root Directory Structure:
# RootDir/
# |- config.toml (app and chain configuration for running the kwild node)
# |- config.toml (app and chain configuration for running the kwild node)
# |- private_key (node's private key)
# |- abci/
# | |- config/
Expand All @@ -64,7 +61,6 @@ const defaultConfigTemplate = `
# | |- data/
# | | |- blockchain db files/dir (blockstore.db, state.db, etc)
# | |- info/
# |- application/wal
# |- signing/

# Only the config.toml and genesis file are required to run the kwild node
Expand All @@ -74,6 +70,7 @@ const defaultConfigTemplate = `
### Logging Config Options ###
#######################################################################
[log]

# Output level for logging, default is "info". Other options are "debug", "error", "warn", "trace"
level = "{{ .Logging.Level }}"

Expand All @@ -89,8 +86,8 @@ time_format = "{{ .Logging.TimeEncoding }}"
#######################################################################
### App Config Options ###
#######################################################################

[app]

# Node's Private key
private_key_path = "{{ .AppCfg.PrivateKeyPath }}"

Expand Down Expand Up @@ -141,8 +138,10 @@ hostname = "{{ .AppCfg.Hostname }}"


#######################################################################
### Extension Configuration ###
### Extension Configuration ###
#######################################################################
[app.extensions]

{{- range $extensionName, $configs := .AppCfg.Extensions }}
[app.extensions.{{$extensionName}}]
{{- range $key, $value := $configs }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kwil-admin/nodecfg/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Test_Generate_TOML(t *testing.T) {
cfg.AppCfg.GrpcListenAddress = "localhost:9000"
cfg.AppCfg.ExtensionEndpoints = []string{"localhost:9001", "localhost:9002"}
cfg.Logging.OutputPaths = []string{"stdout", "file"}
err := writeConfigFile("test.toml", cfg)
err := WriteConfigFile("test.toml", cfg)
assert.NoError(t, err)
defer os.Remove("test.toml")

Expand Down
32 changes: 22 additions & 10 deletions cmd/kwild/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ func defaultMoniker() string {
// 2. Config file
// 3. Env vars
// 4. Command line flags
// It takes one argument, which is the config generated from the command line flags.
func GetCfg(flagCfg *KwildConfig) (*KwildConfig, error) {
// It takes the config generated from the command line flags to override default.
// It also takes a flag to indicate if the caller wants to modify the defaults
// for "quickstart" mode. Presently this just makes the HTTP RPC service listen
// on all interfaces instead of the default of localhost.
func GetCfg(flagCfg *KwildConfig, quickStart bool) (*KwildConfig, bool, error) {
/*
the process here is:
1. identify the root dir. This requires reading in the env and command line flags
Expand All @@ -265,10 +268,17 @@ func GetCfg(flagCfg *KwildConfig) (*KwildConfig, error) {
cfg := DefaultConfig()
rootDir := cfg.RootDir

// If doing a quickstart (autogen mode in caller), change the default HTTP
// listen address to use all interfaces. We do this here so that the user
// can still override it if they want.
if quickStart {
cfg.AppCfg.HTTPListenAddress = "0.0.0.0:8080"
}

// read in env config
envCfg, err := LoadEnvConfig()
if err != nil {
return nil, fmt.Errorf("failed to load env config: %w", err)
return nil, false, fmt.Errorf("failed to load env config: %w", err)
}
if envCfg.RootDir != "" {
rootDir = envCfg.RootDir
Expand All @@ -281,42 +291,44 @@ func GetCfg(flagCfg *KwildConfig) (*KwildConfig, error) {
// expand the root dir
rootDir, err = ExpandPath(rootDir)
if err != nil {
return nil, fmt.Errorf("failed to expand root directory \"%v\": %v", rootDir, err)
return nil, false, fmt.Errorf("failed to expand root directory \"%v\": %v", rootDir, err)
}

fmt.Printf("Root directory \"%v\"\n", rootDir)

// make sure the root dir exists
err = os.MkdirAll(rootDir, 0755)
if err != nil {
return nil, fmt.Errorf("failed to create root directory \"%v\": %v", rootDir, err)
return nil, false, fmt.Errorf("failed to create root directory \"%v\": %v", rootDir, err)
}

// 2. Read in the config file
// read in config file and merge into default config
var configFileExists bool
fileCfg, err := LoadConfigFile(filepath.Join(rootDir, ConfigFileName))
if err == nil {
configFileExists = true
// merge in config file
err2 := cfg.Merge(fileCfg)
if err2 != nil {
return nil, fmt.Errorf("failed to merge config file: %w", err2)
return nil, false, fmt.Errorf("failed to merge config file: %w", err2)
}
} else if err != ErrConfigFileNotFound {
return nil, fmt.Errorf("failed to load config file: %w", err)
return nil, false, fmt.Errorf("failed to load config file: %w", err)
}

// 3. Merge in the env config
// merge in env config
err = cfg.Merge(envCfg)
if err != nil {
return nil, fmt.Errorf("failed to merge env config: %w", err)
return nil, false, fmt.Errorf("failed to merge env config: %w", err)
}

// 4. Merge in the flag config
// merge in flag config
err = cfg.Merge(flagCfg)
if err != nil {
return nil, fmt.Errorf("failed to merge flag config: %w", err)
return nil, false, fmt.Errorf("failed to merge flag config: %w", err)
}

cfg.RootDir = rootDir
Expand All @@ -327,7 +339,7 @@ func GetCfg(flagCfg *KwildConfig) (*KwildConfig, error) {
cfg.ChainCfg.Moniker = defaultMoniker()
}

return cfg, nil
return cfg, configFileExists, nil
}

// LoadConfig reads a config.toml at the given path and returns a KwilConfig.
Expand Down
13 changes: 6 additions & 7 deletions cmd/kwild/config/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@
grpc_listen_addr = "localhost:50051"

# TCP address for the KWILD App's HTTP server to listen on
http_listen_addr = "localhost:8080"
http_listen_addr = "0.0.0.0:8080"

# UNIX socket for KWILD Admin server to listen on
admin_unix_socket = "/tmp/kwil_admin.sock"

# List of Extension endpoints to be enabled ex: ["localhost:50052", "169.198.102.34:50053"]
extension_endpoints = []

# Toggle to enable gas costs for transactions and queries
without_gas_costs = true

# Toggle to disable nonces for transactions and queries
without_nonces = false

# PostgreSQL database host (UNIX socket path or IP address with no port)
pg_db_host = "127.0.0.1"

Expand Down Expand Up @@ -81,6 +75,11 @@ tls_key_file = ""
# Kwild Server hostname
hostname = ""

#######################################################################
### Extension Configuration ###
#######################################################################
[app.extensions]

#######################################################################
### Snapshot store Config Options ###
#######################################################################
Expand Down
6 changes: 0 additions & 6 deletions cmd/kwild/config/test_data/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ http_listen_addr = "localhost:8080"
# List of Extension endpoints to be enabled ex: ["localhost:50052", "169.198.102.34:50053"]
extension_endpoints = ["localhost:50052", "localhost:50053", "localhost:50054"]

# Toggle to enable gas costs for transactions and queries
without_gas_costs = true

# Toggle to disable nonces for transactions and queries
without_nonces = false

# PostgreSQL database host (UNIX socket path or IP address with no port)
pg_db_host = "127.0.0.1"

Expand Down
Loading
Loading