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

feat: remove traces of account number from the account object #3213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 4 additions & 6 deletions contribs/gnofaucet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ go 1.22
toolchain go1.22.4

require (
github.com/gnolang/faucet v0.3.2
github.com/gnolang/gno v0.1.0-nightly.20240627
github.com/stretchr/testify v1.9.0
github.com/gnolang/faucet v0.4.0
github.com/gnolang/gno v0.0.0-20241127025539-d8589b06b14c
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/time v0.5.0
)

replace github.com/gnolang/gno => ../..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be kept.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replace was originally removed, not sure when it was added back in 🙁

The gnofaucet cannot have a replace, because gnolang/faucet (imported by gnofaucet) imports gnolang/gno, and it's going to cause a build error since the API changed in this version of gnolang/gno -- we want gnofaucet to use an old version of gnolang/gno

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking gnolang/faucet should be moved into the monorepo or gnofaucet out of it; in any case fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it in the monorepo.


require (
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.6 // indirect
Expand Down Expand Up @@ -46,7 +44,7 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions contribs/gnofaucet/go.sum

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

17 changes: 8 additions & 9 deletions docs/gno-tooling/cli/gnokey/full-security-tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ id: full-security-tx
## Overview

`gnokey` provides a way to create a transaction, sign it, and later
broadcast it to a chain in the most secure fashion. This approach, while more
broadcast it to a chain in the most secure fashion. This approach, while more
complicated than the standard approach shown [in a previous tutorial](./state-changing-calls.md),
grants full control and provides [airgap](https://en.wikipedia.org/wiki/Air_gap_(networking))
support.
support.

By separating the signing and the broadcasting steps of submitting a transaction,
users can make sure that the signing happens in a secure, offline environment,
keeping private keys away from possible exposure to attacks coming from the
keeping private keys away from possible exposure to attacks coming from the
internet.

The intended purpose of this functionality is to provide maximum security when
The intended purpose of this functionality is to provide maximum security when
signing and broadcasting a transaction. In practice, this procedure should take
place on two separate machines controlled by the holder of the keys, one with
access to the internet (`Machine A`), and the other one without (`Machine B`),
with the separation of steps as follows:

1. `Machine A`: Fetch account information from the chain
2. `Machine B`: Create an unsigned transaction locally
3. `Machine B`: Sign the transaction
Expand All @@ -41,7 +42,7 @@ using the [auth/accounts](./querying-a-network.md#authaccounts) query:
gnokey query auth/accounts/<your_address> -remote "https://rpc.gno.land:443"
```

We need to extract the account number and sequence from the output:
We need to extract the sequence from the output:

```bash
height: 0
Expand All @@ -50,13 +51,12 @@ data: {
"address": "g1zzqd6phlfx0a809vhmykg5c6m44ap9756s7cjj",
"coins": "10000000ugnot",
"public_key": null,
"account_number": "468",
"sequence": "0"
}
}
```

In this case, the account number is `468`, and the sequence (nonce) is `0`. We
In this case, the sequence (nonce) is `0`. We
will need these values to sign the transaction later. These pieces of information
are crucial during the signing process, as they are included in the signature
of the transaction, preventing replay attacks.
Expand All @@ -82,16 +82,15 @@ Now we are ready to sign the transaction.

To add a signature to the transaction, we can use the `gnokey sign` subcommand.
To sign, we must set the correct flags for the subcommand:

- `-tx-path` - path to the transaction file to sign, in our case, `userbook.tx`
- `-chainid` - id of the chain to sign for
- `-account-number` - number of the account fetched previously
- `-account-sequence` - sequence of the account fetched previously

```bash
gnokey sign \
-tx-path userbook.tx \
-chainid "portal-loop" \
-account-number 468 \
-account-sequence 0 \
mykey
```
Expand Down
2 changes: 0 additions & 2 deletions docs/gno-tooling/cli/gnokey/querying-a-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ data: {
"@type": "/tm.PubKeySecp256k1",
"value": "A+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2y"
},
"account_number": "0",
"sequence": "12"
}
}
Expand All @@ -67,7 +66,6 @@ to hold account data. It contains the following information:
- `address` - the address of the account
- `coins` - the list of coins the account owns
- `public_key` - the TM2 public key of the account, from which the address is derived
- `account_number` - a unique identifier for the account on the gno.land chain
- `sequence` - a nonce, used for protection against replay attacks

## `bank/balances`
Expand Down
3 changes: 1 addition & 2 deletions docs/how-to-guides/connecting-from-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ fmt.Println(accountRes)
// Address: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5
// Pubkey:
// Coins: 9999862000000ugnot
// AccountNumber: 0
// Sequence: 0

```

We are now ready to send a transaction to the chain.
Expand All @@ -212,7 +212,6 @@ To construct the base set of transaction fields, we can use the `BaseTxCfg` type
txCfg := gnoclient.BaseTxCfg{
GasFee: "1000000ugnot", // gas price
GasWanted: 1000000, // gas limit
AccountNumber: accountRes.GetAccountNumber(), // account ID
SequenceNumber: accountRes.GetSequence(), // account nonce
Memo: "This is a cool how-to guide!", // transaction memo
}
Expand Down
3 changes: 1 addition & 2 deletions gno.land/cmd/gnoland/testdata/event_multi_msg.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ stdout ' "BaseAccount": {'
stdout ' "address": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",'
stdout ' "coins": "[0-9]*ugnot",' # dynamic
stdout ' "public_key": null,'
stdout ' "account_number": "0",'
stdout ' "sequence": "0"'
stdout ' }'
stdout '}'
! stderr '.+' # empty


## sign
gnokey sign -tx-path $WORK/multi/multi_msg.tx -chainid=tendermint_test -account-number 0 -account-sequence 0 test1
gnokey sign -tx-path $WORK/multi/multi_msg.tx -chainid=tendermint_test -account-sequence 0 test1
stdout 'Tx successfully signed and saved to '

## broadcast
Expand Down
3 changes: 1 addition & 2 deletions gno.land/cmd/gnoland/testdata/gnoweb_airgapped.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ stdout ' "BaseAccount": {'
stdout ' "address": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",'
stdout ' "coins": "[0-9]*ugnot",' # dynamic
stdout ' "public_key": null,'
stdout ' "account_number": "0",'
stdout ' "sequence": "0"'
stdout ' }'
stdout '}'
Expand All @@ -26,7 +25,7 @@ gnokey maketx call -pkgpath "gno.land/r/demo/echo" -func "Render" -gas-fee 10000
cp stdout call.tx

# Sign
gnokey sign -tx-path $WORK/call.tx -chainid "tendermint_test" -account-number 0 -account-sequence 0 test1
gnokey sign -tx-path $WORK/call.tx -chainid "tendermint_test" -account-sequence 0 test1
cmpenv stdout sign.stdout.golden

gnokey broadcast $WORK/call.tx
Expand Down
Loading
Loading