-
Notifications
You must be signed in to change notification settings - Fork 39
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
docs: Using agd to make queries and transactions #901
Conversation
Deploying with Cloudflare Pages
|
|
||
Options include: | ||
|
||
- Use the [basic dapp local chain](../getting-started/#starting-a-local-agoric-blockchain) docker container: to run `agd status`, enter `yarn docker:bash` followed by `agd status`; or use `docker-compose exec agd agd status`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for me, yarn docker:bash
gave some errors, I had to run yarn start:docker
first for it to work. Likely because some time passed, or my laptop restarted since I went through Your First Agoric Dapp
section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You folks might've already thought about this but would it be possible to create a separate repo that contains all of the docker compose stuff and make all other Dapp sample repos include/reference the same docker compose repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for me, yarn
docker:bash
gave some errors, I had to runyarn start:docker
first for it to work.
Were the errors / diagnostics straightforward to understand? You evidently figured out how to proceed. It's not practical to make yarn docker:bash
work without yarn start:docker
first, but if the diagnostics aren't clear, we could perhaps address that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re separate repo: it's worth considering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re errors / diagnostics, I was getting a pretty generic error
Error: post failed: Post "http://localhost:26657": dial tcp 127.0.0.1:26657: connect: connection refused
And I figured it out by backtracking my way through Your First Agoric Dapp
section and run the docker related command preceding yarn docker:bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you got that error in response to yarn docker:bash
? that seems unlikely. Perhaps in response to agd status
? That's possible, but it would mean you have agd
available outside the container.
Example: | ||
|
||
```console | ||
$ agd status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion
Pipe the output to jq
for readability? I tested in the docker container and it does have jq
installed already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting that we inform our readers about the jq
technique?
Or that the output currently in the docs is less readable than it should be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm suggesting we inform our readers about the jq
technique, because the output of this command is a json blob without any formatting or whitespaces in between.
The query goes to a local node at `tcp://localhost:26657` by default. To use another node: | ||
|
||
```console | ||
$ agd status --node https://devnet.rpc.agoric.net:443 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like once is enough to teach the technique.
::: tip Port is required | ||
|
||
Typically, `:443` can be left implicit in `https` URLs. | ||
But not here. Without it, we get: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my own curiosity
Why is it? Was it because we need to specify port 443 for gRPC to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why cosmos SDK requires it. I just know that it does.
@JimLarson ? @michaelfig ? Do you know? Should we open an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling for the --node $rpcUri
option is client, err := NewClientFromNode(rpcURI)
, where NewClientFromNode(nodeURI string)
returns rpchttp.New(nodeURI, "/websocket")
and rpchttp
is now cometbft rpc/client/http/http.go but was formerly tendermint rpc/client/http/http.go. Both use url.Parse to parse the input string into a parsedUrl
struct "u" and return an http.Client with a Transport whose Dial function is implemented to return net.Dial(protocol, u.GetDialAddress())
[CometBFT, Tendermint], where GetDialAddress()
for a URL destination [as opposed to the path of a Unix domain socket] returns the parsed Host
(causing failure in the absence of a port because net.Dial is low-level and requires that).
Bottom line, this could easily be fixed by updating func (u parsedURL) GetDialAddress()
to pay attention to URL Scheme, e.g.
// GetDialAddress returns the endpoint to dial for the parsed URL.
func (u parsedURL) GetDialAddress() string {
- // if it's not a unix socket we return the host, example: localhost:443
+ // if it's not a unix socket we return the host with port, example: localhost:443
if !u.isUnixSocket {
+ hasPort, err := regexp.MatchString(`:[0-9]+$`, u.Host)
+ if err == nil && !hasPort {
+ if u.Scheme == protoHTTP || u.Scheme == protoWS {
+ return u.Host + `:80`
+ } else if u.Scheme == protoHTTPS || u.scheme == protoWSS {
+ return u.Host + `:443`
+ }
+ }
return u.Host
}
// otherwise we return the path of the unix socket, ex /tmp/socket
return u.GetHostWithPath()
}
I think it makes sense to report upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing that since they're using the URL format, they don't want to mess with the assumption that 80 is the implicit port number. Since they don't want to squat on the webserver's favorite port, it would make sense to pick a different standard port number, then make it explicit in the node argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: cometbft no longer requires an explicit port for http/https or ws/wss URLs.
- tip: Formatting with jq
rendered:
dc-agd-query-tx
branch