Skip to content

Commit

Permalink
rpc/client/user/http: httpConvert and logging fixes
Browse files Browse the repository at this point in the history
Deal with a nil *transactions.Transaction in a response from the
legacy HTTP REST server.

Also update some kwil-admin docs and logging.
charithabandi authored and jchappelow committed May 20, 2024
1 parent 553bb6f commit 04a2cfa
Showing 4 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/kwil-admin/cmds/setup/testnet.go
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ func testnetCmd() *cobra.Command {
cmd.Flags().BoolVar(&withGas, "gas", false, "enable gas")
cmd.Flags().Var(&allocs, "alloc", "account=amount pairs of genesis account allocations")
cmd.Flags().BoolVar(&snapshotsEnabled, "--snaps", false, "enables db snapshots")
cmd.Flags().Uint64Var(&maxSnapshots, "--max-snaps", 3, "Maximum number of snapshots to store in the device")
cmd.Flags().Uint64Var(&snapshotHeights, "--snap-heights", 10000, "Recurring heights(multipes of --snap-heights) to take snapshots at")
cmd.Flags().Uint64Var(&maxSnapshots, "--max-snaps", 3, "maximum number of snapshots to store in the device")
cmd.Flags().Uint64Var(&snapshotHeights, "--snap-heights", 10000, "recurring heights(multipes of --snap-heights) to take snapshots at")
return cmd
}
6 changes: 3 additions & 3 deletions cmd/kwil-admin/cmds/snapshot/create.go
Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@ import (

var (
createLongExplain = `
This command creates a logical snapshot of the database and genesis file to initialize a new network. The genesis file is created with the app_hash set to the hash of the snapshot(uncompressed) and the genesis validators set to the validators from the previous network. This command interacts directly with the underlying PostgreSQL server, bypassing any interactions with the kwild node. It requires user with administrative privileges on the database to create snapshot without any restrictions.
This command is intended to be used for network migrations to generate exportable snapshots used for initializing a new network, serving as the genesis state. The snapshots generated by this command are different from the ones generated by the snapshot store on running the Kwild instance. The snapshots generated by the snapshot store are used for state sync and are not meant to be used for initializing a new network as they contains state which shouldn't exist at genesis.`
This command creates a logical snapshot and prepares a genesis.json for a new network based on that snapshot. This command interacts directly with the underlying PostgreSQL server, bypassing any interactions with the kwild node. It requires a database user with superuser privileges.
The snapshots generated by kwild during normal operation are different from the snapshots generated by this tool. This tool is to prepare a new network based on the final state of an existing network, while kwild's snapshots support fast "state sync" for nodes joining an existing network.`

createExample = `# Create database snapshot and the genesis file to initialize a new network
# Password is optional if the db is operating in a trust authentication mode.
22 changes: 17 additions & 5 deletions cmd/kwil-admin/nodecfg/toml.go
Original file line number Diff line number Diff line change
@@ -159,12 +159,23 @@ hostname = "{{ .AppCfg.Hostname }}"
# Path to the snapshot file to restore the database from.
# Used during the network migration process.
snapshot_file = "{{ .AppCfg.SnapshotFile }}"
#######################################################################
### Extension Configuration ###
#######################################################################
[app.extensions]
# Oracle extensions can be enabled by adding the following configuration
# Each oracle extension configuration is defined under a subsection identified by the
# oracle extension name [app.extensions.<oracle_extension-name>]
# The configuration options for each oracle extension are defined as key-value pairs under the subsection.
# Only string values are supported for these configuration options.
# For example, to enable the Ethereum listener extension, the configuration would look like:
# [app.extensions.eth_listener]
# rpc_provider = "https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY"
# contract_address = "0xYOUR_CONTRACT_ADDRESS"
{{- range $extensionName, $configs := .AppCfg.Extensions }}
[app.extensions.{{$extensionName}}]
{{- range $key, $value := $configs }}
@@ -322,14 +333,15 @@ enable = {{ .ChainCfg.StateSync.Enable }}
snapshot_dir = "{{ .ChainCfg.StateSync.SnapshotDir }}"
# Trusted snapshot providers (comma-separated chain RPC servers) are the source-of-truth for the snapshot integrity.
# Snapshots are accepted for statesync only after verifying it with these trusted snapshot providers.
# Atleast 1 trusted rpc server is required for enabling state sync.
# Snapshots are accepted for statesync only after verifying the snapshot metadata (snapshot hash, chunk count, height etc.)
# with these trusted snapshot providers. At least 1 trusted snapshot provider is required for enabling state sync.
rpc_servers = "{{ .ChainCfg.StateSync.RPCServers }}"
# Time to spend discovering snapshots before offering the best(latest) snapshot to the application. (default: 60 seconds)
# If no snapshots are discovered within this time, the node will restart the discovery process and request snapshots from other peers.
# The node is forever in the discovery mode until it discovers a snapshot.
# Time spent discovering snapshots before offering the best(latest) snapshot to the application.
# If no snapshots are discovered, the node will redo the discovery process until snapshots are found.
# If network has no snapshots, restart the node with state sync disabled to sync with the network.
# Current default is 15s, as only snapshot metadata is requested in the discovery process.
# Adjust this value according to the network latencies of your peers.
discovery_time = "{{ .ChainCfg.StateSync.DiscoveryTime }}"
# The timeout duration before re-requesting a chunk, possibly from a different
4 changes: 4 additions & 0 deletions core/rpc/client/user/http/convert.go
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ func convertTx(tx *transactions.Transaction) *httpTx.TxTransaction {

// convertHttpTx converts a httpTx.TxTransaction to a transactions.Transaction
func convertHttpTx(tx *httpTx.TxTransaction) (*transactions.Transaction, error) {
if tx == nil {
return nil, nil
}

decodedSender, err := base64.StdEncoding.DecodeString(tx.Sender)
if err != nil {
return nil, err

0 comments on commit 04a2cfa

Please sign in to comment.