Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for a ws client & batch processing over ws #1498

Merged
merged 32 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
306e96a
Start client cleanup
zivkovicmilos Jan 4, 2024
215af3f
Add support for batches in the WS client; standardize batch request c…
zivkovicmilos Jan 5, 2024
37d4650
Replicate batch processing for the ws server
zivkovicmilos Jan 5, 2024
9bda10b
Start chipping away at the WS client
zivkovicmilos Apr 8, 2024
8c8d967
Add initial unit tests for ws client request parsing
zivkovicmilos Apr 9, 2024
615b963
Add additional unit tests for ws client request parsing
zivkovicmilos Apr 9, 2024
6c872ed
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 9, 2024
437eb50
Add unit tests for the http client
zivkovicmilos Apr 9, 2024
0c05470
Clean up batch functionality
zivkovicmilos Apr 9, 2024
61141c7
Drop utils
zivkovicmilos Apr 11, 2024
1a418b9
Clean up rpc/client
zivkovicmilos Apr 12, 2024
e2febd9
Implement RPC batch support
zivkovicmilos Apr 12, 2024
86f76dc
Start adding E2E client test cases
zivkovicmilos Apr 12, 2024
fc4f1d7
Add unit tests for the RPC batch
zivkovicmilos Apr 14, 2024
5de0bea
Add E2E RPC client tests
zivkovicmilos Apr 15, 2024
8977f83
Clean up rpctypes tests
zivkovicmilos Apr 15, 2024
4b6f5c2
Resolve codebase linting errors
zivkovicmilos Apr 15, 2024
8de8cf0
Move gnofaucet as a separate module
zivkovicmilos Apr 16, 2024
756e9c6
Minor tidy
zivkovicmilos Apr 16, 2024
ad14469
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 16, 2024
ac718e3
Update workflows and Dockerfile for gnofaucet
zivkovicmilos Apr 16, 2024
1a05f59
Update Dockerfile
zivkovicmilos Apr 16, 2024
4042c8f
Remove gnofaucet from the Docker build workflow
zivkovicmilos Apr 16, 2024
194a3f5
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 18, 2024
4a5eaf2
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 19, 2024
6602ba2
Remove leftover Dockerfile changes
zivkovicmilos Apr 19, 2024
ca5a3fc
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 22, 2024
5ca5fef
Merge branch 'master' into feat/add-ws-client
zivkovicmilos Apr 26, 2024
84260a3
Simplify parseRemoteAddr
zivkovicmilos Apr 26, 2024
cff8577
Move code out of the default switch
zivkovicmilos Apr 26, 2024
d710fea
Handle internal context for request adding
zivkovicmilos Apr 26, 2024
133376e
Utilize context causes for propagating errors
zivkovicmilos Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
Expand All @@ -49,7 +49,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: [gnoland-slim, gnokey-slim, gno-slim, gnofaucet-slim, gnoweb-slim]
target: [ gnoland-slim, gnokey-slim, gno-slim, gnofaucet-slim, gnoweb-slim ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -71,7 +71,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/how-to-guides/connecting-from-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ A few things to note:
You can initialize the RPC Client used to connect to the Gno.land network with
the following line:
```go
rpc := rpcclient.NewHTTP("<gno_chain_endpoint>", "")
rpc := rpcclient.NewHTTP("<gno_chain_endpoint>")
```

A list of Gno.land network endpoints & chain IDs can be found in the [Gno RPC
Expand Down Expand Up @@ -138,7 +138,7 @@ func main() {
}

// Initialize the RPC client
rpc := rpcclient.NewHTTP("<gno.land_remote_endpoint>", "")
rpc := rpcclient.NewHTTP("<gno.land_remote_endpoint>")

// Initialize the gnoclient
client := gnoclient.Client{
Expand Down
6 changes: 3 additions & 3 deletions gno.land/pkg/gnoclient/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Example_withDisk() {
}

remote := "127.0.0.1:26657"
rpcClient := rpcclient.NewHTTP(remote, "/websocket")
rpcClient, _ := rpcclient.NewHTTPClient(remote)

client := gnoclient.Client{
Signer: signer,
Expand All @@ -35,7 +35,7 @@ func Example_withInMemCrypto() {
signer, _ := gnoclient.SignerFromBip39(mnemo, chainID, bip39Passphrase, account, index)

remote := "127.0.0.1:26657"
rpcClient := rpcclient.NewHTTP(remote, "/websocket")
rpcClient, _ := rpcclient.NewHTTPClient(remote)

client := gnoclient.Client{
Signer: signer,
Expand All @@ -47,7 +47,7 @@ func Example_withInMemCrypto() {
// Example_readOnly demonstrates how to initialize a read-only gnoclient, which can only query.
func Example_readOnly() {
remote := "127.0.0.1:26657"
rpcClient := rpcclient.NewHTTP(remote, "/websocket")
rpcClient, _ := rpcclient.NewHTTPClient(remote)

client := gnoclient.Client{
RPCClient: rpcClient,
Expand Down
28 changes: 18 additions & 10 deletions gno.land/pkg/gnoclient/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func TestCallSingle_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -68,7 +69,8 @@ func TestCallMultiple_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -119,7 +121,8 @@ func TestSendSingle_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -167,7 +170,8 @@ func TestSendMultiple_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -223,7 +227,8 @@ func TestRunSingle_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

client := Client{
Signer: signer,
Expand Down Expand Up @@ -281,7 +286,8 @@ func TestRunMultiple_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

client := Client{
Signer: signer,
Expand Down Expand Up @@ -361,7 +367,8 @@ func TestAddPackageSingle_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -404,7 +411,7 @@ func Echo(str string) string {
}

// Execute AddPackage
_, err := client.AddPackage(baseCfg, msg)
_, err = client.AddPackage(baseCfg, msg)
assert.Nil(t, err)

// Check for deployed file on the node
Expand All @@ -429,7 +436,8 @@ func TestAddPackageMultiple_Integration(t *testing.T) {

// Init Signer & RPCClient
signer := newInMemorySigner(t, "tendermint_test")
rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket")
rpcClient, err := rpcclient.NewHTTPClient(remoteAddr)
require.NoError(t, err)

// Setup Client
client := Client{
Expand Down Expand Up @@ -495,7 +503,7 @@ func Hello(str string) string {
}

// Execute AddPackage
_, err := client.AddPackage(baseCfg, msg1, msg2)
_, err = client.AddPackage(baseCfg, msg1, msg2)
assert.Nil(t, err)

// Check Package #1
Expand Down
6 changes: 5 additions & 1 deletion gno.land/pkg/gnoweb/gnoweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@
// Prove: false, XXX
}
remote := cfg.RemoteAddr
cli := client.NewHTTP(remote, "/websocket")
cli, err := client.NewHTTPClient(remote)
if err != nil {
return nil, fmt.Errorf("unable to create HTTP client, %w", err)

Check warning on line 426 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L426

Added line #L426 was not covered by tests
}

qres, err := cli.ABCIQueryWithOptions(
qpath, data, opts2)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion gnovm/pkg/gnomod/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ func queryChain(remote string, qpath string, data []byte) (res *abci.ResponseQue
// Height: height, XXX
// Prove: false, XXX
}
cli := client.NewHTTP(remote, "/websocket")
cli, err := client.NewHTTPClient(remote)
if err != nil {
return nil, err
}

qres, err := cli.ABCIQueryWithOptions(qpath, data, opts2)
if err != nil {
return nil, err
Expand Down
16 changes: 7 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
dario.cat/mergo v1.0.0
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/cockroachdb/apd/v3 v3.2.1
github.com/cosmos/ledger-cosmos-go v0.13.3
Expand All @@ -26,6 +27,7 @@ require (
github.com/pmezard/go-difflib v1.0.0
github.com/rogpeppe/go-internal v1.12.0
github.com/rs/cors v1.10.1
github.com/rs/xid v1.5.0
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
go.etcd.io/bbolt v1.3.9
Expand All @@ -49,29 +51,25 @@ require (

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
)

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/gdamore/encoding v1.0.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading