21 Commits

Author SHA1 Message Date
Lorenz Herzberger
2a5b7c49c8
447 add validatoraddress getter to config (#449)
* feat: add GetValidatorAddress() to config
* feat: add GetDefaultValidatorRecord() to libConfig
---------

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2024-10-02 13:52:26 +02:00
Lorenz Herzberger
e404fef08b
Add occ signing to lib (#441)
* feat: add trustwallet signing to lib
* feat: add osc message sender to lib
* docs: update README
---------

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2024-09-19 16:20:24 +02:00
Lorenz Herzberger
5e2b307a70
368 make attestmachine msgtx with fee=zero (#372)
* no fee deduction in case of machineattestation messages
* no gas price for machineattestations in lib/tx
* test: add balance check to machine attestation e2e test

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2024-04-22 13:07:40 +02:00
Jürgen Eckel
1e1e19bb19
added more sync objects to avoid accidential data races (#345)
* Added more sync objects to avoid accidental data races
* made lib.config.Config variables are private, so they cannot be tampered with (multithreading).
Please introduce Get-methods to retrieve the varialbes outside of the package if you need it.
This way, the race conditions and unexpected change of the global object state can be protected
* added reverse takedown of the validators to avoid the following error
 [app] PoP broadcast tx failed: node0.info: key not found
* moved util.TerminationWaitGroup.Wait()
to the central network cleanup method
* removed mappings for private variables


Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-03-11 11:11:56 +01:00
Jürgen Eckel
31b304f232
added TermintionWaitGroup (#336)
* added TermintionWaitGroup
* added mutex to lib/tx
* removed machine attestation thread (to comply with testing-race conditions becoming apparent on the CI)
* renamed test suites to have a clear naming structure
* removed parallel-testing from e2e machine test suite
* improved test suite logging
* removed parallel tests of machine_nft_tests - this caused data races due to the mock overwrites
* reduced error check to "out of gas" due to multi-threading and locking  delays that result in different gas consumptions
* Added waiting blocks to pass the CI

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-03-06 10:52:22 +01:00
Jürgen Eckel
373614e1b2
269 set a chain wide upper gas limit for transactions (#309)
* set global tx gas limit
* extend lib/tx to process multiple messages
* extend lib/tx to configure tx gas limit
* added global gas limit tests
* increased account funding to support needs of testcases

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-02-01 10:23:38 +01:00
Julian Strobl
23648927c3
feat: put sequence files into sub-directory (#308)
- aligns the folder structure in `planetmint-go/`
- makes sequence number clean up via systemd possible

// see https://github.com/rddl-network/issues/issues/61

* refactor: open sequence file into function
* refactor: get sequence number into utils

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-30 12:13:05 +01:00
Julian Strobl
ae161f11e5
refactor: let lib set client context's address and name (#261)
* fix: make a real copy of bytes.Buffer

* refactor: rename `address` for maximum clarity in lib

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-08 16:04:42 +01:00
Julian Strobl
99031fb857
lib: add initial e2e tests (#255)
* fix: only increase counter if broadcast was successful

Otherwise we will get account and sequence numbers mismatches.

* test: add initial e2e tests for `lib/`

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-03 13:08:13 +01:00
Julian Strobl
f957f540a1
Refactor lib (#254)
* refactor: remove unwanted function in `lib`

The `lib` shall always be used with file lock.

* refactor: log `txResponse` in `buildSignBroadcastTx`

- Move `GetTxResponseFromOut` from `testutil` to `lib`

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-03 10:41:09 +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
df8ece2a30
Fix TestReissuance() E2E test (#214)
* [lib] Add fee denominator parameter

* [lib] Add client context parameter

e.g. the test cases create their own client context.

* [lib] Reset client context's output

Otherwise if the client context does not change, output gets appended
and gets un-parsable.

* [test] Set missing validator client context values

Necessary for sending transactions.

* [test] Configure RPC library

* [test] Fix `TestReissuance()`

// Closes #195

* Partially revert "[lib] Provide default encoding config (#209)"

This reverts commit 8a8a3aaaf2648f87c4052575bc1a60b23056463b.

Fix README example.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-12-07 09:57:33 +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
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
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
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
Julian Strobl
e36eb6c2a1
Add golangci-lint run to lib/ (#181)
* [lib] Add .golangci.yaml as symlink

https://github.com/golang/go/wiki/Modules#faqs--multi-module-repositories

* [golangci-lint] Change `nakedret` settings

* [linter] Can be replaced with faster hex.EncodeToString (perfsprint)

* [linter] Fix too many quotes

* [ci] Add `golangci-lint run` of `lib/`

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-16 09:16: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
Julian Strobl
1ca7faec60
Library for RPC requests to Planetmint (#173)
* [lib] Add initial version

// See #152

* [lib] Add initial README.md

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-14 15:04:46 +01:00