29 Commits

Author SHA1 Message Date
Julian Strobl
8bc221d476
[lib] Use AccountRetriever instead of calling API (#203)
This reduces complexity:

- Just use one endpoint
- No need for context.Context to be passed

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-28 10:58:53 +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
14f8749125
Synchronize sequence number across services and for offline mode (#199)
* [lib] Refactor `getClientContextAndTxFactory()`
So that we can pass the account number and sequence number from
outside.

* [lib] Add `BroadcastTxWithFileLock()`

This implements "offline mode" via RPC, but instead of keeping track of
the sequence numbers, we write them into a file and lock them. This way, we can synchronize multiple processes using the same address, trying to
send transactions simultaneously.

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

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

* [lib] Introduce variable for error
* [lib] Improve error handling in `broadcastTx()`
* Use `BroadcastTxWithFileLock()`
// See https://github.com/rddl-network/issues/issues/46

---------

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-27 16:11:07 +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
db5f4fb3fe
[lib] Switch from RPC (REST) to gRPC (#183)
* [lib] Add `SimulateTx()`

* [lib] Set `plmnt` as default bech32 account prefix

* [linter] Function should pass the context parameter (contextcheck)

// Closes #175

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-16 14:47:16 +01:00
Lorenz Herzberger
a5cea30e26
92 implement pop result handler (#101)
* ignite scaffold message report-pop-result challenge:Challenge --module dao

* add issuePoPRewards and fix typo

* add util validate struct and report pop test cases

* add TODOs

* replace depricated error

* fix broken import

* add error handler for failed pop issuance

* add placeholder for validator is issuer check

* added changed go.mod and go.sum

* generate docs

* reduce cognitive complexity

---------

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-11-16 12:44:56 +01:00
Julian Strobl
5bc0097ae3
Use RPC instead of exec.Command(...) (#176)
* Move `encoding.go` to lib to avoid import cycle

* [lib] Add `SetEncodingConfig` to avoid import cycle

```
package github.com/planetmint/planetmint-go/app
        imports github.com/planetmint/planetmint-go/app/ante
        imports github.com/planetmint/planetmint-go/x/dao
        imports github.com/planetmint/planetmint-go/util
        imports github.com/planetmint/planetmint-go/app: import cycle not allowed
```

* Use RPC instead of `exec.Command(...)`

// Closes #152

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-15 14:16:21 +01:00
Jürgen Eckel
a982abecf5
Distribute assets (#162)
* distributed & result msgs
* added DistributionResult
* added RDDL token conversion methods
* set proper validatoraddress within the testcases for e2e/dao
* set proper root dir for test cases
* fixed some wordings
---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-11-15 13:31:20 +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
7d65bff35f
Switch BlockHeight to int64 (#158)
To align with cosmos-sdk and make interoperability easier.

* Fix typo: blockheight -> blockHeight

* Generate protobuf and openapi

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-20 13:43:44 +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
e10416b23d
Use globally defined keyring backend from client.toml (#156)
This partially reverts commit 1927c4d47219c428e4d12cfd9015f0137af7a030.

// Closes #142

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-19 09:48:18 +02:00
Jürgen Eckel
1927c4d472
Eckelj/support keyring (#136)
* added keyring option
* added Reissuance workflow logging

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-11 16:02:37 +02:00
Jürgen Eckel
6e3d5ec394
improved error handling
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-10 02:14:05 +02:00
Jürgen Eckel
5adaab3b14
fixed linter issues
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-10 01:54:09 +02:00
Jürgen Eckel
a0d4a9a575
removed obsolete print commands
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-10 01:39:09 +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
a441ff87dd
added reissuance tests and fixed conversion
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-06 10:12:23 +02:00
Jürgen Eckel
f69c978911
added SendRDDLReissuanceResult sending by the proposer after the consensus over the ReissuanceProposal
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-05 17:49:59 +02:00
Jürgen Eckel
4ad86048a5
initial reissue rddl proposal message
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-05 15:02:36 +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
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
Jürgen Eckel
ea1e316852
adjusted signing to work with ext pub keys being commited within the cid notarization message
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-12 14:49:25 +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