Skip to content

Commit 88e8598

Browse files
authored
Merge branch 'master' into dev-thinhnx/feat_mux_support_query_strings
2 parents 108c458 + bd99fbe commit 88e8598

File tree

14 files changed

+445
-71
lines changed

14 files changed

+445
-71
lines changed

contribs/gnofaucet/go.mod

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.22
55
toolchain go1.22.4
66

77
require (
8-
github.com/gnolang/faucet v0.2.1
9-
github.com/gnolang/gno v0.1.0-nightly.20240627
8+
github.com/gnolang/faucet v0.3.1
9+
github.com/gnolang/gno v0.1.1
1010
github.com/stretchr/testify v1.9.0
1111
go.uber.org/zap v1.27.0
1212
golang.org/x/time v0.5.0
@@ -19,37 +19,38 @@ require (
1919
github.com/davecgh/go-spew v1.1.1 // indirect
2020
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
2121
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
22-
github.com/go-chi/chi/v5 v5.0.12 // indirect
23-
github.com/go-logr/logr v1.4.1 // indirect
22+
github.com/go-chi/chi/v5 v5.1.0 // indirect
23+
github.com/go-logr/logr v1.4.2 // indirect
2424
github.com/go-logr/stdr v1.2.2 // indirect
25+
github.com/google/uuid v1.6.0 // indirect
2526
github.com/gorilla/websocket v1.5.1 // indirect
2627
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
2728
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
2829
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
2930
github.com/pmezard/go-difflib v1.0.0 // indirect
3031
github.com/rs/cors v1.11.0 // indirect
3132
github.com/rs/xid v1.5.0 // indirect
32-
go.opentelemetry.io/otel v1.27.0 // indirect
33-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 // indirect
34-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 // indirect
35-
go.opentelemetry.io/otel/metric v1.27.0 // indirect
36-
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
37-
go.opentelemetry.io/otel/sdk/metric v1.27.0 // indirect
38-
go.opentelemetry.io/otel/trace v1.27.0 // indirect
39-
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
33+
go.opentelemetry.io/otel v1.28.0 // indirect
34+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect
35+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 // indirect
36+
go.opentelemetry.io/otel/metric v1.28.0 // indirect
37+
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
38+
go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect
39+
go.opentelemetry.io/otel/trace v1.28.0 // indirect
40+
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
4041
go.uber.org/multierr v1.11.0 // indirect
4142
go.uber.org/zap/exp v0.2.0 // indirect
42-
golang.org/x/crypto v0.23.0 // indirect
43-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
44-
golang.org/x/mod v0.17.0 // indirect
45-
golang.org/x/net v0.25.0 // indirect
43+
golang.org/x/crypto v0.25.0 // indirect
44+
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
45+
golang.org/x/mod v0.19.0 // indirect
46+
golang.org/x/net v0.27.0 // indirect
4647
golang.org/x/sync v0.7.0 // indirect
47-
golang.org/x/sys v0.20.0 // indirect
48-
golang.org/x/term v0.20.0 // indirect
49-
golang.org/x/text v0.15.0 // indirect
50-
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
51-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
52-
google.golang.org/grpc v1.64.0 // indirect
53-
google.golang.org/protobuf v1.34.1 // indirect
48+
golang.org/x/sys v0.22.0 // indirect
49+
golang.org/x/term v0.22.0 // indirect
50+
golang.org/x/text v0.16.0 // indirect
51+
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
52+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
53+
google.golang.org/grpc v1.65.0 // indirect
54+
google.golang.org/protobuf v1.34.2 // indirect
5455
gopkg.in/yaml.v3 v3.0.1 // indirect
5556
)

contribs/gnofaucet/go.sum

Lines changed: 48 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Entropy generates fully deterministic, cost-effective, and hard to guess
2+
// numbers.
3+
//
4+
// It is designed both for single-usage, like seeding math/rand or for being
5+
// reused which increases the entropy and its cost effectiveness.
6+
//
7+
// Disclaimer: this package is unsafe and won't prevent others to guess values
8+
// in advance.
9+
//
10+
// It uses the Bernstein's hash djb2 to be CPU-cycle efficient.
11+
package entropy
12+
13+
import (
14+
"math"
15+
"std"
16+
"time"
17+
)
18+
19+
type Instance struct {
20+
value uint32
21+
}
22+
23+
func New() *Instance {
24+
r := Instance{value: 5381}
25+
r.addEntropy()
26+
return &r
27+
}
28+
29+
func FromSeed(seed uint32) *Instance {
30+
r := Instance{value: seed}
31+
r.addEntropy()
32+
return &r
33+
}
34+
35+
func (i *Instance) Seed() uint32 {
36+
return i.value
37+
}
38+
39+
func (i *Instance) djb2String(input string) {
40+
for _, c := range input {
41+
i.djb2Uint32(uint32(c))
42+
}
43+
}
44+
45+
// super fast random algorithm.
46+
// http://www.cse.yorku.ca/~oz/hash.html
47+
func (i *Instance) djb2Uint32(input uint32) {
48+
i.value = (i.value << 5) + i.value + input
49+
}
50+
51+
// AddEntropy uses various runtime variables to add entropy to the existing seed.
52+
func (i *Instance) addEntropy() {
53+
// FIXME: reapply the 5381 initial value?
54+
55+
// inherit previous entropy
56+
// nothing to do
57+
58+
// handle callers
59+
{
60+
caller1 := std.GetCallerAt(1).String()
61+
i.djb2String(caller1)
62+
caller2 := std.GetCallerAt(2).String()
63+
i.djb2String(caller2)
64+
}
65+
66+
// height
67+
{
68+
height := std.GetHeight()
69+
if height >= math.MaxUint32 {
70+
height -= math.MaxUint32
71+
}
72+
i.djb2Uint32(uint32(height))
73+
}
74+
75+
// time
76+
{
77+
secs := time.Now().Second()
78+
i.djb2Uint32(uint32(secs))
79+
nsecs := time.Now().Nanosecond()
80+
i.djb2Uint32(uint32(nsecs))
81+
}
82+
83+
// FIXME: compute other hard-to-guess but deterministic variables, like real gas?
84+
}
85+
86+
func (i *Instance) Value() uint32 {
87+
i.addEntropy()
88+
return i.value
89+
}

0 commit comments

Comments
 (0)