Skip to content

Commit 9333af8

Browse files
committed
chore: merge branch 'origin/main'
Signed-off-by: Chris Gianelloni <[email protected]>
2 parents c8e64d2 + 682253c commit 9333af8

File tree

20 files changed

+1053
-85
lines changed

20 files changed

+1053
-85
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ run:
44
tests: false
55
linters:
66
enable:
7+
- asasalint
78
- asciicheck
89
- bidichk
910
- bodyclose
@@ -36,7 +37,6 @@ linters:
3637
- whitespace
3738
- zerologlint
3839
disable:
39-
- asasalint
4040
- depguard
4141
- noctx
4242
- recvcheck

cbor/tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ type Map map[any]any
181181

182182
// SetType is a generic type for wrapping other types in an optional CBOR set tag
183183
type SetType[T any] struct {
184-
useTag bool
185184
items []T
185+
useTag bool
186186
}
187187

188188
func NewSetType[T any](items []T, useTag bool) SetType[T] {

cbor/value.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,20 @@ func generateAstJson(obj any) ([]byte, error) {
211211
}
212212

213213
func generateAstJsonList[T []any | Set](v T) ([]byte, error) {
214-
tmpJson := `{"list":[`
214+
var sb strings.Builder
215+
sb.WriteString(`{"list":[`)
215216
for idx, val := range v {
216217
tmpVal, err := generateAstJson(val)
217218
if err != nil {
218219
return nil, err
219220
}
220-
tmpJson += string(tmpVal)
221+
sb.WriteString(string(tmpVal))
221222
if idx != (len(v) - 1) {
222-
tmpJson += `,`
223+
sb.WriteString(`,`)
223224
}
224225
}
225-
tmpJson += `]}`
226-
return []byte(tmpJson), nil
226+
sb.WriteString(`]}`)
227+
return []byte(sb.String()), nil
227228
}
228229

229230
func generateAstJsonMap[T map[any]any | Map](v T) ([]byte, error) {
@@ -343,7 +344,8 @@ func (c Constructor) MarshalCBOR() ([]byte, error) {
343344
}
344345

345346
func (v Constructor) MarshalJSON() ([]byte, error) {
346-
tmpJson := fmt.Sprintf(`{"constructor":%d,"fields":[`, v.constructor)
347+
var sb strings.Builder
348+
sb.WriteString(fmt.Sprintf(`{"constructor":%d,"fields":[`, v.constructor))
347349
tmpList := [][]byte{}
348350
for _, val := range v.value.Value().([]any) {
349351
tmpVal, err := generateAstJson(val)
@@ -353,13 +355,13 @@ func (v Constructor) MarshalJSON() ([]byte, error) {
353355
tmpList = append(tmpList, tmpVal)
354356
}
355357
for idx, val := range tmpList {
356-
tmpJson += string(val)
358+
sb.WriteString(string(val))
357359
if idx != (len(tmpList) - 1) {
358-
tmpJson += `,`
360+
sb.WriteString(`,`)
359361
}
360362
}
361-
tmpJson += `]}`
362-
return []byte(tmpJson), nil
363+
sb.WriteString(`]}`)
364+
return []byte(sb.String()), nil
363365
}
364366

365367
type LazyValue struct {

cmd/gouroboros/query.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ func testQuery(f *globalFlags) {
305305
}
306306
}
307307
}
308+
case "proposed-protocol-params-updates":
309+
proposedUpdates, err := o.LocalStateQuery().Client.GetProposedProtocolParamsUpdates()
310+
if err != nil {
311+
fmt.Printf("ERROR: failure querying proposed protocol params updates: %s\n", err)
312+
os.Exit(1)
313+
}
314+
fmt.Printf("proposed-protocol-params-updates: %v\n", *proposedUpdates)
308315
default:
309316
fmt.Printf("ERROR: unknown query: %s\n", queryFlags.flagset.Args()[0])
310317
os.Exit(1)

connection.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/blinklabs-io/gouroboros/protocol/chainsync"
4040
"github.com/blinklabs-io/gouroboros/protocol/handshake"
4141
"github.com/blinklabs-io/gouroboros/protocol/keepalive"
42+
"github.com/blinklabs-io/gouroboros/protocol/leiosfetch"
4243
"github.com/blinklabs-io/gouroboros/protocol/leiosnotify"
4344
"github.com/blinklabs-io/gouroboros/protocol/localstatequery"
4445
"github.com/blinklabs-io/gouroboros/protocol/localtxmonitor"
@@ -85,6 +86,8 @@ type Connection struct {
8586
handshake *handshake.Handshake
8687
keepAlive *keepalive.KeepAlive
8788
keepAliveConfig *keepalive.Config
89+
leiosFetch *leiosfetch.LeiosFetch
90+
leiosFetchConfig *leiosfetch.Config
8891
leiosNotify *leiosnotify.LeiosNotify
8992
leiosNotifyConfig *leiosnotify.Config
9093
localStateQuery *localstatequery.LocalStateQuery
@@ -209,6 +212,11 @@ func (c *Connection) KeepAlive() *keepalive.KeepAlive {
209212
return c.keepAlive
210213
}
211214

215+
// LeiosFetch returns the leios-fetch protocol handler
216+
func (c *Connection) LeiosFetch() *leiosfetch.LeiosFetch {
217+
return c.leiosFetch
218+
}
219+
212220
// LeiosNotify returns the leios-notify protocol handler
213221
func (c *Connection) LeiosNotify() *leiosnotify.LeiosNotify {
214222
return c.leiosNotify
@@ -405,6 +413,7 @@ func (c *Connection) setupConnection() error {
405413
c.peerSharing = peersharing.New(protoOptions, c.peerSharingConfig)
406414
}
407415
c.leiosNotify = leiosnotify.New(protoOptions, c.leiosNotifyConfig)
416+
c.leiosFetch = leiosfetch.New(protoOptions, c.leiosFetchConfig)
408417
// Start protocols
409418
if !c.delayProtocolStart {
410419
if (c.fullDuplex && handshakeFullDuplex) || !c.server {
@@ -418,6 +427,7 @@ func (c *Connection) setupConnection() error {
418427
c.peerSharing.Client.Start()
419428
}
420429
c.leiosNotify.Client.Start()
430+
c.leiosFetch.Client.Start()
421431
}
422432
if (c.fullDuplex && handshakeFullDuplex) || c.server {
423433
c.blockFetch.Server.Start()
@@ -430,6 +440,7 @@ func (c *Connection) setupConnection() error {
430440
c.peerSharing.Server.Start()
431441
}
432442
c.leiosNotify.Server.Start()
443+
c.leiosFetch.Server.Start()
433444
}
434445
}
435446
} else {

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ require (
1414
github.com/stretchr/testify v1.11.1
1515
github.com/utxorpc/go-codegen v0.17.0
1616
go.uber.org/goleak v1.3.0
17-
golang.org/x/crypto v0.42.0
17+
golang.org/x/crypto v0.43.0
1818
)
1919

2020
require (
2121
github.com/bits-and-blooms/bitset v1.20.0 // indirect
2222
github.com/btcsuite/btcd/btcec/v2 v2.3.5 // indirect
2323
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
24-
github.com/consensys/gnark-crypto v0.19.0 // indirect
24+
github.com/consensys/gnark-crypto v0.19.1 // indirect
2525
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2626
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
2727
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
@@ -30,7 +30,7 @@ require (
3030
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3131
github.com/rogpeppe/go-internal v1.14.1 // indirect
3232
github.com/x448/float16 v0.8.4 // indirect
33-
golang.org/x/sys v0.36.0 // indirect
33+
golang.org/x/sys v0.37.0 // indirect
3434
google.golang.org/protobuf v1.36.6 // indirect
3535
gopkg.in/yaml.v3 v3.0.1 // indirect
3636
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
3333
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
3434
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
3535
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
36-
github.com/consensys/gnark-crypto v0.19.0 h1:zXCqeY2txSaMl6G5wFpZzMWJU9HPNh8qxPnYJ1BL9vA=
37-
github.com/consensys/gnark-crypto v0.19.0/go.mod h1:rT23F0XSZqE0mUA0+pRtnL56IbPxs6gp4CeRsBk4XS0=
36+
github.com/consensys/gnark-crypto v0.19.1 h1:FWO1JDs7A2OajswzwMG7f8l2Zrxc/yOkxSTByKTc3O0=
37+
github.com/consensys/gnark-crypto v0.19.1/go.mod h1:rT23F0XSZqE0mUA0+pRtnL56IbPxs6gp4CeRsBk4XS0=
3838
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
3939
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4040
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -112,8 +112,8 @@ go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
112112
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
113113
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
114114
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
115-
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
116-
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
115+
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
116+
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
117117
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
118118
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
119119
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -129,8 +129,8 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
129129
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
130130
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
131131
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
132-
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
133-
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
132+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
133+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
134134
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
135135
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
136136
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

ledger/common/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func Blake2b224Hash(data []byte) Blake2b224 {
110110
return Blake2b224(tmpHash.Sum(nil))
111111
}
112112

113+
// GenesisHash is a type alias for the Blake2b-224 hash used for genesis keys
114+
type GenesisHash = Blake2b224
115+
113116
type Blake2b160 [Blake2b160Size]byte
114117

115118
func NewBlake2b160(data []byte) Blake2b160 {

ledger/common/script.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ScriptHash = Blake2b224
3737
type Script interface {
3838
isScript()
3939
Hash() ScriptHash
40+
RawScriptBytes() []byte
4041
}
4142

4243
type ScriptRef struct {
@@ -114,6 +115,10 @@ func (s PlutusV1Script) Hash() ScriptHash {
114115
)
115116
}
116117

118+
func (s PlutusV1Script) RawScriptBytes() []byte {
119+
return []byte(s)
120+
}
121+
117122
type PlutusV2Script []byte
118123

119124
func (PlutusV2Script) isScript() {}
@@ -127,6 +132,10 @@ func (s PlutusV2Script) Hash() ScriptHash {
127132
)
128133
}
129134

135+
func (s PlutusV2Script) RawScriptBytes() []byte {
136+
return []byte(s)
137+
}
138+
130139
type PlutusV3Script []byte
131140

132141
func (PlutusV3Script) isScript() {}
@@ -140,6 +149,10 @@ func (s PlutusV3Script) Hash() ScriptHash {
140149
)
141150
}
142151

152+
func (s PlutusV3Script) RawScriptBytes() []byte {
153+
return []byte(s)
154+
}
155+
143156
func (s PlutusV3Script) Evaluate(
144157
scriptContext data.PlutusData,
145158
budget ExUnits,
@@ -238,6 +251,10 @@ func (s NativeScript) Hash() ScriptHash {
238251
)
239252
}
240253

254+
func (s NativeScript) RawScriptBytes() []byte {
255+
return s.Cbor()
256+
}
257+
241258
type NativeScriptPubkey struct {
242259
cbor.StructAsArray
243260
Type uint

ledger/common/script_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package common_test
1616

1717
import (
18+
"bytes"
1819
"encoding/hex"
1920
"reflect"
2021
"testing"
@@ -40,6 +41,13 @@ func TestScriptRefDecodeEncode(t *testing.T) {
4041
&expectedScript,
4142
)
4243
}
44+
if !bytes.Equal(testScriptRef.Script.RawScriptBytes(), scriptCbor) {
45+
t.Fatalf(
46+
"did not get expected raw script bytes\n got: %x\n wanted: %x",
47+
testScriptRef.Script.RawScriptBytes(),
48+
scriptCbor,
49+
)
50+
}
4351
scriptRefCbor, err := cbor.Encode(testScriptRef)
4452
if err != nil {
4553
t.Fatalf("unexpected error: %s", err)

0 commit comments

Comments
 (0)