Skip to content

Commit c93c225

Browse files
committed
chore: Merge remote-tracking branch 'origin/master' into gno-resolver
Signed-off-by: Norman <norman@samourai.coop>
2 parents 31b92be + be61d7d commit c93c225

File tree

202 files changed

+5191
-833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+5191
-833
lines changed

.github/codecov.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,10 @@ coverage:
1010
round: down
1111
precision: 2
1212
status:
13-
project:
13+
patch: # new lines
1414
default:
15-
target: auto
16-
threshold: 5 # Let's decrease this later.
17-
base: parent
18-
if_no_uploads: error
19-
if_not_found: success
20-
if_ci_failed: error
21-
only_pulls: false
22-
patch:
23-
default:
24-
target: auto
25-
threshold: 5 # Let's decrease this later.
15+
target: 80
16+
threshold: 10
2617
base: auto
2718
if_no_uploads: error
2819
if_not_found: success

.github/workflows/genesis-verify.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
testnet: [ "test5.gno.land" ]
17+
testnet: [ ] # Currently, all active testnet deployment genesis.json are legacy
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout code

.github/workflows/gh-pages.yml

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# generate Go docs and publish on gh-pages branch
22
# Live at: https://gnolang.github.io/gno
3-
name: Go Reference Docs Deployment
3+
name: GitHub pages (godoc & stdlib_diff) build and deploy
44

55
on:
66
push:
77
branches:
88
- master
9+
pull_request:
10+
branches:
11+
- master
912
workflow_dispatch:
1013

1114
permissions:
@@ -19,29 +22,39 @@ concurrency:
1922

2023
jobs:
2124
build:
22-
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
25+
if: github.repository == 'gnolang/gno' # Alternatively, validate based on provided tokens and permissions.
2326
runs-on: ubuntu-latest
2427
steps:
2528
- uses: actions/checkout@v4
2629
- uses: actions/setup-go@v5
2730
with:
2831
go-version-file: go.mod
29-
- run: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
30-
- run: echo $GOROOT
32+
# Use the goroot at the top of the project to compare with the GnoVM
33+
# stdlib, rather than the one in stdlib_diff (which may have a go.mod with
34+
# a different toolchain version).
35+
- run: echo "GOROOT_SAVE=$(go env GOROOT)" >> $GITHUB_ENV
3136
- run: "cd misc/stdlib_diff && make gen"
3237
- run: "cd misc/gendocs && make install gen"
3338
- run: "mkdir -p pages_output/stdlib_diff"
3439
- run: |
3540
cp -r misc/gendocs/godoc/* pages_output/
3641
cp -r misc/stdlib_diff/stdlib_diff/* pages_output/stdlib_diff/
42+
43+
# These two last steps will be skipped on pull requests
3744
- uses: actions/configure-pages@v5
3845
id: pages
46+
if: github.event_name != 'pull_request'
47+
3948
- uses: actions/upload-pages-artifact@v3
49+
if: github.event_name != 'pull_request'
4050
with:
4151
path: ./pages_output
4252

4353
deploy:
44-
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
54+
if: >
55+
github.repository == 'gnolang/gno' &&
56+
github.ref == 'refs/heads/master' &&
57+
github.event_name == 'push'
4558
runs-on: ubuntu-latest
4659
environment:
4760
name: github-pages

contribs/github-bot/internal/config/config.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
3333
auto := []AutomaticCheck{
3434
{
3535
Description: "Maintainers must be able to edit this pull request ([more info](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork))",
36-
If: c.CreatedFromFork(),
37-
Then: r.MaintainerCanModify(),
36+
If: c.And(
37+
c.BaseBranch("^master$"),
38+
c.CreatedFromFork(),
39+
),
40+
Then: r.MaintainerCanModify(),
3841
},
3942
{
4043
Description: "Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff",
41-
If: c.FileChanged(gh, "^docs/"),
44+
If: c.And(
45+
c.BaseBranch("^master$"),
46+
c.FileChanged(gh, "^docs/"),
47+
),
4248
Then: r.And(
4349
r.Or(
4450
r.AuthorInTeam(gh, "tech-staff"),
@@ -57,7 +63,10 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
5763
},
5864
{
5965
Description: "Pending initial approval by a review team member, or review from tech-staff",
60-
If: c.Not(c.AuthorInTeam(gh, "tech-staff")),
66+
If: c.And(
67+
c.BaseBranch("^master$"),
68+
c.Not(c.AuthorInTeam(gh, "tech-staff")),
69+
),
6170
Then: r.
6271
If(r.Or(
6372
r.ReviewByOrgMembers(gh).WithDesiredState(utils.ReviewStateApproved),
@@ -91,7 +100,7 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
91100
{
92101
Description: "Determine if infra needs to be updated before merging",
93102
If: c.And(
94-
c.BaseBranch("master"),
103+
c.BaseBranch("^master$"),
95104
c.Or(
96105
c.FileChanged(gh, `Dockerfile`),
97106
c.FileChanged(gh, `^misc/deployments`),

contribs/gnodev/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ require (
7979
github.com/rs/xid v1.6.0 // indirect
8080
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
8181
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
82+
github.com/valyala/bytebufferpool v1.0.0 // indirect
8283
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
8384
github.com/yuin/goldmark v1.7.8 // indirect
8485
github.com/yuin/goldmark-emoji v1.0.2 // indirect

contribs/gnodev/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnofaucet/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ require (
3232
github.com/rs/cors v1.11.1 // indirect
3333
github.com/rs/xid v1.6.0 // indirect
3434
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
35+
github.com/valyala/bytebufferpool v1.0.0 // indirect
3536
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
3637
go.opentelemetry.io/otel v1.34.0 // indirect
3738
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect

contribs/gnofaucet/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnogenesis/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ require (
3636
github.com/rs/xid v1.6.0 // indirect
3737
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
3838
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
39+
github.com/valyala/bytebufferpool v1.0.0 // indirect
3940
github.com/zondax/hid v0.9.2 // indirect
4041
github.com/zondax/ledger-go v0.14.3 // indirect
4142
go.etcd.io/bbolt v1.3.11 // indirect

contribs/gnogenesis/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnogenesis/internal/verify/verify.go

+27-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import (
1212
"github.com/gnolang/gno/tm2/pkg/commands"
1313
)
1414

15-
var errInvalidGenesisState = errors.New("invalid genesis state type")
15+
var (
16+
errInvalidGenesisState = errors.New("invalid genesis state type")
17+
errInvalidTxSignature = errors.New("invalid tx signature")
18+
)
1619

1720
type verifyCfg struct {
1821
common.Cfg
@@ -60,10 +63,32 @@ func execVerify(cfg *verifyCfg, io commands.IO) error {
6063
}
6164

6265
// Validate the initial transactions
63-
for _, tx := range state.Txs {
66+
for index, tx := range state.Txs {
6467
if validateErr := tx.Tx.ValidateBasic(); validateErr != nil {
6568
return fmt.Errorf("invalid transacton, %w", validateErr)
6669
}
70+
71+
// Genesis txs can only be signed by 1 account.
72+
// Basic tx validation ensures there is at least 1 signer
73+
signer := tx.Tx.GetSignatures()[0]
74+
75+
// Grab the signature bytes of the tx.
76+
// Genesis transactions are signed with
77+
// account number and sequence set to 0
78+
signBytes, err := tx.Tx.GetSignBytes(genesis.ChainID, 0, 0)
79+
if err != nil {
80+
return fmt.Errorf("unable to get tx signature payload, %w", err)
81+
}
82+
83+
// Verify the signature using the public key
84+
if !signer.PubKey.VerifyBytes(signBytes, signer.Signature) {
85+
return fmt.Errorf(
86+
"%w #%d, by signer %s",
87+
errInvalidTxSignature,
88+
index,
89+
signer.PubKey.Address(),
90+
)
91+
}
6792
}
6893

6994
// Validate the initial balances

contribs/gnogenesis/internal/verify/verify_test.go

+97
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import (
88
"github.com/gnolang/gno/gno.land/pkg/gnoland"
99
"github.com/gnolang/gno/tm2/pkg/bft/types"
1010
"github.com/gnolang/gno/tm2/pkg/commands"
11+
"github.com/gnolang/gno/tm2/pkg/crypto/ed25519"
1112
"github.com/gnolang/gno/tm2/pkg/crypto/mock"
13+
"github.com/gnolang/gno/tm2/pkg/sdk/bank"
14+
"github.com/gnolang/gno/tm2/pkg/std"
1215
"github.com/gnolang/gno/tm2/pkg/testutils"
16+
"github.com/stretchr/testify/assert"
1317
"github.com/stretchr/testify/require"
1418
)
1519

@@ -63,6 +67,99 @@ func TestGenesis_Verify(t *testing.T) {
6367
require.Error(t, cmdErr)
6468
})
6569

70+
t.Run("invalid tx signature", func(t *testing.T) {
71+
t.Parallel()
72+
73+
g := getValidTestGenesis()
74+
75+
testTable := []struct {
76+
name string
77+
signBytesFn func(tx *std.Tx) []byte
78+
}{
79+
{
80+
name: "invalid chain ID",
81+
signBytesFn: func(tx *std.Tx) []byte {
82+
// Sign the transaction, but with a chain ID
83+
// that differs from the genesis chain ID
84+
signBytes, err := tx.GetSignBytes(g.ChainID+"wrong", 0, 0)
85+
require.NoError(t, err)
86+
87+
return signBytes
88+
},
89+
},
90+
{
91+
name: "invalid account params",
92+
signBytesFn: func(tx *std.Tx) []byte {
93+
// Sign the transaction, but with an
94+
// account number that is not 0
95+
signBytes, err := tx.GetSignBytes(g.ChainID, 10, 0)
96+
require.NoError(t, err)
97+
98+
return signBytes
99+
},
100+
},
101+
}
102+
103+
for _, testCase := range testTable {
104+
t.Run(testCase.name, func(t *testing.T) {
105+
t.Parallel()
106+
107+
tempFile, cleanup := testutils.NewTestFile(t)
108+
t.Cleanup(cleanup)
109+
110+
// Generate the transaction
111+
signer := ed25519.GenPrivKey()
112+
113+
sendMsg := bank.MsgSend{
114+
FromAddress: signer.PubKey().Address(),
115+
ToAddress: signer.PubKey().Address(),
116+
Amount: std.NewCoins(std.NewCoin("ugnot", 10)),
117+
}
118+
119+
tx := std.Tx{
120+
Msgs: []std.Msg{sendMsg},
121+
Fee: std.Fee{
122+
GasWanted: 1000000,
123+
GasFee: std.NewCoin("ugnot", 20),
124+
},
125+
}
126+
127+
// Sign the transaction
128+
signBytes := testCase.signBytesFn(&tx)
129+
130+
signature, err := signer.Sign(signBytes)
131+
require.NoError(t, err)
132+
133+
tx.Signatures = append(tx.Signatures, std.Signature{
134+
PubKey: signer.PubKey(),
135+
Signature: signature,
136+
})
137+
138+
g.AppState = gnoland.GnoGenesisState{
139+
Balances: []gnoland.Balance{},
140+
Txs: []gnoland.TxWithMetadata{
141+
{
142+
Tx: tx,
143+
},
144+
},
145+
}
146+
147+
require.NoError(t, g.SaveAs(tempFile.Name()))
148+
149+
// Create the command
150+
cmd := NewVerifyCmd(commands.NewTestIO())
151+
args := []string{
152+
"--genesis-path",
153+
tempFile.Name(),
154+
}
155+
156+
// Run the command
157+
cmdErr := cmd.ParseAndRun(context.Background(), args)
158+
assert.ErrorIs(t, cmdErr, errInvalidTxSignature)
159+
})
160+
}
161+
})
162+
66163
t.Run("invalid balances", func(t *testing.T) {
67164
t.Parallel()
68165

contribs/gnohealth/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require (
2323
github.com/rs/xid v1.6.0 // indirect
2424
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
2525
github.com/stretchr/testify v1.10.0 // indirect
26+
github.com/valyala/bytebufferpool v1.0.0 // indirect
2627
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
2728
go.opentelemetry.io/otel v1.34.0 // indirect
2829
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect

contribs/gnohealth/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnokeykc/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ require (
3838
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
3939
github.com/stretchr/testify v1.10.0 // indirect
4040
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
41+
github.com/valyala/bytebufferpool v1.0.0 // indirect
4142
github.com/zondax/hid v0.9.2 // indirect
4243
github.com/zondax/ledger-go v0.14.3 // indirect
4344
go.opentelemetry.io/auto/sdk v1.1.0 // indirect

contribs/gnokeykc/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contribs/gnomigrate/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ require (
3333
github.com/rs/xid v1.6.0 // indirect
3434
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
3535
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
36+
github.com/valyala/bytebufferpool v1.0.0 // indirect
3637
go.etcd.io/bbolt v1.3.11 // indirect
3738
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
3839
go.opentelemetry.io/otel v1.34.0 // indirect

contribs/gnomigrate/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)