Skip to content

Commit

Permalink
Merge branch 'gnolang:master' into auction
Browse files Browse the repository at this point in the history
  • Loading branch information
thinhnx-var committed Sep 10, 2024
2 parents 27735b4 + 68b8f54 commit 2d66134
Show file tree
Hide file tree
Showing 65 changed files with 3,617 additions and 1,043 deletions.
6 changes: 4 additions & 2 deletions contribs/gnodev/pkg/dev/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ func (n *Node) rebuildNode(ctx context.Context, genesis gnoland.GnoGenesisState)

// Setup node config
nodeConfig := newNodeConfig(n.config.TMConfig, n.config.ChainID, genesis)
nodeConfig.GenesisTxHandler = n.genesisTxHandler
nodeConfig.GenesisTxResultHandler = n.genesisTxResultHandler
// Speed up stdlib loading after first start (saves about 2-3 seconds on each reload).
nodeConfig.CacheStdlibLoad = true
nodeConfig.Genesis.ConsensusParams.Block.MaxGas = n.config.MaxGasPerBlock

// recoverFromError handles panics and converts them to errors.
Expand Down Expand Up @@ -512,7 +514,7 @@ func (n *Node) rebuildNode(ctx context.Context, genesis gnoland.GnoGenesisState)
return nil
}

func (n *Node) genesisTxHandler(ctx sdk.Context, tx std.Tx, res sdk.Result) {
func (n *Node) genesisTxResultHandler(ctx sdk.Context, tx std.Tx, res sdk.Result) {
if !res.IsErr() {
return
}
Expand Down
17 changes: 17 additions & 0 deletions docs/concepts/portal-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ has some drawbacks:
Gno will fail to be replayed, meaning **data will be lost**.
- Since transactions are archived and replayed during genesis,
block height & timestamp cannot be relied upon.

### Deploying to the Portal Loop

There are two ways to deploy code to the Portal Loop:

1. *automatic* - all packages in found in the `examples/gno.land/{p,r}/` directory in the [Gno monorepo](https://github.com/gnolang/gno) get added to the
new genesis each cycle,
2. *permissionless* - this includes replayed transactions with `addpkg`, and
new transactions you can issue with `gnokey maketx addpkg`.

Since the packages in `examples/gno.land/{p,r}` are deployed first,
permissionless deployments get superseded when packages with identical `pkgpath`
get merged into `examples/`.

The above mechanism is also how the `examples/` on the Portal Loop
get collaboratively iterated upon, which is its main mission.

77 changes: 77 additions & 0 deletions docs/getting-started/local-setup/creating-a-keypair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: creating-a-keypair
---

# Creating a Keypair

## Overview

In this tutorial, you will learn how to create your Gno keypair using
[`gnokey`](../../gno-tooling/cli/gnokey/gnokey.md).

Keypairs are the foundation of how users interact with blockchains; and Gno is
no exception. By using a 12-word or 24-word [mnemonic phrase](https://www.zimperium.com/glossary/mnemonic-seed/)
as a source of randomness, users can derive a private and a public key.
These two keys can then be used further; a public key derives an address which is
a unique identifier of a user on the blockchain, while a private key is used for
signing messages and transactions for the aforementioned address, proving a user
has ownership over it.

Let's see how we can use `gnokey` to generate a Gno keypair locally.

## Generating a keypair

The `gnokey add` command allows you to generate a new keypair locally. Simply
run the command, while adding a name for your keypair:

```bash
gnokey add MyKey
```

![gnokey-add-random](../../assets/getting-started/local-setup/creating-a-key-pair/gnokey-add-random.gif)

After running the command, `gnokey` will ask you to enter a password that will be
used to encrypt your keypair to the disk. Then, it will show you the following
information:
- Your public key, as well as the Gno address derived from it, starting with `g1...`,
- Your randomly generated 12-word mnemonic phrase which was used to derive the keypair.

:::warning Safeguard your mnemonic phrase!

A **mnemonic phrase** is like your master password; you can use it over and over
to derive the same keypairs. This is why it is crucial to store it in a safe,
offline place - writing the phrase on a piece of paper and hiding it is highly
recommended. **If it gets lost, it is unrecoverable.**

:::

`gnokey` will generate a keybase in which it will store information about your
keypairs. The keybase directory path is stored under the `-home` flag in `gnokey`.

### Gno addresses

Your **Gno address** is like your unique identifier on the network; an address
is visible in the caller stack of an application, it is included in each
transaction you create with your keypair, and anyone who knows your address can
send you [coins](../../concepts/stdlibs/coin.md), etc.

## Conclusion

That's it 🎉

You've successfully created your first Gno keypair. Check out
[Browsing gno.land](./browsing-gnoland.md) and
[Interacting with gno.land](./interacting-with-gnoland.md) to see how you can
use it.

If you wish to learn more about `gnokey` specifically, check out the
[gnokey section](../../gno-tooling/cli/gnokey/gnokey.md).









6 changes: 3 additions & 3 deletions docs/getting-started/local-setup/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ git clone https://github.com/gnolang/gno.git
There are three tools that should be used for getting started with Gno development:
- `gno` - the GnoVM binary
- `gnodev` - the Gno [development helper](../../gno-tooling/cli/gnodev.md)
- `gnokey` - the Gno [keypair manager](working-with-key-pairs.md)
- `gnokey` - the Gno [keypair manager](../../gno-tooling/cli/gnokey/working-with-key-pairs.md)

To install all three tools, simply run the following in the root of the repo:
```bash
Expand Down Expand Up @@ -87,7 +87,7 @@ You should get the following output:

`gnokey` is the gno.land keypair management CLI tool. It allows you to create
keypairs, sign transactions, and broadcast them to gno.land chains. Read more
about `gnokey` [here](../../gno-tooling/cli/gnokey.md).
about `gnokey` [here](../../gno-tooling/cli/gnokey/gnokey.md).

To verify that the `gnokey` binary is installed system-wide, you can run:

Expand All @@ -106,5 +106,5 @@ That's it 🎉
You have successfully built out and installed the necessary tools for Gno
development!

In further documents, you will gain a better understanding on how they are used
In further documents, you will gain a better understanding of how they are used
to make Gno work.
26 changes: 13 additions & 13 deletions docs/getting-started/local-setup/interacting-with-gnoland.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ You will understand how to use your keypair to send transactions to realms
and packages, send native coins, and more.

## Prerequisites

- **`gnokey` installed.** Reference the
[Local Setup](installation.md#3-installing-other-gno-tools) guide for steps
- **A keypair in `gnokey`.** Reference the
[Working with Key Pairs](working-with-key-pairs.md#adding-a-private-key-using-a-mnemonic) guide for steps
[Local Setup](installation.md) guide for steps
- **A keypair in `gnokey`.** Reference the [Creating a key pair](creating-a-keypair.md) guide for steps

## 1. Get testnet GNOTs
For interacting with any gno.land chain, you will need a certain amount of GNOTs
to pay gas fees with.

For this example, we will use the [Portal Loop](../../concepts/testnets.md#portal-loop)
testnet. We can access the Portal Loop faucet through the
[Gno Faucet Hub](https://faucet.gno.land), or by accessing the faucet directly at
[gno.land/faucet](https://gno.land/faucet).
[Gno Faucet Hub](https://faucet.gno.land).

![faucet-hub](../../assets/getting-started/local-setup/interacting-with-gnoland/faucet-hub.png)

Expand All @@ -35,7 +34,7 @@ After inputting your address and solving the captcha, you can check if you have
following `gnokey` command:

```bash
gnokey query bank/balances/<your_gno_address> --remote "https://rpc.gno.land:443"
gnokey query bank/balances/<your_gno_address> --remote "https://rpc.gno.land:443"
```

If the faucet request was successful, you should see something similar to the
Expand All @@ -48,15 +47,16 @@ data: "10000000ugnot"
```

## 2. Visit a realm

For this example, we will use the [Userbook realm](https://gno.land/r/demo/userbook).
The Userbook realm is a simple app that allows users to sign up, and keeps track
of when they signed up. It also displays the currently signed-up users and the block
height at which they have signed up.

![userbook-default](../../assets/getting-started/local-setup/interacting-with-gnoland/userbook-default.png)

> Note: block heights are not correct because of the way the Portal Loop testnet
> works.
> Note: block heights in this case are unreliable because of the way the Portal Loop
> network works.
> Read more [here](../../concepts/portal-loop.md).
To see what functions are available to call on the Userbook realm, click
Expand All @@ -67,7 +67,7 @@ the `[help]` button.
By choosing one of the two `gnokey` commands and inputting your address
(or keypair name) in the top bar, you will have a ready command to paste into your
terminal. For example, the following command will call the `SignUp` function with the
keypair `MyKeypair`:
keypair `MyKey`:

```
gnokey maketx call \
Expand All @@ -79,11 +79,11 @@ gnokey maketx call \
-broadcast \
-chainid "portal-loop" \
-remote "https://rpc.gno.land:443" \
MyKeypair
MyKey
```

To see what each option and flag in this command does, read the `gnokey`
[reference page](../../gno-tooling/cli/gnokey.md).
To see what each option and flag in this command does, check out `gnokey` in the
[tooling section](../../gno-tooling/cli/gnokey/gnokey.md).

## Conclusion

Expand All @@ -92,6 +92,6 @@ That's it! Congratulations on executing your first transaction on a Gno network!
If the previous transaction was successful, you should be able
to see your address on the main page of the Userbook realm.

This concludes the "Local Setup" tutorial. For next steps, see the
This concludes the "Local Setup" section. For next steps, see the
[How-to guides section](../../how-to-guides/how-to-guides.md), where you will
learn how to write your first realm, package, and much more.
2 changes: 1 addition & 1 deletion docs/gno-tooling/cli/faucet/faucet.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Gno faucet works by designating a single address as a faucet address that wi
Ensure the faucet account will have enough funds
by [premining its balance](../../../gno-infrastructure/premining-balances.md) to a high value.
In case you do not have an existing address added to `gnokey`, you can consult
the [Working with Key Pairs](../../../getting-started/local-setup/working-with-key-pairs.md) guide.
the [Working with Key Pairs](../gnokey/working-with-key-pairs.md) guide.

## 2. Start the local chain

Expand Down
Loading

0 comments on commit 2d66134

Please sign in to comment.