76 Commits

Author SHA1 Message Date
Julian Strobl
cb230f1615
refactor: cli queries (#288)
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-18 12:06:21 +01:00
Julian Strobl
ee4089f847
Remove planetmint-go from API endpoints (#287)
* feat: let the ci check if there are malformed api endpoints

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-16 10:39:32 +01:00
Julian Strobl
25649be550
fix: remove check from machine attestation request (#264)
`k.isNFTCreationRequest(msg.Machine)` was removed as it became obsolete
and we are not issuing generic tokens from within the machine
attestation process.

Closes #242

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-09 10:25:50 +01:00
Julian Strobl
4599bc2c78
refactor: improve logging (#257)
* refactor: improve logging

- Introduce logger tags
- Log variable contents
- Fix testing logger to support string formatting

* refactor: set logging context

And move logging into function.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-04 12:50:34 +01:00
Julian Strobl
036ce7cbc1
Enable sequence file locking in tests (#236)
* [lib] Add `FeeGranter` to tx factory
* [lib] Align return value with test cases
* [test] Return error on tx response
* [test] Switch to sequence file locking via libRPC
* [test] Reintegrate `TestPoPResult`

Closes #234


Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-12-18 15:47:44 +01:00
Julian Strobl
ede70b073b
Replace call to external python program (#215)
* Split asset registry endpoint

Into scheme, domain and path. We need the domain in the liquid contract.

* Switch to pure Go implementation

This is a reimplementation of the `issue2liquid.py`.

See https://github.com/rddl-network/issuer_service

// Closes #196

* Move elements RPC URL into config

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-12-11 15:53:58 +01:00
Jürgen Eckel
ff6aab33df
Fix error throwing bug that lead to block creation inconsistencies (#212)
* removed error throwing within the AttestMachine method
* add more extensive logging around that call

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-12-06 11:20:37 +01:00
Lorenz Herzberger
94830df5fc
184 implement staged claim (#190)
* adjust issuePoPRewards to mint stagedCRDDL
* add GetChallengeRange
* add resolveStagedClaims on ReissueRDDLResult msg
* move claim resolve to distribution result
* add StagedDenom and ClaimDenom to config
* added the prepare4linting.sh script
* renamed PoPEpochs to PopEpochs
* renamed DistributionAddressPoP to DistributionAddressPop
* added config value ReIssuanceEpochs
* detached the re-issuance from the distribution process and schedule them independently
* changed logging messages
* added an explicit util/kv_serialize.go file to have all KV serialization done
* switched to Bigendian serialization of int64 to have the ordered list on the kvstore
* added ComputeReIssuanceValue to enable re-issuances once a day or defined by ReIssuanceEpoch
* integrated a ReIssuanceValue computation test case
* adjusted the challenges test cases to be epoch-dependent
* added ReIssuances per ReIssuanceEpoch
* extended the Reissue message
* checking ReIssuanceProposal in the ante handler
* added precision setter for the UINT to RDDL token converter (and test cases)
* add e2e test case for pop rewards


Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-12-05 10:51:06 +01:00
Jürgen Eckel
6ad235e847 Improve RPC command issuance (#206)
* removed error handling from util/issue_command.go methods
* integrated the complete error handling with context into util/issue_command.go: buildSignBroadcastTx
* setting the chainID of lib/tx dynamically
* removed obsolete timeout
* removed obsolete TODO message
* improved logging information and clarity of information
* improved readability and debugability of BroadcastTxWithFileLock
* fixed getClientContext bug for chains different from the testnet by removing a hard-coded value
* renamed setConfig to setRPCConfig

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-11-29 08:11:49 +01:00
Julian Strobl
f18d4542e2
Merge release_0_5 branch (#202)
* Fix liuqid notarization (#191)

* Fix liuqid notarization - 2nd part (#193)

* fixed missing unmarshaling
* fixed message formatting issue

* fixed config parsing issue (#194)

* [util] Supply fees

But only where we want to see the transaction succeed. The other ones we
let in a broken state.

* Added logger a logger struct to log with a TAG (#198)

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
Co-authored-by: Jürgen Eckel <eckelj@users.noreply.github.com>
2023-11-28 10:22:39 +01:00
Julian Strobl
ec6bd1f755
[lib] Use build and broadcast tx from cosmos-sdk (#189)
* [tests] Avoid potential data races

* Revert "[lib] Switch from RPC (REST) to gRPC (#183)"

This reverts commit db5f4fb3fe6899bcfdadf3471f826a6a97035440.

* [lib] DRY: Use build and broadcast tx from cosmos-sdk

This is in preparation for: https://github.com/rddl-network/issues/issues/46

Without this patch broadcasting a transaction in "offline mode" (setting
the sequence number manually) would not work consistently. Every so
often the endpoint would report back, that it got an unexpected sequence
number. Executing the request with the same sequence number couple of
seconds later would be successful.

I decided to better use the same source code, that the CLI uses, because
I know that offline mode works there.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-22 15:03:36 +01:00
Julian Strobl
5b25d4cefc
Improve linter setup (#186)
* [linter] Add `musttag`

Enforce field tags in (un)marshaled structs.

* [linter] Add `nestif`

Reports deeply nested if statements.

* [linter] Add `noctx`

Finds sending http request without context.Context.

* [linter] Add `paralleltest`

Paralleltest detects missing usage of t.Parallel() method in your Go
test.

* [linter] Add `tagalign`

Check that struct tags are well aligned.

* [linter] Add `tagliatelle`

Checks the struct tags.

* [linter] Add `whitespace`

Tool for detection of leading and trailing whitespace.

* [paralleltest] Exclude files bc of data race in tests

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-17 10:56:25 +01:00
Julian Strobl
5470fc668b
Improve linter setup (#185)
* [linter] Remove unused exclusions

Linter `nosnakecase` was removed in 1e1138d0268a9896a1bd058e9b65b808eb20666e.

* [linter] Add tool for code clone detection

* [linter] Add `errorlint`

Find code that will cause problems with the error wrapping scheme
introduced in Go 1.13.

* [linter] Add `exhaustive`

Check exhaustiveness of enum switch statements.

* [linter] Add `forcetypeassert`

Finds type assertions which did forcely such as below:
```
func f() {
	var a interface{}
	_ = a.(int) // type assertion must be checked
}
```

* [linter] Add `gocritic`

Provides diagnostics that check for bugs, performance and style issues.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-16 17:44:38 +01:00
Julian Strobl
1e1138d026
Switch to revive and fix findings (#171)
* [ci] Switch from `nosnakecase` to `revive`

* [revive] Fix findings

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-13 12:42:52 +01:00
Julian Strobl
6472d7693f
[ci] Add nosnakecase to golangci-lint (#161)
Golang uses:

- Camel Case for variable names, e.g. `firstName`
- Camel Case for private function names, e.g. `getFirstName`
- Pascal Case for public function names, e.g. `GetFirstName`

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-20 14:09:07 +02:00
Julian Strobl
45504f4670
Replace fmt.PrintX calls by proper logging (#159)
// Closes #137

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-20 12:57:42 +02:00
Julian Strobl
6aaa5399ef
Remove /planetmint-go from API paths (#157)
* Remove `/planetmint-go` from API paths

* Generate protobuf and openapi

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-19 10:39:23 +02:00
Julian Strobl
283eeb7c9a
Fix broken API paths (#154)
* Fix broken API paths

Partially revert d4eed021c8b16210e82dbaa7687fc671b6ea5a90

* Generate protobuf and openapi

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-18 08:48:33 +02:00
Jürgen Eckel
c6909a3e4a
hotfix: inconsistent logging of block-proposer results on the chain. … (#153)
* hotfix: inconsistent logging of block-proposer results on the chain. These results need to be consensed via an explicit message instead of an error output.

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-17 11:49:54 +02:00
Jürgen Eckel
b4ddc44044
* integrated ante-handler
* added two new config variables: reissuance-asset and validator-address

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-10 01:24:28 +02:00
Jürgen Eckel
f11f66e14f
112 direct call to issue2liquid (#121)
* removed IssueResponseHandler
* added asset-registration endpoint config
* added methods to locally issue the asset and register it
* added issue_service directory configuration
* removed obsolete configuration options
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-05 12:38:35 +02:00
Lorenz Herzberger
20af6d2c46
move IsValidatorBlockProposer to util and add to issueMachineNFT (#118)
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-10-03 17:33:16 +02:00
Lorenz Herzberger
4db2fbc43f
add sentinel errors for machine module (#116)
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-10-03 13:23:56 +02:00
Lorenz Herzberger
e80ce7e894
remove duplicate validation (#102)
* remove duplicate validation
* add e2e test for antehandler checks on invalid machine attestation requests
* added comment
* adjusted openapi docs

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-29 09:09:27 +02:00
Jürgen Eckel
8fd9f213f3
77 rename asset hash to asset cid (#97)
* initial asset notarization restructuring
* adjusted test cases, two are still failing
* removed obsolete data structures

---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-27 16:35:31 +02:00
Lorenz Herzberger
e22d590bf8
removed println
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-25 16:44:13 +02:00
Lorenz Herzberger
86a85913cf
add GetMachineByAddress capabilities
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-25 16:42:26 +02:00
Julian Strobl
d4eed021c8
[go.mod] Switch module to github.com (#86)
This is the quasi-standard and fixes the error below:

```
$ go get -u github.com/planetmint/planetmint-go@v0.1.0
go: github.com/planetmint/planetmint-go@v0.1.0: parsing go.mod:
        module declares its path as: planetmint-go
                but was required as: github.com/planetmint/planetmint-go
```

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-09-21 17:37:57 +02:00
Jürgen Eckel
b215f7a5db
Trust Anchor state query (#85)
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-21 14:02:32 +02:00
Lorenz Herzberger
56ad4822d8
Add custom ante handler (#76)
* add initial custom ante handler
* implement CheckMachineDecorator.AnteHandle
* add machine error code
* add TA check to antehandler
* change machine error codes

---------

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-20 16:27:16 +02:00
Jürgen Eckel
2a09f9d90d
fixed missing return value check
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-20 16:03:57 +02:00
Jürgen Eckel
cb9f762675
Eckelj/fix store resolve issues (#79)
* added upper and lower case TA resolution testing

* added more detailed error reporting to the ValidateSignature method.
* extended test cases to test and verify these errs and their differences

* fixed CID attestation issue. CIDs are send in web compatible encoding that is not hex encoded and can be utilized without any further decoding on the server side.

* added checks and error handling for the Ta store object storage/loading

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-15 10:10:04 +02:00
Lorenz Herzberger
311a3596c2
replace byte cast with hex.DecodeString()
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-07 10:09:06 +02:00
Jürgen Eckel
120d3fdd9d
fixed signing (tests) and signing verification of the machine ID Signature
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-06 15:41:39 +02:00
Lorenz Herzberger
e33452476f
adjust test suite for ta validation
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-06 15:13:06 +02:00
Lorenz Herzberger
b1f572ddee
update machine message
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-06 11:41:54 +02:00
Lorenz Herzberger
6d7158d124
add trust anchor check to attest machine and fix test cases
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-06 11:26:26 +02:00
Lorenz Herzberger
307dfd1e12
fix staticcheck error
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 21:43:22 +02:00
Lorenz Herzberger
4bb3e694a5
add secp256k1 public key validation
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 21:41:18 +02:00
Lorenz Herzberger
b0d4ffad7a
add unit test for msg_server_register_trust_anchor
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 19:51:06 +02:00
Lorenz Herzberger
688f13e171
add update trust anchor test case
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 17:36:30 +02:00
Lorenz Herzberger
7d78e0f9b8
add test for trust anchor store
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 17:28:39 +02:00
Lorenz Herzberger
7ada150ae0
remove circular dependency
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 16:03:46 +02:00
Lorenz Herzberger
9f1ef39fec
ignite scaffold message register-trust-anchor trust-anchor:TrustAnchor --module machine
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 15:36:26 +02:00
Lorenz Herzberger
51dfde22e1
add trust anchor type to machine module
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2023-09-05 14:19:59 +02:00
Jürgen Eckel
5763bd6a7c
Eckelj/adding machine types (#67)
* added machine-type definition and checks
* fixed staticcheck issues

---------
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-08-31 10:04:07 +02:00
Julian Strobl
3fe9c018cd
Introduce Liquid network parameters (#64)
Up to know we just use the Bitcoin mainnet parameters
`chaincfg.MainNetParams` for Liquid. That's okay, because we use them
for creating and verifying extended private and public keys. Those only
depend on `HDPrivateKeyID` and `HDPublicKeyID`, which are the same for
Bitcoin and Liquid networks.

The only real difference is the `HDCoinType` used for key derivation,
which we want to use in the future. So it is a good idea to introduce
this value now.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-08-11 12:05:58 +02:00
Julian Strobl
1383d0aaa6
Add extended public key as IssuerPlanetmint (#62)
* Fix package and domain name

Signed-off-by: Julian Strobl <jmastr@mailbox.org>

* Add extended public key as `IssuerPlanetmint`

This patch introduces parts of the `chaincfg` for Planetmint and
especially the magic bytes that produces extended keys with the prefix
`pmpr` for a Planetmint extended private key and `pmpb` for a Planetmint
extended public key.

// Closes https://github.com/rddl-network/issues/issues/30

Signed-off-by: Julian Strobl <jmastr@mailbox.org>

* Validate Planetmint extended public key during machine attestation

Signed-off-by: Julian Strobl <jmastr@mailbox.org>

* [lint] Fix error return value is not checked

Signed-off-by: Julian Strobl <jmastr@mailbox.org>

---------

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-08-11 09:14:52 +02:00
Jürgen Eckel
01ef2dbfd0
Improve communication to liquid issuance service (#58)
* added OSC response listener with logging

added Machine NFT issuance for each machine attestation process
added CID and Planetmint Issuer extPublicKey to the issuance process
removed type inconsistency

* added machine NFT creation criteria

* [toml] Parsing does not allow sub-structs

* made OSC listener port configurable

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
Co-authored-by: Julian Strobl <jmastr@mailbox.org>
2023-08-04 16:38:18 +02:00
Julian Strobl
4ba12f7b03
[config] Add planetmint section to app.toml
This patch extends `app.toml` and adds the following section with these
default values:

```
[planetmint]
watchmen-endpoint = "localhost"
watchmen-port = 7401
```

A global singleton `plmntConfig` is introduced to save and access the
values similar to how cosmos does it (see
vendor/github.com/cosmos/cosmos-sdk/types/config.go).

Different environments can be managed by changing the values in
`app.toml` and restarting the daemon.

// Closes #53

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-08-04 10:53:38 +02:00