feature/1120 leverage service authorization (#1188)

* refactor: remove redundant branch trigger for scheduled releases

* refactor: simplify process-compose commands and improve logging

* refactor: remove redundant  command

* refactor: remove unused error variables and simplify database configuration

* feat: introduce task runner for project automation

* refactor: Remove hardcoded action and method from form components

* refactor: move server setup to main.go and add prometheus metrics

* refactor: move index handlers to render handlers

* refactor: improve user identification logic in gateway and vault handlers

* refactor: rename TitleDescription to TitleDesc for consistency

* feat: integrate go-useragent library for enhanced user agent parsing

* feat: enhance initial view rendering based on device type

* feat: Add support for PostgreSQL database

* fix: Use formatPsqlDSN() to properly set PostgreSQL DSN from command flags

* feat: Add PostgreSQL support with fallback to SQLite in NewGormDB

* feat: Add PostgreSQL connection validation with SQLite fallback

* chore: update golang.org/x/crypto dependency to v0.31.0

* feat: add PKL-based configuration initialization

* refactor: improve file naming consistency in cmd/sonrd

* refactor: Improve init-pkl command with safer config file generation and error handling

* fix: add logging for pkl evaluation results

* refactor: Move credential handling to gateway context

* refactor: Migrate session models to gateway package

* refactor: rename models and update User model

* chore: initial commit for address and pubkey functionality

* refactor: move pubkey package to keys package

* refactor: Rename models and add resolver service

* feat: add gRPC clients for bank, DID, DWN, and SVC modules

* refactor: Migrate title and description components from text package to hero package

* refactor: improve file naming conventions

* feat: add user credential validation

* refactor: rename registration handlers and routes for clarity

* <no value>

* refactor: Decouple database and IPFS interactions from server setup

* refactor: Migrate configuration from class-based to TOML-based structure

* refactor: move network configuration files to sonr.net module

* feature/1120-leverage-service-authorization

* fix: correct DID identifier creation function name

* feat: add compressed and uncompressed public keys to keyset

* refactor: move address packages to crypto/address

* feat: implement pubkey verification

* refactor: remove ECDSA-related functions from keyshare and protocol modules

* feat: Implement ECDSA signature serialization

* <no value>

* feat: add vault service for IPFS token storage

* refactor: update ucan codec to use new DID generation method

* refactor: refactor key management and move address parsers to keys package

* refactor: rename key parsers and move to parsers package

* fix: resolved import issues with the new spec

* feat: improve user onboarding experience by updating button text and functionality

* refactor: update point marshaling and unmarshaling methods to use JSON

* refactor: remove unnecessary DID method from PubKey

* refactor: Rename and refactor MPC key generation functions

* test: Add comprehensive test suite for keyshare generation and validation

* test: Fix keyshare role validation and encoding tests

* feat: Update key share role tests with enclave initialization validation

* test(mpc): refactor tests to focus on public API and remove internal role checks

* refactor: Remove unnecessary role check in initKeyEnclave function

* fix: Enforce strict order for validator and user keyshares in enclave initialization

* fix: Update codec_test to match latest codec implementation

* refactor: Update KeyEnclave to use string-based key shares and improve error handling

* fix: Refactor MPC enclave to use string-based encoding and simplify key management

* refactor: Remove redundant keyshare decoding tests in codec_test.go

* fix: Resolve type conversion issues in MPC crypto enclave initialization

* fix: Convert CID to byte slice in addEnclaveIPFS function

* fix: Resolve type conversion and constant definition errors in MPC crypto utils

* refactor: Simplify KeyShare encoding and role handling in MPC codec

* fix: Resolve JSON unmarshaling type mismatch in KeyShare.Message()

* fix: Refactor KeyEnclave to use struct and Enclave interface

* fix: Resolve type and naming conflicts in MPC crypto package

* refactor: Update codec_test.go to use new KeyEnclave struct fields

* refactor: remove keyshare encoding and decoding logic

* refactor: Remove unused JSON marshaling functions for curve points

* fix: Improve signature serialization and deserialization in MPC crypto

This commit addresses several issues with signature handling:
- Fixed signature length to 65 bytes
- Added proper padding for R and S values
- Added nil and zero value checks
- Improved error messages for signature parsing

The changes ensure more robust signature encoding and decoding, preventing potential nil pointer and invalid signature issues.

* fix: Update signature serialization to match protocol test approach

* refactor: Simplify KeyEnclave struct and improve message handling

* fix: Improve signature serialization and verification in MPC crypto module

* refactor: Simplify enclave validation using IsValid method in test

* refactor: Add marshaling and comprehensive tests for KeyEnclave

* feat: Add JSON marshaling support for Point in KeyEnclave

* refactor: Rename KeyEnclave to Enclave and update related functions

* refactor: Update PubKey verification to use SHA3-256 hashing

* test: Add comprehensive tests for DID and PubKey implementations

* refactor: simplify DID key retrieval

* test: refactor CI workflow and remove unused DIDAuth middleware

* The changes look good! The updated workflows will now:

1. Run tests on push to master
2. Bump the version if the commit doesn't already start with 'bump:'
3. Trigger a release workflow automatically with the new version tag
4. Create and publish the release

A few things to note:
- Make sure you have the `peter-evans/repository-dispatch` action installed/available
- The `commitizen-tools/commitizen-action` should output the new tag for this to work
- Ensure your release workflow can handle the repository dispatch event

Would you like me to review or suggest any additional modifications to the workflows?

* ci(github actions): add build stage dependency for tests

* fix(workflow): update workflow to trigger on PR edits

* test: Update unit test dependencies

* ci: Add GoReleaser dry-run check for merge group events

* test: remove unnecessary dependencies between test jobs

* ci: Make race and coverage tests depend on build tests
This commit is contained in:
Prad Nukala
2024-12-13 20:10:27 +00:00
committed by GitHub
parent ee12bf684e
commit ac8c153b28
132 changed files with 2879 additions and 3397 deletions
-89
View File
@@ -1,89 +0,0 @@
open module sonr.chain.App
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl"
class Chain {
`minimum-gas-prices`: String = "0stake"
`query-gas-limit`: String = "0"
pruning: String = "default"
`pruning-keep-recent`: String = "0"
`pruning-interval`: String = "0"
`halt-height`: Int = 0
`halt-time`: Int = 0
`min-retain-blocks`: Int = 0
`inter-block-cache`: Boolean = true
`index-events`: Listing<String> = new {}
`iavl-cache-size`: Int = 781250
`iavl-disable-fastnode`: Boolean = false
`app-db-backend`: String = ""
telemetry: Telemetry = new {}
api: Api = new {}
grpc: Grpc = new {}
`grpc-web`: GrpcWeb = new {}
`state-sync`: StateSync = new {}
streaming: Streaming = new {}
mempool: Mempool = new {}
}
class Telemetry {
`service-name`: String = ""
enabled: Boolean = true
`enable-hostname`: Boolean = false
`enable-hostname-label`: Boolean = false
`enable-service-label`: Boolean = false
`prometheus-retention-time`: Int = 60
`global-labels`: Listing<Listing<String>> = new {
new {
"chain_id"
"chain-NKlMbx"
}
}
`metrics-sink`: String = ""
`statsd-addr`: String = ""
`datadog-hostname`: String = ""
}
class Api {
enable: Boolean = true
swagger: Boolean = false
address: String = "tcp://0.0.0.0:1317"
`max-open-connections`: Int = 1000
`rpc-read-timeout`: Int = 10
`rpc-write-timeout`: Int = 0
`rpc-max-body-bytes`: Int = 1000000
`enabled-unsafe-cors`: Boolean = false
}
class Grpc {
enable: Boolean = true
address: String = "0.0.0.0:9090"
`max-recv-msg-size`: String = "10485760"
`max-send-msg-size`: String = "2147483647"
}
class GrpcWeb {
enable: Boolean = true
}
class StateSync {
`snapshot-interval`: Int = 0
`snapshot-keep-recent`: Int = 2
}
class Streaming {
abci: Abci = new {}
}
class Abci {
keys: Listing<String> = new {}
plugin: String = ""
`stop-node-on-err`: Boolean = true
}
class Mempool {
`max-txs`: Int = 5000
}
output {
renderer = new toml.Renderer {}
}
-154
View File
@@ -1,154 +0,0 @@
open module sonr.chain.Config
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl"
class Chain {
version: String = "0.38.5"
proxy_app: String = "tcp://127.0.0.1:26658"
moniker: String = "node0"
db_backend: String = "goleveldb"
db_dir: String = "data"
log_level: String = "info"
log_format: String = "plain"
genesis_file: String = "config/genesis.json"
priv_validator_key_file: String = "config/priv_validator_key.json"
priv_validator_state_file: String = "data/priv_validator_state.json"
priv_validator_laddr: String = ""
node_key_file: String = "config/node_key.json"
abci: String = "socket"
filter_peers: Boolean = false
rpc: Rpc = new {}
p2p: P2p = new {}
mempool: Mempool = new {}
statesync: StateSync = new {}
blocksync: BlockSync = new {}
consensus: Consensus = new {}
storage: Storage = new {}
tx_index: TxIndex = new {}
instrumentation: Instrumentation = new {}
}
class Rpc {
laddr: String = "tcp://0.0.0.0:26657"
cors_allowed_origins: Listing<String> = new {}
cors_allowed_methods: Listing<String> = new {
"HEAD"
"GET"
"POST"
}
cors_allowed_headers: Listing<String> = new {
"Origin"
"Accept"
"Content-Type"
"X-Requested-With"
"X-Server-Time"
}
grpc_laddr: String = ""
grpc_max_open_connections: Int = 900
unsafe: Boolean = false
max_open_connections: Int = 900
max_subscription_clients: Int = 100
max_subscriptions_per_client: Int = 5
experimental_subscription_buffer_size: Int = 200
experimental_websocket_write_buffer_size: Int = 200
experimental_close_on_slow_client: Boolean = false
timeout_broadcast_tx_commit: String = "10s"
max_body_bytes: Int = 1000000
max_header_bytes: Int = 1048576
tls_cert_file: String = ""
tls_key_file: String = ""
pprof_laddr: String = "localhost:6060"
}
class P2p {
laddr: String = "tcp://0.0.0.0:26656"
external_address: String = ""
seeds: String = ""
persistent_peers: String = read("env:SONR_PERSISTENT_PEERS") ?? ""
addr_book_file: String = "config/addrbook.json"
addr_book_strict: Boolean = true
max_num_inbound_peers: Int = 40
max_num_outbound_peers: Int = 10
unconditional_peer_ids: String = ""
persistent_peers_max_dial_period: String = "0s"
flush_throttle_timeout: String = "100ms"
max_packet_msg_payload_size: Int = 1024
send_rate: Int = 5120000
recv_rate: Int = 5120000
pex: Boolean = true
seed_mode: Boolean = false
private_peer_ids: String = ""
allow_duplicate_ip: Boolean = false
handshake_timeout: String = "20s"
dial_timeout: String = "3s"
}
class Mempool {
type: String = "flood"
recheck: Boolean = true
broadcast: Boolean = true
wal_dir: String = ""
size: Int = 5000
max_txs_bytes: Int = 1073741824
cache_size: Int = 10000
`keep-invalid-txs-in-cache`: Boolean = false
max_tx_bytes: Int = 1048576
max_batch_bytes: Int = 0
experimental_max_gossip_connections_to_persistent_peers: Int = 0
experimental_max_gossip_connections_to_non_persistent_peers: Int = 0
}
class StateSync {
enable: Boolean = false
rpc_servers: String = ""
trust_height: Int = 0
trust_hash: String = ""
trust_period: String = "168h0m0s"
discovery_time: String = "15s"
temp_dir: String = ""
chunk_request_timeout: String = "10s"
chunk_fetchers: String = "4"
}
class BlockSync {
version: String = "v0"
}
class Consensus {
wal_file: String = "data/cs.wal/wal"
timeout_propose: String = "3s"
timeout_propose_delta: String = "500ms"
timeout_prevote: String = "1s"
timeout_prevote_delta: String = "500ms"
timeout_precommit: String = "1s"
timeout_precommit_delta: String = "500ms"
timeout_commit: String = "5s"
double_sign_check_height: Int = 0
skip_timeout_commit: Boolean = false
create_empty_blocks: Boolean = true
create_empty_blocks_interval: String = "0s"
peer_gossip_sleep_duration: String = "100ms"
peer_query_maj23_sleep_duration: String = "2s"
}
class Storage {
discard_abci_responses: Boolean = false
}
class TxIndex {
indexer: String = "kv"
`psql-conn`: String = read("env:SONR_PSQL_CONN") ?? ""
}
class Instrumentation {
prometheus: Boolean = false
prometheus_listen_addr: String = ":26660"
max_open_connections: Int = 3
namespace: String = "cometbft"
}
output {
renderer = new toml.Renderer {}
}
-747
View File
@@ -1,747 +0,0 @@
open module sonr.chain.Genesis
app_name: String
app_version: String
genesis_time: String
chain_id: String
initial_height: Int
app_hash: Any
app_state: AppState
consensus: Consensus
class AppState {
`07-tendermint`: Any
auth: Auth
authz: Authz
bank: Bank
capability: Capability
circuit: Circuit
consensus: Any
crisis: Crisis
did: Did
distribution: Distribution
dwn: Dwn
evidence: Evidence
feegrant: Feegrant
feeibc: Feeibc
genutil: Genutil
globalfee: Globalfee
gov: Gov
group: Group
ibc: Ibc
interchainaccounts: Interchainaccounts
mint: Mint
nft: Nft
packetfowardmiddleware: Packetfowardmiddleware
params: Any
poa: Poa
slashing: Slashing
staking: Staking
svc: Svc
tokenfactory: Tokenfactory
transfer: Transfer
upgrade: Dynamic
vesting: Dynamic
}
class Auth {
params: Params
accounts: Listing
}
class Params {
max_memo_characters: String
tx_sig_limit: String
tx_size_cost_per_byte: String
sig_verify_cost_ed25519: String
sig_verify_cost_secp256k1: String
}
class AccountsItem1 {
`@type`: String
address: String
pub_key: Any
account_number: String
sequence: String
}
class Authz {
authorization: Listing<Any>
}
class Bank {
params: BankParams
balances: Listing
supply: Listing
denom_metadata: Listing<Any>
send_enabled: Listing<Any>
}
class BankParams {
send_enabled: Listing<Any>
default_send_enabled: Boolean
}
class BalancesItem1 {
address: String
coins: Listing
}
class ExpeditedMinDepositItem0 {
denom: String
amount: String
}
class Capability {
index: String
owners: Listing<Any>
}
class Circuit {
account_permissions: Listing<Any>
disabled_type_urls: Listing<Any>
}
class Crisis {
constant_fee: ExpeditedMinDepositItem0
}
class Did {
params: Dynamic
}
class Distribution {
params: DistributionParams
fee_pool: FeePool
delegator_withdraw_infos: Listing<Any>
previous_proposer: String
outstanding_rewards: Listing<Any>
validator_accumulated_commissions: Listing<Any>
validator_historical_rewards: Listing<Any>
validator_current_rewards: Listing<Any>
delegator_starting_infos: Listing<Any>
validator_slash_events: Listing<Any>
}
class DistributionParams {
community_tax: String
base_proposer_reward: String
bonus_proposer_reward: String
withdraw_addr_enabled: Boolean
}
class FeePool {
community_pool: Listing<Any>
}
class Dwn {
params: DwnParams
}
class DwnParams {
allowed_public_keys: Dynamic
conveyance_preference: String
attestation_formats: Listing
schema: Schema
allowed_operators: Listing
}
class Schema {
version: Int
account: String
asset: String
chain: String
credential: String
did: String
jwk: String
grant: String
keyshare: String
profile: String
}
class Evidence {
evidence: Listing<Any>
}
class Feegrant {
allowances: Listing<Any>
}
class Feeibc {
identified_fees: Listing<Any>
fee_enabled_channels: Listing<Any>
registered_payees: Listing<Any>
registered_counterparty_payees: Listing<Any>
forward_relayers: Listing<Any>
}
class Genutil {
gen_txs: Listing
}
class GenTxsItem0 {
body: Body
auth_info: AuthInfo
signatures: Listing
}
class Body {
messages: Listing
memo: String
timeout_height: String
extension_options: Listing<Any>
non_critical_extension_options: Listing<Any>
}
class MessagesItem0 {
`@type`: String
description: Description
commission: Commission
min_self_delegation: String
delegator_address: String
validator_address: String
pubkey: PublicKey
value: ExpeditedMinDepositItem0
}
class Description {
moniker: String
identity: String
website: String
security_contact: String
details: String
}
class Commission {
rate: String
max_rate: String
max_change_rate: String
}
class PublicKey {
`@type`: String
key: String
}
class AuthInfo {
signer_infos: Listing
fee: Fee
tip: Any
}
class SignerInfosItem0 {
public_key: PublicKey
mode_info: ModeInfo
sequence: String
}
class ModeInfo {
single: Single
}
class Single {
mode: String
}
class Fee {
amount: Listing<Any>
gas_limit: String
payer: String
granter: String
}
class Globalfee {
params: GlobalfeeParams
}
class GlobalfeeParams {
minimum_gas_prices: Listing
}
class MinimumGasPricesItem0 {
amount: String
denom: String
}
class Gov {
starting_proposal_id: String
deposits: Listing<Any>
votes: Listing<Any>
proposals: Listing<Any>
deposit_params: Any
voting_params: Any
tally_params: Any
params: GovParams
constitution: String
}
class GovParams {
min_deposit: Listing
max_deposit_period: String
voting_period: String
quorum: String
threshold: String
veto_threshold: String
min_initial_deposit_ratio: String
proposal_cancel_ratio: String
proposal_cancel_dest: String
expedited_voting_period: String
expedited_threshold: String
expedited_min_deposit: Listing
burn_vote_quorum: Boolean
burn_proposal_deposit_prevote: Boolean
burn_vote_veto: Boolean
min_deposit_ratio: String
}
class Group {
group_seq: String
groups: Listing<Any>
group_members: Listing<Any>
group_policy_seq: String
group_policies: Listing<Any>
proposal_seq: String
proposals: Listing<Any>
votes: Listing<Any>
}
class Ibc {
client_genesis: ClientGenesis
connection_genesis: ConnectionGenesis
channel_genesis: ChannelGenesis
}
class ClientGenesis {
clients: Listing<Any>
clients_consensus: Listing<Any>
clients_metadata: Listing<Any>
params: ClientGenesisParams
create_localhost: Boolean
next_client_sequence: String
}
class ClientGenesisParams {
allowed_clients: Listing
}
class ConnectionGenesis {
connections: Listing<Any>
client_connection_paths: Listing<Any>
next_connection_sequence: String
params: ConnectionGenesisParams
}
class ConnectionGenesisParams {
max_expected_time_per_block: String
}
class ChannelGenesis {
channels: Listing<Any>
acknowledgements: Listing<Any>
commitments: Listing<Any>
receipts: Listing<Any>
send_sequences: Listing<Any>
recv_sequences: Listing<Any>
ack_sequences: Listing<Any>
next_channel_sequence: String
params: ChannelGenesisParams
}
class ChannelGenesisParams {
upgrade_timeout: UpgradeTimeout
}
class UpgradeTimeout {
height: Height
timestamp: String
}
class Height {
revision_number: String
revision_height: String
}
class Interchainaccounts {
controller_genesis_state: ControllerGenesisState
host_genesis_state: HostGenesisState
}
class ControllerGenesisState {
active_channels: Listing<Any>
interchain_accounts: Listing<Any>
ports: Listing<Any>
params: ControllerGenesisStateParams
}
class ControllerGenesisStateParams {
controller_enabled: Boolean
}
class HostGenesisState {
active_channels: Listing<Any>
interchain_accounts: Listing<Any>
port: String
params: HostGenesisStateParams
}
class HostGenesisStateParams {
host_enabled: Boolean
allow_messages: Listing
}
class Mint {
minter: Minter
params: MintParams
}
class Minter {
inflation: String
annual_provisions: String
}
class MintParams {
mint_denom: String
inflation_rate_change: String
inflation_max: String
inflation_min: String
goal_bonded: String
blocks_per_year: String
}
class Nft {
classes: Listing<Any>
entries: Listing<Any>
}
class Packetfowardmiddleware {
params: PacketfowardmiddlewareParams
in_flight_packets: Dynamic
}
class PacketfowardmiddlewareParams {
fee_percentage: String
}
class Poa {
params: PoaParams
}
class PoaParams {
admins: Listing
allow_validator_self_exit: Boolean
}
class Slashing {
params: SlashingParams
signing_infos: Listing<Any>
missed_blocks: Listing<Any>
}
class SlashingParams {
signed_blocks_window: String
min_signed_per_window: String
downtime_jail_duration: String
slash_fraction_double_sign: String
slash_fraction_downtime: String
}
class Staking {
params: StakingParams
last_total_power: String
last_validator_powers: Listing<Any>
validators: Listing<Any>
delegations: Listing<Any>
unbonding_delegations: Listing<Any>
redelegations: Listing<Any>
exported: Boolean
}
class StakingParams {
unbonding_time: String
max_validators: Int
max_entries: Int
historical_entries: Int
bond_denom: String
min_commission_rate: String
}
class Svc {
params: SvcParams
}
class SvcParams {
categories: Any
types: Any
}
class Tokenfactory {
params: TokenfactoryParams
factory_denoms: Listing<Any>
}
class TokenfactoryParams {
denom_creation_fee: Listing<Any>
denom_creation_gas_consume: Int
}
class Transfer {
port_id: String
denom_traces: Listing<Any>
params: TransferParams
total_escrowed: Listing<Any>
}
class TransferParams {
send_enabled: Boolean
receive_enabled: Boolean
}
class Consensus {
params: ConsensusParams
}
class ConsensusParams {
block: Block
evidence: ParamsEvidence
validator: Validator
version: Version
abci: Abci
}
class Block {
max_bytes: String
max_gas: String
}
class ParamsEvidence {
max_age_num_blocks: String
max_age_duration: String
max_bytes: String
}
class Validator {
pub_key_types: Listing
}
class Version {
app: String
}
class Abci {
vote_extensions_enable_height: String
}
-22
View File
@@ -1,22 +0,0 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
/// Base configuration files for initializing a sonr chain
amends "../basePklProject.pkl"
package {
name = "sonr.chain"
version = "0.0.2"
}
-4
View File
@@ -1,4 +0,0 @@
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
@@ -1,18 +1,17 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/config/hway" }
open module sonr.conf.Hway
open module sonr.net.Hway
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
servePort: Int = 3000
configDir: String = "~/.config/hway"
sqliteFile: String = "hway.db"
chainId: String = "sonr-testnet-1"
ipfsGatewayUrl: String = "http://localhost:8080"
sonrApiUrl: String = "http://localhost:1317"
sonrGrpcUrl: String = "http://localhost:9090"
sonrRpcUrl: String = "http://localhost:26657"
psqlDSN: String
@@ -1,6 +1,6 @@
@go.Package { name = "github.com/onsonr/sonr/pkg/config/motr" }
module sonr.conf.Motr
module sonr.net.Motr
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
@@ -17,6 +17,6 @@
amends "../basePklProject.pkl"
package {
name = "sonr.conf"
name = "sonr.net"
version = "0.0.1"
}