Skip to content

Commit 2b8dff8

Browse files
committed
feat: asset verification
Fixes #104
1 parent 5ffbfa8 commit 2b8dff8

File tree

5 files changed

+167
-36
lines changed

5 files changed

+167
-36
lines changed

go.mod

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/blinklabs-io/cdnsd
33
go 1.20
44

55
require (
6-
github.com/blinklabs-io/cardano-models v0.2.0
7-
github.com/blinklabs-io/gouroboros v0.69.5
6+
github.com/blinklabs-io/cardano-models v0.3.0
7+
github.com/blinklabs-io/gouroboros v0.70.0
88
github.com/blinklabs-io/snek v0.17.1
99
github.com/dgraph-io/badger/v4 v4.2.0
1010
github.com/kelseyhightower/envconfig v1.4.0
@@ -18,6 +18,10 @@ require (
1818
github.com/dgraph-io/ristretto v0.1.1 // indirect
1919
github.com/dustin/go-humanize v1.0.0 // indirect
2020
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
21+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
22+
github.com/go-playground/locales v0.14.1 // indirect
23+
github.com/go-playground/universal-translator v0.18.1 // indirect
24+
github.com/go-playground/validator/v10 v10.17.0 // indirect
2125
github.com/gogo/protobuf v1.3.2 // indirect
2226
github.com/golang/glog v1.0.0 // indirect
2327
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
@@ -26,6 +30,7 @@ require (
2630
github.com/google/flatbuffers v1.12.1 // indirect
2731
github.com/jinzhu/copier v0.4.0 // indirect
2832
github.com/klauspost/compress v1.12.3 // indirect
33+
github.com/leodido/go-urn v1.2.4 // indirect
2934
github.com/pkg/errors v0.9.1 // indirect
3035
github.com/x448/float16 v0.8.4 // indirect
3136
go.opencensus.io v0.22.5 // indirect
@@ -34,6 +39,7 @@ require (
3439
golang.org/x/mod v0.14.0 // indirect
3540
golang.org/x/net v0.20.0 // indirect
3641
golang.org/x/sys v0.16.0 // indirect
42+
golang.org/x/text v0.14.0 // indirect
3743
golang.org/x/tools v0.17.0 // indirect
3844
google.golang.org/protobuf v1.31.0 // indirect
3945
)

go.sum

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3-
github.com/blinklabs-io/cardano-models v0.2.0 h1:fQ2vkvMLFgQodtFpYE73i+6+eNN5vaIB3GBIys8FsyI=
4-
github.com/blinklabs-io/cardano-models v0.2.0/go.mod h1:iH8IqSca4WzFQIAT3Ssd3TviILfoCgaJQ8mc3JrIvwE=
5-
github.com/blinklabs-io/gouroboros v0.69.5 h1:oFTObwPchrzZAunNA/+Y6g5NwMZQhA1Zj+iZGzX4TsU=
6-
github.com/blinklabs-io/gouroboros v0.69.5/go.mod h1:ecxtryJb+vIeVizQl4nYJr0tVdyIgOTze7R9xeGqFu4=
3+
github.com/blinklabs-io/cardano-models v0.3.0 h1:Xc7H1l4i96Vaf5bBKXrOl1ctL0vyT/bJ9+OrZUqD6E4=
4+
github.com/blinklabs-io/cardano-models v0.3.0/go.mod h1:mahC1oL4zVM5TCqZzqZ9I2GWAcEfzhJ3tYBpjwBWVI4=
5+
github.com/blinklabs-io/gouroboros v0.70.0 h1:/Jlo1G2c7rQDjijSXNti4v+J34QSkQwS57Vso6STqBo=
6+
github.com/blinklabs-io/gouroboros v0.70.0/go.mod h1:ecxtryJb+vIeVizQl4nYJr0tVdyIgOTze7R9xeGqFu4=
77
github.com/blinklabs-io/snek v0.17.1 h1:3u5eBTWF9tHQSNnHtHs7AQVSdX99xtqiPS5Hk7EU1qE=
88
github.com/blinklabs-io/snek v0.17.1/go.mod h1:6XJ2eDcU4n5V6TgpLDod+YD7pM43JOXcCiNOrDhdtKY=
99
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -23,6 +23,15 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
2323
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
2424
github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
2525
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
26+
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
27+
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
28+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
29+
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
30+
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
31+
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
32+
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
33+
github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74=
34+
github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
2635
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
2736
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
2837
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -53,14 +62,21 @@ github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/Vq
5362
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
5463
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
5564
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
65+
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
66+
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
5667
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
5768
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
5869
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
5970
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
6071
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6172
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6273
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
74+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
75+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
6376
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
77+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
78+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
79+
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
6480
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
6581
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
6682
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
@@ -114,6 +130,8 @@ golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
114130
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
115131
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
116132
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
133+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
134+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
117135
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
118136
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
119137
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -143,5 +161,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR
143161
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
144162
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
145163
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
164+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
146165
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
166+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
147167
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/config/config.go

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,14 @@ import (
1414
"gopkg.in/yaml.v2"
1515
)
1616

17-
// Per-network script address for Handshake
18-
var networkScriptAddresses = map[string]string{
19-
"preprod": "addr_test1wpf6lxntd3dztphew0m5dagrs7ptjcg9g6vgjyazt7mw44gdnwq0h",
20-
}
21-
22-
// Per-network intercept points for starting the chain-sync
23-
// We start the sync somewhere near where we expect the first data to appear to save time
24-
// during the initial sync
25-
var networkInterceptPoints = map[string]struct {
26-
Hash string
27-
Slot uint64
28-
}{
29-
"preprod": {
30-
Hash: "a35a0d216e00c64c257e41089138f4d22be721281d73f2ab8ef61ca8863d04a0",
31-
Slot: 34255089,
32-
},
33-
}
34-
3517
type Config struct {
3618
Logging LoggingConfig `yaml:"logging"`
3719
Metrics MetricsConfig `yaml:"metrics"`
3820
Dns DnsConfig `yaml:"dns"`
3921
Debug DebugConfig `yaml:"debug"`
4022
Indexer IndexerConfig `yaml:"indexer"`
4123
State StateConfig `yaml:"state"`
24+
Profile string `yaml:"profile" envconfig:"PROFILE"`
4225
}
4326

4427
type LoggingConfig struct {
@@ -72,6 +55,9 @@ type IndexerConfig struct {
7255
ScriptAddress string `yaml:"scriptAddress" envconfig:"INDEXER_SCRIPT_ADDRESS"`
7356
InterceptHash string `yaml:"interceptHash" envconfig:"INDEXER_INTERCEPT_HASH"`
7457
InterceptSlot uint64 `yaml:"interceptSlot" envconfig:"INDEXER_INTERCEPT_SLOT"`
58+
Tld string `yaml:"tld" envconfig:"INDEXER_TLD"`
59+
PolicyId string `yaml:"policyId" envconfig:"INDEXER_POLICY_ID"`
60+
Verify bool `yaml:"verify" envconfig:"INDEXER_VERIFY"`
7561
}
7662

7763
type StateConfig struct {
@@ -105,10 +91,12 @@ var globalConfig = &Config{
10591
},
10692
Indexer: IndexerConfig{
10793
Network: "preprod",
94+
Verify: true,
10895
},
10996
State: StateConfig{
11097
Directory: "./.state",
11198
},
99+
Profile: "cardano-preprod-testing",
112100
}
113101

114102
func Load(configFile string) (*Config, error) {
@@ -130,19 +118,41 @@ func Load(configFile string) (*Config, error) {
130118
if err != nil {
131119
return nil, fmt.Errorf("error processing environment: %s", err)
132120
}
133-
// Provide default script address for named network
121+
// Check profile
122+
profile, ok := Profiles[globalConfig.Profile]
123+
if !ok {
124+
return nil, fmt.Errorf("unknown profile: %s", globalConfig.Profile)
125+
}
126+
// Provide default network
127+
if globalConfig.Indexer.Network != "" {
128+
if profile.Network != "" {
129+
globalConfig.Indexer.Network = profile.Network
130+
} else {
131+
return nil, fmt.Errorf("no built-in network name for specified profile, please provide one")
132+
}
133+
}
134+
// Provide default script address from profile
134135
if globalConfig.Indexer.ScriptAddress == "" {
135-
if scriptAddress, ok := networkScriptAddresses[globalConfig.Indexer.Network]; ok {
136-
globalConfig.Indexer.ScriptAddress = scriptAddress
136+
if profile.ScriptAddress != "" {
137+
globalConfig.Indexer.ScriptAddress = profile.ScriptAddress
137138
} else {
138-
return nil, fmt.Errorf("no built-in script address for specified network, please provide one")
139+
return nil, fmt.Errorf("no built-in script address for specified profile, please provide one")
139140
}
140141
}
141-
// Provide default intercept point for named network
142+
// Provide default intercept point from profile
142143
if globalConfig.Indexer.InterceptSlot == 0 || globalConfig.Indexer.InterceptHash == "" {
143-
if interceptPoint, ok := networkInterceptPoints[globalConfig.Indexer.Network]; ok {
144-
globalConfig.Indexer.InterceptHash = interceptPoint.Hash
145-
globalConfig.Indexer.InterceptSlot = interceptPoint.Slot
144+
if profile.InterceptHash != "" && profile.InterceptSlot > 0 {
145+
globalConfig.Indexer.InterceptHash = profile.InterceptHash
146+
globalConfig.Indexer.InterceptSlot = profile.InterceptSlot
147+
}
148+
}
149+
// Provide default TLD and Policy ID from profile
150+
if globalConfig.Indexer.Tld == "" || globalConfig.Indexer.PolicyId == "" {
151+
if profile.Tld != "" && profile.PolicyId != "" {
152+
globalConfig.Indexer.Tld = profile.Tld
153+
globalConfig.Indexer.PolicyId = profile.PolicyId
154+
} else {
155+
return nil, fmt.Errorf("no built-in TLD and/or policy ID for specified profile, please provide one")
146156
}
147157
}
148158
return globalConfig, nil

internal/config/profile.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2023 Blink Labs Software
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file or at
5+
// https://opensource.org/licenses/MIT.
6+
7+
package config
8+
9+
type Profile struct {
10+
Network string // Cardano network name
11+
Tld string // Top-level domain
12+
PolicyId string // Verification asset policy ID
13+
ScriptAddress string // Address to follow
14+
InterceptSlot uint64 // Chain-sync initial intercept slot
15+
InterceptHash string // Chain-sync initial intercept hash
16+
}
17+
18+
var Profiles = map[string]Profile{
19+
// This (default) profile corresponds to the values specified in:
20+
// https://github.com/blinklabs-io/cardano-dns/blob/main/README.md
21+
"cardano-preprod-testing": Profile{
22+
Network: "preprod",
23+
Tld: "cardano",
24+
PolicyId: "6af60c2a7a06551ef09b3810a41d086b26ca26f926d22e462103194d",
25+
ScriptAddress: "addr_test1vr75xezmpxastymx985l3gamuxrwqdwcfrcnjlygs55aynsqu3edq",
26+
InterceptSlot: 50844079,
27+
InterceptHash: "81325118471fddb00a20327572b371aee7cce13b846a18500d011b9cefd2a34c",
28+
},
29+
}

internal/indexer/indexer.go

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func (i *Indexer) Start() error {
153153
}
154154

155155
func (i *Indexer) handleEvent(evt event.Event) error {
156+
cfg := config.GetConfig()
156157
logger := logging.GetLogger()
157158
eventTx := evt.Payload.(input_chainsync.TransactionEvent)
158159
eventCtx := evt.Context.(input_chainsync.TransactionContext)
@@ -169,17 +170,82 @@ func (i *Indexer) handleEvent(evt event.Event) error {
169170
// Stop processing TX output if we can't parse the datum
170171
continue
171172
}
172-
domainName := string(dnsDomain.Origin)
173-
// Convert to canonical form for consistency
174-
domainName = dns.CanonicalName(domainName)
173+
origin := string(dnsDomain.Origin)
174+
// Convert origin to canonical form for consistency
175+
// This mostly means adding a trailing period if it doesn't have one
176+
domainName := dns.CanonicalName(origin)
177+
// We want an empty value for the TLD root for convenience
178+
if domainName == `.` {
179+
domainName = ``
180+
}
181+
// Append TLD
182+
domainName = dns.CanonicalName(
183+
domainName + cfg.Indexer.Tld,
184+
)
185+
if cfg.Indexer.Verify {
186+
// Look for asset matching domain origin and TLD policy ID
187+
if txOutput.Assets() == nil {
188+
logger.Warnf(
189+
"ignoring datum for domain %q with no matching asset",
190+
domainName,
191+
)
192+
continue
193+
}
194+
foundAsset := false
195+
for _, policyId := range txOutput.Assets().Policies() {
196+
for _, assetName := range txOutput.Assets().Assets(policyId) {
197+
if policyId.String() == cfg.Indexer.PolicyId {
198+
if string(assetName) == string(origin) {
199+
foundAsset = true
200+
} else {
201+
logger.Warnf(
202+
"ignoring datum for domain %q with no matching asset",
203+
domainName,
204+
)
205+
}
206+
} else {
207+
logger.Warnf(
208+
"ignoring datum for domain %q with no matching asset",
209+
domainName,
210+
)
211+
}
212+
}
213+
}
214+
if !foundAsset {
215+
continue
216+
}
217+
// Make sure all records are for specified origin domain
218+
badRecordName := false
219+
for _, record := range dnsDomain.Records {
220+
recordName := dns.CanonicalName(
221+
string(record.Lhs),
222+
)
223+
if !strings.HasSuffix(recordName, domainName) {
224+
logger.Warnf(
225+
"ignoring datum with record %q outside of origin domain (%s)",
226+
recordName,
227+
domainName,
228+
)
229+
badRecordName = true
230+
break
231+
}
232+
}
233+
if badRecordName {
234+
continue
235+
}
236+
}
175237
nameServers := map[string]string{}
176238
for _, record := range dnsDomain.Records {
239+
recordName := strings.Trim(
240+
string(record.Lhs),
241+
`.`,
242+
)
177243
// NOTE: we're losing information here, but we need to revamp the storage
178244
// format before we can use it. We're also making the assumption that all
179245
// records are for nameservers
180246
switch strings.ToUpper(string(record.Type)) {
181247
case "A", "AAAA":
182-
nameServers[string(record.Lhs)] = string(record.Rhs)
248+
nameServers[recordName] = string(record.Rhs)
183249
default:
184250
continue
185251
}

0 commit comments

Comments
 (0)