@blinklabs/dingo 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/{bin/dingo → dingo} +0 -0
- package/dingo.yaml.example +53 -0
- package/package.json +2 -2
- package/.github/CODEOWNERS +0 -5
- package/.github/assets/dingo-ate-my-blockchain.png +0 -0
- package/.github/assets/dingo-illustration.png +0 -0
- package/.github/assets/dingo-logo-with-text-horizontal.png +0 -0
- package/.github/assets/dingo-logo-with-text.png +0 -0
- package/.github/dependabot.yml +0 -19
- package/.github/dingo-20241210.png +0 -0
- package/.github/dingo.md +0 -56
- package/.github/workflows/ci-docker.yml +0 -36
- package/.github/workflows/conventional-commits.yml +0 -17
- package/.github/workflows/go-test.yml +0 -29
- package/.github/workflows/golangci-lint.yml +0 -23
- package/.github/workflows/publish.yml +0 -207
- package/Dockerfile +0 -25
- package/Makefile +0 -53
- package/blockfetch.go +0 -144
- package/chain/chain.go +0 -504
- package/chain/chain_test.go +0 -468
- package/chain/errors.go +0 -80
- package/chain/event.go +0 -33
- package/chain/iter.go +0 -64
- package/chainsync/chainsync.go +0 -97
- package/chainsync.go +0 -223
- package/cmd/dingo/load.go +0 -52
- package/cmd/dingo/main.go +0 -118
- package/cmd/dingo/serve.go +0 -49
- package/config/cardano/node.go +0 -192
- package/config/cardano/node_test.go +0 -85
- package/config/cardano/preview/README.md +0 -4
- package/config/cardano/preview/alonzo-genesis.json +0 -196
- package/config/cardano/preview/byron-genesis.json +0 -117
- package/config/cardano/preview/config.json +0 -114
- package/config/cardano/preview/conway-genesis.json +0 -297
- package/config/cardano/preview/shelley-genesis.json +0 -68
- package/config.go +0 -245
- package/connmanager/connection_manager.go +0 -105
- package/connmanager/connection_manager_test.go +0 -185
- package/connmanager/event.go +0 -37
- package/connmanager/listener.go +0 -140
- package/connmanager/outbound.go +0 -93
- package/connmanager/socket.go +0 -55
- package/connmanager/unix.go +0 -78
- package/custom-p2p-topology.json +0 -24
- package/custom-p2p-topology.json.backup +0 -24
- package/custom-p2p-topology.json.mainnet +0 -37
- package/database/account.go +0 -180
- package/database/block.go +0 -362
- package/database/certs.go +0 -53
- package/database/commit_timestamp.go +0 -77
- package/database/database.go +0 -118
- package/database/database_test.go +0 -62
- package/database/drep.go +0 -47
- package/database/epoch.go +0 -121
- package/database/immutable/chunk.go +0 -182
- package/database/immutable/immutable.go +0 -350
- package/database/immutable/immutable_test.go +0 -59
- package/database/immutable/primary.go +0 -106
- package/database/immutable/secondary.go +0 -103
- package/database/immutable/testdata/08893.chunk +0 -0
- package/database/immutable/testdata/08893.primary +0 -0
- package/database/immutable/testdata/08893.secondary +0 -0
- package/database/immutable/testdata/08894.chunk +0 -0
- package/database/immutable/testdata/08894.primary +0 -0
- package/database/immutable/testdata/08894.secondary +0 -0
- package/database/immutable/testdata/README.md +0 -4
- package/database/plugin/blob/badger/commit_timestamp.go +0 -50
- package/database/plugin/blob/badger/database.go +0 -152
- package/database/plugin/blob/badger/logger.go +0 -63
- package/database/plugin/blob/badger/metrics.go +0 -98
- package/database/plugin/blob/blob.go +0 -19
- package/database/plugin/blob/store.go +0 -40
- package/database/plugin/log.go +0 -27
- package/database/plugin/metadata/metadata.go +0 -19
- package/database/plugin/metadata/sqlite/account.go +0 -313
- package/database/plugin/metadata/sqlite/certs.go +0 -58
- package/database/plugin/metadata/sqlite/commit_timestamp.go +0 -68
- package/database/plugin/metadata/sqlite/database.go +0 -218
- package/database/plugin/metadata/sqlite/drep.go +0 -140
- package/database/plugin/metadata/sqlite/epoch.go +0 -120
- package/database/plugin/metadata/sqlite/models/account.go +0 -118
- package/database/plugin/metadata/sqlite/models/auth_committee_hot.go +0 -26
- package/database/plugin/metadata/sqlite/models/drep.go +0 -52
- package/database/plugin/metadata/sqlite/models/epoch.go +0 -31
- package/database/plugin/metadata/sqlite/models/models.go +0 -46
- package/database/plugin/metadata/sqlite/models/pool.go +0 -97
- package/database/plugin/metadata/sqlite/models/pparam_update.go +0 -27
- package/database/plugin/metadata/sqlite/models/pparams.go +0 -27
- package/database/plugin/metadata/sqlite/models/resign_committee_cold.go +0 -27
- package/database/plugin/metadata/sqlite/models/stake_vote_delegation.go +0 -27
- package/database/plugin/metadata/sqlite/models/tip.go +0 -26
- package/database/plugin/metadata/sqlite/models/update_drep.go +0 -27
- package/database/plugin/metadata/sqlite/models/utxo.go +0 -30
- package/database/plugin/metadata/sqlite/models/vote_delegation.go +0 -26
- package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +0 -15
- package/database/plugin/metadata/sqlite/pool.go +0 -240
- package/database/plugin/metadata/sqlite/pparams.go +0 -110
- package/database/plugin/metadata/sqlite/tip.go +0 -83
- package/database/plugin/metadata/sqlite/utxo.go +0 -292
- package/database/plugin/metadata/store.go +0 -198
- package/database/plugin/option.go +0 -190
- package/database/plugin/plugin.go +0 -20
- package/database/plugin/register.go +0 -118
- package/database/pparams.go +0 -145
- package/database/tip.go +0 -45
- package/database/txn.go +0 -147
- package/database/types/types.go +0 -74
- package/database/types/types_test.go +0 -83
- package/database/utxo.go +0 -263
- package/dist/artifacts.json +0 -1
- package/dist/checksums.txt +0 -22
- package/dist/config.yaml +0 -253
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz +0 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz.sbom.json +0 -1
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz.sbom.json +0 -1
- package/dist/dingo_darwin_amd64_v1/dingo +0 -0
- package/dist/dingo_darwin_arm64_v8.0/dingo +0 -0
- package/dist/dingo_linux_amd64_v1/dingo +0 -0
- package/dist/dingo_linux_arm64_v8.0/dingo +0 -0
- package/dist/homebrew/dingo.rb +0 -51
- package/dist/metadata.json +0 -1
- package/event/event.go +0 -141
- package/event/event_test.go +0 -115
- package/event/metrics.go +0 -44
- package/go.mod +0 -98
- package/go.sum +0 -358
- package/internal/config/config.go +0 -145
- package/internal/config/config_test.go +0 -118
- package/internal/node/load.go +0 -149
- package/internal/node/node.go +0 -176
- package/internal/version/version.go +0 -33
- package/ledger/certs.go +0 -164
- package/ledger/chainsync.go +0 -504
- package/ledger/delta.go +0 -99
- package/ledger/eras/allegra.go +0 -154
- package/ledger/eras/alonzo.go +0 -156
- package/ledger/eras/babbage.go +0 -154
- package/ledger/eras/byron.go +0 -42
- package/ledger/eras/conway.go +0 -166
- package/ledger/eras/eras.go +0 -44
- package/ledger/eras/mary.go +0 -154
- package/ledger/eras/shelley.go +0 -164
- package/ledger/error.go +0 -19
- package/ledger/event.go +0 -50
- package/ledger/metrics.go +0 -53
- package/ledger/queries.go +0 -258
- package/ledger/slot.go +0 -127
- package/ledger/slot_test.go +0 -147
- package/ledger/state.go +0 -821
- package/ledger/view.go +0 -73
- package/localstatequery.go +0 -50
- package/localtxmonitor.go +0 -44
- package/localtxsubmission.go +0 -52
- package/mempool/consumer.go +0 -98
- package/mempool/mempool.go +0 -322
- package/node.go +0 -320
- package/peergov/event.go +0 -27
- package/peergov/peer.go +0 -67
- package/peergov/peergov.go +0 -290
- package/peersharing.go +0 -70
- package/preview-local-topology.json +0 -23
- package/topology/topology.go +0 -69
- package/topology/topology_test.go +0 -179
- package/tracing.go +0 -65
- package/txsubmission.go +0 -233
- package/utxorpc/query.go +0 -311
- package/utxorpc/submit.go +0 -395
- package/utxorpc/sync.go +0 -276
- package/utxorpc/utxorpc.go +0 -166
- package/utxorpc/watch.go +0 -310
package/peersharing.go
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package dingo
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"net"
|
|
19
|
-
"strconv"
|
|
20
|
-
|
|
21
|
-
opeersharing "github.com/blinklabs-io/gouroboros/protocol/peersharing"
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
func (n *Node) peersharingServerConnOpts() []opeersharing.PeerSharingOptionFunc {
|
|
25
|
-
return []opeersharing.PeerSharingOptionFunc{
|
|
26
|
-
opeersharing.WithShareRequestFunc(n.peersharingShareRequest),
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
func (n *Node) peersharingClientConnOpts() []opeersharing.PeerSharingOptionFunc {
|
|
31
|
-
// We don't provide any client options, but we have this here for consistency
|
|
32
|
-
return []opeersharing.PeerSharingOptionFunc{}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func (n *Node) peersharingShareRequest(
|
|
36
|
-
ctx opeersharing.CallbackContext,
|
|
37
|
-
amount int,
|
|
38
|
-
) ([]opeersharing.PeerAddress, error) {
|
|
39
|
-
peers := []opeersharing.PeerAddress{}
|
|
40
|
-
var cnt int
|
|
41
|
-
for _, peer := range n.peerGov.GetPeers() {
|
|
42
|
-
cnt++
|
|
43
|
-
if cnt > amount {
|
|
44
|
-
break
|
|
45
|
-
}
|
|
46
|
-
if peer.Sharable {
|
|
47
|
-
host, port, err := net.SplitHostPort(peer.Address)
|
|
48
|
-
if err != nil {
|
|
49
|
-
// Skip on error
|
|
50
|
-
n.config.logger.Debug("failed to split peer address, skipping")
|
|
51
|
-
continue
|
|
52
|
-
}
|
|
53
|
-
portNum, err := strconv.ParseUint(port, 10, 16)
|
|
54
|
-
if err != nil {
|
|
55
|
-
// Skip on error
|
|
56
|
-
n.config.logger.Debug("failed to parse peer port, skipping")
|
|
57
|
-
continue
|
|
58
|
-
}
|
|
59
|
-
n.config.logger.Debug(
|
|
60
|
-
"adding peer for sharing: " + peer.Address,
|
|
61
|
-
)
|
|
62
|
-
peers = append(peers, opeersharing.PeerAddress{
|
|
63
|
-
IP: net.ParseIP(host),
|
|
64
|
-
Port: uint16(portNum),
|
|
65
|
-
},
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return peers, nil
|
|
70
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"bootstrapPeers": [
|
|
3
|
-
{
|
|
4
|
-
"address": "192.168.4.56",
|
|
5
|
-
"port": 3001
|
|
6
|
-
}
|
|
7
|
-
],
|
|
8
|
-
"localRoots": [
|
|
9
|
-
{
|
|
10
|
-
"accessPoints": [],
|
|
11
|
-
"advertise": false,
|
|
12
|
-
"trustable": false,
|
|
13
|
-
"valency": 1
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"publicRoots": [
|
|
17
|
-
{
|
|
18
|
-
"accessPoints": [],
|
|
19
|
-
"advertise": false
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"useLedgerAfterSlot": 53827185
|
|
23
|
-
}
|
package/topology/topology.go
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package topology
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"encoding/json"
|
|
19
|
-
"io"
|
|
20
|
-
"os"
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
// TopologyConfig represents a cardano-node topology config
|
|
24
|
-
type TopologyConfig struct {
|
|
25
|
-
LocalRoots []TopologyConfigP2PLocalRoot `json:"localRoots"`
|
|
26
|
-
PublicRoots []TopologyConfigP2PPublicRoot `json:"publicRoots"`
|
|
27
|
-
BootstrapPeers []TopologyConfigP2PBootstrapPeer `json:"bootstrapPeers"`
|
|
28
|
-
UseLedgerAfterSlot int64 `json:"useLedgerAfterSlot"`
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type TopologyConfigP2PAccessPoint struct {
|
|
32
|
-
Address string `json:"address"`
|
|
33
|
-
Port uint `json:"port"`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type TopologyConfigP2PLocalRoot struct {
|
|
37
|
-
AccessPoints []TopologyConfigP2PAccessPoint `json:"accessPoints"`
|
|
38
|
-
Advertise bool `json:"advertise"`
|
|
39
|
-
Trustable bool `json:"trustable"`
|
|
40
|
-
Valency uint `json:"valency"`
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type TopologyConfigP2PPublicRoot struct {
|
|
44
|
-
AccessPoints []TopologyConfigP2PAccessPoint `json:"accessPoints"`
|
|
45
|
-
Advertise bool `json:"advertise"`
|
|
46
|
-
Valency uint `json:"valency"`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type TopologyConfigP2PBootstrapPeer = TopologyConfigP2PAccessPoint
|
|
50
|
-
|
|
51
|
-
func NewTopologyConfigFromFile(path string) (*TopologyConfig, error) {
|
|
52
|
-
dataFile, err := os.Open(path)
|
|
53
|
-
if err != nil {
|
|
54
|
-
return nil, err
|
|
55
|
-
}
|
|
56
|
-
return NewTopologyConfigFromReader(dataFile)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
func NewTopologyConfigFromReader(r io.Reader) (*TopologyConfig, error) {
|
|
60
|
-
t := &TopologyConfig{}
|
|
61
|
-
data, err := io.ReadAll(r)
|
|
62
|
-
if err != nil {
|
|
63
|
-
return nil, err
|
|
64
|
-
}
|
|
65
|
-
if err := json.Unmarshal(data, t); err != nil {
|
|
66
|
-
return nil, err
|
|
67
|
-
}
|
|
68
|
-
return t, nil
|
|
69
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package topology_test
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"reflect"
|
|
19
|
-
"strings"
|
|
20
|
-
"testing"
|
|
21
|
-
|
|
22
|
-
"github.com/blinklabs-io/dingo/topology"
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
type topologyTestDefinition struct {
|
|
26
|
-
jsonData string
|
|
27
|
-
expectedObject *topology.TopologyConfig
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var topologyTests = []topologyTestDefinition{
|
|
31
|
-
{
|
|
32
|
-
jsonData: `
|
|
33
|
-
{
|
|
34
|
-
"localRoots": [
|
|
35
|
-
{
|
|
36
|
-
"accessPoints": [],
|
|
37
|
-
"advertise": false,
|
|
38
|
-
"valency": 1
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"publicRoots": [
|
|
42
|
-
{
|
|
43
|
-
"accessPoints": [
|
|
44
|
-
{
|
|
45
|
-
"address": "backbone.cardano.iog.io",
|
|
46
|
-
"port": 3001
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"advertise": false
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"accessPoints": [
|
|
53
|
-
{
|
|
54
|
-
"address": "backbone.mainnet.emurgornd.com",
|
|
55
|
-
"port": 3001
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"advertise": false
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"useLedgerAfterSlot": 99532743
|
|
62
|
-
}
|
|
63
|
-
`,
|
|
64
|
-
expectedObject: &topology.TopologyConfig{
|
|
65
|
-
LocalRoots: []topology.TopologyConfigP2PLocalRoot{
|
|
66
|
-
{
|
|
67
|
-
AccessPoints: []topology.TopologyConfigP2PAccessPoint{},
|
|
68
|
-
Advertise: false,
|
|
69
|
-
Valency: 1,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
PublicRoots: []topology.TopologyConfigP2PPublicRoot{
|
|
73
|
-
{
|
|
74
|
-
AccessPoints: []topology.TopologyConfigP2PAccessPoint{
|
|
75
|
-
{
|
|
76
|
-
Address: "backbone.cardano.iog.io",
|
|
77
|
-
Port: 3001,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
Advertise: false,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
AccessPoints: []topology.TopologyConfigP2PAccessPoint{
|
|
84
|
-
{
|
|
85
|
-
Address: "backbone.mainnet.emurgornd.com",
|
|
86
|
-
Port: 3001,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
Advertise: false,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
UseLedgerAfterSlot: 99532743,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
jsonData: `
|
|
97
|
-
{
|
|
98
|
-
"bootstrapPeers": [
|
|
99
|
-
{
|
|
100
|
-
"address": "backbone.cardano.iog.io",
|
|
101
|
-
"port": 3001
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"address": "backbone.mainnet.emurgornd.com",
|
|
105
|
-
"port": 3001
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"address": "backbone.mainnet.cardanofoundation.org",
|
|
109
|
-
"port": 3001
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
"localRoots": [
|
|
113
|
-
{
|
|
114
|
-
"accessPoints": [],
|
|
115
|
-
"advertise": false,
|
|
116
|
-
"trustable": false,
|
|
117
|
-
"valency": 1
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"publicRoots": [
|
|
121
|
-
{
|
|
122
|
-
"accessPoints": [],
|
|
123
|
-
"advertise": false
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
"useLedgerAfterSlot": 128908821
|
|
127
|
-
}
|
|
128
|
-
`,
|
|
129
|
-
expectedObject: &topology.TopologyConfig{
|
|
130
|
-
LocalRoots: []topology.TopologyConfigP2PLocalRoot{
|
|
131
|
-
{
|
|
132
|
-
AccessPoints: []topology.TopologyConfigP2PAccessPoint{},
|
|
133
|
-
Advertise: false,
|
|
134
|
-
Trustable: false,
|
|
135
|
-
Valency: 1,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
PublicRoots: []topology.TopologyConfigP2PPublicRoot{
|
|
139
|
-
{
|
|
140
|
-
AccessPoints: []topology.TopologyConfigP2PAccessPoint{},
|
|
141
|
-
Advertise: false,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
BootstrapPeers: []topology.TopologyConfigP2PBootstrapPeer{
|
|
145
|
-
{
|
|
146
|
-
Address: "backbone.cardano.iog.io",
|
|
147
|
-
Port: 3001,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
Address: "backbone.mainnet.emurgornd.com",
|
|
151
|
-
Port: 3001,
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
Address: "backbone.mainnet.cardanofoundation.org",
|
|
155
|
-
Port: 3001,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
UseLedgerAfterSlot: 128908821,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
func TestParseTopologyConfig(t *testing.T) {
|
|
164
|
-
for _, test := range topologyTests {
|
|
165
|
-
topology, err := topology.NewTopologyConfigFromReader(
|
|
166
|
-
strings.NewReader(test.jsonData),
|
|
167
|
-
)
|
|
168
|
-
if err != nil {
|
|
169
|
-
t.Fatalf("failed to load TopologyConfig from JSON data: %s", err)
|
|
170
|
-
}
|
|
171
|
-
if !reflect.DeepEqual(topology, test.expectedObject) {
|
|
172
|
-
t.Fatalf(
|
|
173
|
-
"did not get expected object\n got:\n %#v\n wanted:\n %#v",
|
|
174
|
-
topology,
|
|
175
|
-
test.expectedObject,
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
package/tracing.go
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package dingo
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"context"
|
|
19
|
-
"log/slog"
|
|
20
|
-
|
|
21
|
-
"go.opentelemetry.io/otel"
|
|
22
|
-
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
|
23
|
-
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
|
|
24
|
-
"go.opentelemetry.io/otel/propagation"
|
|
25
|
-
"go.opentelemetry.io/otel/sdk/trace"
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
func (n *Node) setupTracing() error {
|
|
29
|
-
// Set up propagator.
|
|
30
|
-
otel.SetTextMapPropagator(
|
|
31
|
-
propagation.NewCompositeTextMapPropagator(
|
|
32
|
-
propagation.TraceContext{},
|
|
33
|
-
propagation.Baggage{},
|
|
34
|
-
),
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
// Set up trace provider.
|
|
38
|
-
var traceExporter trace.SpanExporter
|
|
39
|
-
var err error
|
|
40
|
-
if n.config.tracingStdout {
|
|
41
|
-
traceExporter, err = stdouttrace.New(
|
|
42
|
-
stdouttrace.WithPrettyPrint(),
|
|
43
|
-
)
|
|
44
|
-
} else {
|
|
45
|
-
// TODO: make options configurable (#387)
|
|
46
|
-
traceExporter, err = otlptracehttp.New(context.TODO())
|
|
47
|
-
}
|
|
48
|
-
if err != nil {
|
|
49
|
-
return err
|
|
50
|
-
}
|
|
51
|
-
tracerProvider := trace.NewTracerProvider(
|
|
52
|
-
trace.WithBatcher(traceExporter),
|
|
53
|
-
)
|
|
54
|
-
n.shutdownFuncs = append(n.shutdownFuncs, tracerProvider.Shutdown)
|
|
55
|
-
otel.SetTracerProvider(tracerProvider)
|
|
56
|
-
otel.SetErrorHandler(
|
|
57
|
-
otel.ErrorHandlerFunc(
|
|
58
|
-
func(err error) {
|
|
59
|
-
slog.Error(err.Error())
|
|
60
|
-
},
|
|
61
|
-
),
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
return nil
|
|
65
|
-
}
|
package/txsubmission.go
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 Blink Labs Software
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
package dingo
|
|
16
|
-
|
|
17
|
-
import (
|
|
18
|
-
"encoding/hex"
|
|
19
|
-
"errors"
|
|
20
|
-
"fmt"
|
|
21
|
-
"math"
|
|
22
|
-
|
|
23
|
-
"github.com/blinklabs-io/dingo/mempool"
|
|
24
|
-
ouroboros "github.com/blinklabs-io/gouroboros"
|
|
25
|
-
"github.com/blinklabs-io/gouroboros/ledger"
|
|
26
|
-
"github.com/blinklabs-io/gouroboros/protocol/txsubmission"
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
const (
|
|
30
|
-
txsubmissionRequestTxIdsCount = 10 // Number of TxIds to request from peer at one time
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
func (n *Node) txsubmissionServerConnOpts() []txsubmission.TxSubmissionOptionFunc {
|
|
34
|
-
return []txsubmission.TxSubmissionOptionFunc{
|
|
35
|
-
txsubmission.WithInitFunc(n.txsubmissionServerInit),
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
func (n *Node) txsubmissionClientConnOpts() []txsubmission.TxSubmissionOptionFunc {
|
|
40
|
-
return []txsubmission.TxSubmissionOptionFunc{
|
|
41
|
-
txsubmission.WithRequestTxIdsFunc(n.txsubmissionClientRequestTxIds),
|
|
42
|
-
txsubmission.WithRequestTxsFunc(n.txsubmissionClientRequestTxs),
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
func (n *Node) txsubmissionClientStart(connId ouroboros.ConnectionId) error {
|
|
47
|
-
// Register mempool consumer
|
|
48
|
-
// We don't bother capturing the consumer because we can easily look it up later by connection ID
|
|
49
|
-
_ = n.mempool.AddConsumer(connId)
|
|
50
|
-
// Start TxSubmission loop
|
|
51
|
-
conn := n.connManager.GetConnectionById(connId)
|
|
52
|
-
if conn == nil {
|
|
53
|
-
return fmt.Errorf("failed to lookup connection ID: %s", connId.String())
|
|
54
|
-
}
|
|
55
|
-
conn.TxSubmission().Client.Init()
|
|
56
|
-
return nil
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
func (n *Node) txsubmissionServerInit(ctx txsubmission.CallbackContext) error {
|
|
60
|
-
// Start async loop to request transactions from the peer's mempool
|
|
61
|
-
go func() {
|
|
62
|
-
for {
|
|
63
|
-
// Request available TX IDs (era and TX hash) and sizes
|
|
64
|
-
// We make the request blocking to avoid looping on our side
|
|
65
|
-
txIds, err := ctx.Server.RequestTxIds(
|
|
66
|
-
true,
|
|
67
|
-
txsubmissionRequestTxIdsCount,
|
|
68
|
-
)
|
|
69
|
-
if err != nil {
|
|
70
|
-
n.config.logger.Error(
|
|
71
|
-
fmt.Sprintf(
|
|
72
|
-
"failed to get TxIds: %s",
|
|
73
|
-
err,
|
|
74
|
-
),
|
|
75
|
-
"component", "network",
|
|
76
|
-
"protocol", "tx-submission",
|
|
77
|
-
"role", "server",
|
|
78
|
-
"connection_id", ctx.ConnectionId.String(),
|
|
79
|
-
)
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
if len(txIds) > 0 {
|
|
83
|
-
// Unwrap inner TxId from TxIdAndSize
|
|
84
|
-
var requestTxIds []txsubmission.TxId
|
|
85
|
-
for _, txId := range txIds {
|
|
86
|
-
requestTxIds = append(requestTxIds, txId.TxId)
|
|
87
|
-
}
|
|
88
|
-
// Request TX content for TxIds from above
|
|
89
|
-
txs, err := ctx.Server.RequestTxs(requestTxIds)
|
|
90
|
-
if err != nil {
|
|
91
|
-
n.config.logger.Error(
|
|
92
|
-
fmt.Sprintf(
|
|
93
|
-
"failed to get Txs: %s",
|
|
94
|
-
err,
|
|
95
|
-
),
|
|
96
|
-
"component", "network",
|
|
97
|
-
"protocol", "tx-submission",
|
|
98
|
-
"role", "server",
|
|
99
|
-
"connection_id", ctx.ConnectionId.String(),
|
|
100
|
-
)
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
for _, txBody := range txs {
|
|
104
|
-
// Decode TX from CBOR
|
|
105
|
-
tx, err := ledger.NewTransactionFromCbor(
|
|
106
|
-
uint(txBody.EraId),
|
|
107
|
-
txBody.TxBody,
|
|
108
|
-
)
|
|
109
|
-
if err != nil {
|
|
110
|
-
n.config.logger.Error(
|
|
111
|
-
fmt.Sprintf(
|
|
112
|
-
"failed to parse transaction CBOR: %s",
|
|
113
|
-
err,
|
|
114
|
-
),
|
|
115
|
-
"component", "network",
|
|
116
|
-
"protocol", "tx-submission",
|
|
117
|
-
"role", "server",
|
|
118
|
-
"connection_id", ctx.ConnectionId.String(),
|
|
119
|
-
)
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
n.config.logger.Debug(
|
|
123
|
-
"received tx",
|
|
124
|
-
"tx_hash", tx.Hash(),
|
|
125
|
-
"protocol", "tx-submission",
|
|
126
|
-
"role", "server",
|
|
127
|
-
"connection_id", ctx.ConnectionId.String(),
|
|
128
|
-
)
|
|
129
|
-
// Add transaction to mempool
|
|
130
|
-
err = n.mempool.AddTransaction(
|
|
131
|
-
uint(txBody.EraId),
|
|
132
|
-
txBody.TxBody,
|
|
133
|
-
)
|
|
134
|
-
if err != nil {
|
|
135
|
-
n.config.logger.Error(
|
|
136
|
-
fmt.Sprintf(
|
|
137
|
-
"failed to add tx %x to mempool: %s",
|
|
138
|
-
tx.Hash(),
|
|
139
|
-
err,
|
|
140
|
-
),
|
|
141
|
-
"component", "network",
|
|
142
|
-
"protocol", "tx-submission",
|
|
143
|
-
"role", "server",
|
|
144
|
-
"connection_id", ctx.ConnectionId.String(),
|
|
145
|
-
)
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}()
|
|
152
|
-
return nil
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
func (n *Node) txsubmissionClientRequestTxIds(
|
|
156
|
-
ctx txsubmission.CallbackContext,
|
|
157
|
-
blocking bool,
|
|
158
|
-
ack uint16,
|
|
159
|
-
req uint16,
|
|
160
|
-
) ([]txsubmission.TxIdAndSize, error) {
|
|
161
|
-
connId := ctx.ConnectionId
|
|
162
|
-
ret := []txsubmission.TxIdAndSize{}
|
|
163
|
-
consumer := n.mempool.Consumer(connId)
|
|
164
|
-
// Clear TX cache
|
|
165
|
-
if ack > 0 {
|
|
166
|
-
consumer.ClearCache()
|
|
167
|
-
}
|
|
168
|
-
// Get available TXs
|
|
169
|
-
var tmpTxs []*mempool.MempoolTransaction
|
|
170
|
-
for {
|
|
171
|
-
if blocking && len(tmpTxs) == 0 {
|
|
172
|
-
// Wait until we see a TX
|
|
173
|
-
tmpTx := consumer.NextTx(true)
|
|
174
|
-
if tmpTx == nil {
|
|
175
|
-
break
|
|
176
|
-
}
|
|
177
|
-
tmpTxs = append(tmpTxs, tmpTx)
|
|
178
|
-
} else {
|
|
179
|
-
// Return immediately if no TX is available
|
|
180
|
-
tmpTx := consumer.NextTx(false)
|
|
181
|
-
if tmpTx == nil {
|
|
182
|
-
break
|
|
183
|
-
}
|
|
184
|
-
tmpTxs = append(tmpTxs, tmpTx)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
for _, tmpTx := range tmpTxs {
|
|
188
|
-
// Add to return value
|
|
189
|
-
txHashBytes, err := hex.DecodeString(tmpTx.Hash)
|
|
190
|
-
if err != nil {
|
|
191
|
-
return nil, err
|
|
192
|
-
}
|
|
193
|
-
txSize := len(tmpTx.Cbor)
|
|
194
|
-
if txSize > math.MaxUint32 {
|
|
195
|
-
return nil, errors.New("tx impossibly large")
|
|
196
|
-
}
|
|
197
|
-
ret = append(
|
|
198
|
-
ret,
|
|
199
|
-
txsubmission.TxIdAndSize{
|
|
200
|
-
TxId: txsubmission.TxId{
|
|
201
|
-
EraId: uint16(tmpTx.Type), // #nosec G115
|
|
202
|
-
TxId: [32]byte(txHashBytes),
|
|
203
|
-
},
|
|
204
|
-
Size: uint32(txSize),
|
|
205
|
-
},
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
return ret, nil
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
func (n *Node) txsubmissionClientRequestTxs(
|
|
212
|
-
ctx txsubmission.CallbackContext,
|
|
213
|
-
txIds []txsubmission.TxId,
|
|
214
|
-
) ([]txsubmission.TxBody, error) {
|
|
215
|
-
connId := ctx.ConnectionId
|
|
216
|
-
ret := []txsubmission.TxBody{}
|
|
217
|
-
consumer := n.mempool.Consumer(connId)
|
|
218
|
-
for _, txId := range txIds {
|
|
219
|
-
txHash := hex.EncodeToString(txId.TxId[:])
|
|
220
|
-
tx := consumer.GetTxFromCache(txHash)
|
|
221
|
-
if tx != nil {
|
|
222
|
-
ret = append(
|
|
223
|
-
ret,
|
|
224
|
-
txsubmission.TxBody{
|
|
225
|
-
EraId: uint16(tx.Type), // #nosec G115
|
|
226
|
-
TxBody: tx.Cbor,
|
|
227
|
-
},
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
consumer.RemoveTxFromCache(txHash)
|
|
231
|
-
}
|
|
232
|
-
return ret, nil
|
|
233
|
-
}
|