@blinklabs/dingo 0.7.0 → 0.8.0

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.
Files changed (187) hide show
  1. package/.dingo/blob/000001.sst +0 -0
  2. package/.dingo/blob/000001.vlog +0 -0
  3. package/.dingo/blob/DISCARD +0 -0
  4. package/.dingo/blob/KEYREGISTRY +2 -0
  5. package/.dingo/blob/MANIFEST +0 -0
  6. package/.dingo/metadata.sqlite +0 -0
  7. package/.github/workflows/golangci-lint.yml +1 -1
  8. package/.github/workflows/publish.yml +1 -7
  9. package/README.md +2 -1
  10. package/{bin/dingo → dingo} +0 -0
  11. package/dingo.yaml.example +53 -0
  12. package/package.json +2 -2
  13. package/Dockerfile +0 -25
  14. package/Makefile +0 -53
  15. package/blockfetch.go +0 -144
  16. package/chain/chain.go +0 -504
  17. package/chain/chain_test.go +0 -468
  18. package/chain/errors.go +0 -80
  19. package/chain/event.go +0 -33
  20. package/chain/iter.go +0 -64
  21. package/chainsync/chainsync.go +0 -97
  22. package/chainsync.go +0 -223
  23. package/cmd/dingo/load.go +0 -52
  24. package/cmd/dingo/main.go +0 -118
  25. package/cmd/dingo/serve.go +0 -49
  26. package/config/cardano/node.go +0 -192
  27. package/config/cardano/node_test.go +0 -85
  28. package/config/cardano/preview/README.md +0 -4
  29. package/config/cardano/preview/alonzo-genesis.json +0 -196
  30. package/config/cardano/preview/byron-genesis.json +0 -117
  31. package/config/cardano/preview/config.json +0 -114
  32. package/config/cardano/preview/conway-genesis.json +0 -297
  33. package/config/cardano/preview/shelley-genesis.json +0 -68
  34. package/config.go +0 -245
  35. package/connmanager/connection_manager.go +0 -105
  36. package/connmanager/connection_manager_test.go +0 -185
  37. package/connmanager/event.go +0 -37
  38. package/connmanager/listener.go +0 -140
  39. package/connmanager/outbound.go +0 -93
  40. package/connmanager/socket.go +0 -55
  41. package/connmanager/unix.go +0 -78
  42. package/custom-p2p-topology.json +0 -24
  43. package/custom-p2p-topology.json.backup +0 -24
  44. package/custom-p2p-topology.json.mainnet +0 -37
  45. package/database/account.go +0 -180
  46. package/database/block.go +0 -362
  47. package/database/certs.go +0 -53
  48. package/database/commit_timestamp.go +0 -77
  49. package/database/database.go +0 -118
  50. package/database/database_test.go +0 -62
  51. package/database/drep.go +0 -47
  52. package/database/epoch.go +0 -121
  53. package/database/immutable/chunk.go +0 -182
  54. package/database/immutable/immutable.go +0 -350
  55. package/database/immutable/immutable_test.go +0 -59
  56. package/database/immutable/primary.go +0 -106
  57. package/database/immutable/secondary.go +0 -103
  58. package/database/immutable/testdata/08893.chunk +0 -0
  59. package/database/immutable/testdata/08893.primary +0 -0
  60. package/database/immutable/testdata/08893.secondary +0 -0
  61. package/database/immutable/testdata/08894.chunk +0 -0
  62. package/database/immutable/testdata/08894.primary +0 -0
  63. package/database/immutable/testdata/08894.secondary +0 -0
  64. package/database/immutable/testdata/README.md +0 -4
  65. package/database/plugin/blob/badger/commit_timestamp.go +0 -50
  66. package/database/plugin/blob/badger/database.go +0 -152
  67. package/database/plugin/blob/badger/logger.go +0 -63
  68. package/database/plugin/blob/badger/metrics.go +0 -98
  69. package/database/plugin/blob/blob.go +0 -19
  70. package/database/plugin/blob/store.go +0 -40
  71. package/database/plugin/log.go +0 -27
  72. package/database/plugin/metadata/metadata.go +0 -19
  73. package/database/plugin/metadata/sqlite/account.go +0 -313
  74. package/database/plugin/metadata/sqlite/certs.go +0 -58
  75. package/database/plugin/metadata/sqlite/commit_timestamp.go +0 -68
  76. package/database/plugin/metadata/sqlite/database.go +0 -218
  77. package/database/plugin/metadata/sqlite/drep.go +0 -140
  78. package/database/plugin/metadata/sqlite/epoch.go +0 -120
  79. package/database/plugin/metadata/sqlite/models/account.go +0 -118
  80. package/database/plugin/metadata/sqlite/models/auth_committee_hot.go +0 -26
  81. package/database/plugin/metadata/sqlite/models/drep.go +0 -52
  82. package/database/plugin/metadata/sqlite/models/epoch.go +0 -31
  83. package/database/plugin/metadata/sqlite/models/models.go +0 -46
  84. package/database/plugin/metadata/sqlite/models/pool.go +0 -97
  85. package/database/plugin/metadata/sqlite/models/pparam_update.go +0 -27
  86. package/database/plugin/metadata/sqlite/models/pparams.go +0 -27
  87. package/database/plugin/metadata/sqlite/models/resign_committee_cold.go +0 -27
  88. package/database/plugin/metadata/sqlite/models/stake_vote_delegation.go +0 -27
  89. package/database/plugin/metadata/sqlite/models/tip.go +0 -26
  90. package/database/plugin/metadata/sqlite/models/update_drep.go +0 -27
  91. package/database/plugin/metadata/sqlite/models/utxo.go +0 -30
  92. package/database/plugin/metadata/sqlite/models/vote_delegation.go +0 -26
  93. package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +0 -15
  94. package/database/plugin/metadata/sqlite/pool.go +0 -240
  95. package/database/plugin/metadata/sqlite/pparams.go +0 -110
  96. package/database/plugin/metadata/sqlite/tip.go +0 -83
  97. package/database/plugin/metadata/sqlite/utxo.go +0 -292
  98. package/database/plugin/metadata/store.go +0 -198
  99. package/database/plugin/option.go +0 -190
  100. package/database/plugin/plugin.go +0 -20
  101. package/database/plugin/register.go +0 -118
  102. package/database/pparams.go +0 -145
  103. package/database/tip.go +0 -45
  104. package/database/txn.go +0 -147
  105. package/database/types/types.go +0 -74
  106. package/database/types/types_test.go +0 -83
  107. package/database/utxo.go +0 -263
  108. package/dist/artifacts.json +0 -1
  109. package/dist/checksums.txt +0 -22
  110. package/dist/config.yaml +0 -253
  111. package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz +0 -0
  112. package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz.sbom.json +0 -1
  113. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz +0 -0
  114. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz.sbom.json +0 -1
  115. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz +0 -0
  116. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz.sbom.json +0 -1
  117. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk +0 -0
  118. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk.sbom.json +0 -1
  119. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb +0 -0
  120. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb.sbom.json +0 -1
  121. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm +0 -0
  122. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm.sbom.json +0 -1
  123. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk +0 -0
  124. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk.sbom.json +0 -1
  125. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb +0 -0
  126. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb.sbom.json +0 -1
  127. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm +0 -0
  128. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm.sbom.json +0 -1
  129. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz +0 -0
  130. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz.sbom.json +0 -1
  131. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz +0 -0
  132. package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz.sbom.json +0 -1
  133. package/dist/dingo_darwin_amd64_v1/dingo +0 -0
  134. package/dist/dingo_darwin_arm64_v8.0/dingo +0 -0
  135. package/dist/dingo_linux_amd64_v1/dingo +0 -0
  136. package/dist/dingo_linux_arm64_v8.0/dingo +0 -0
  137. package/dist/homebrew/dingo.rb +0 -51
  138. package/dist/metadata.json +0 -1
  139. package/event/event.go +0 -141
  140. package/event/event_test.go +0 -115
  141. package/event/metrics.go +0 -44
  142. package/go.mod +0 -98
  143. package/go.sum +0 -358
  144. package/internal/config/config.go +0 -145
  145. package/internal/config/config_test.go +0 -118
  146. package/internal/node/load.go +0 -149
  147. package/internal/node/node.go +0 -176
  148. package/internal/version/version.go +0 -33
  149. package/ledger/certs.go +0 -164
  150. package/ledger/chainsync.go +0 -504
  151. package/ledger/delta.go +0 -99
  152. package/ledger/eras/allegra.go +0 -154
  153. package/ledger/eras/alonzo.go +0 -156
  154. package/ledger/eras/babbage.go +0 -154
  155. package/ledger/eras/byron.go +0 -42
  156. package/ledger/eras/conway.go +0 -166
  157. package/ledger/eras/eras.go +0 -44
  158. package/ledger/eras/mary.go +0 -154
  159. package/ledger/eras/shelley.go +0 -164
  160. package/ledger/error.go +0 -19
  161. package/ledger/event.go +0 -50
  162. package/ledger/metrics.go +0 -53
  163. package/ledger/queries.go +0 -258
  164. package/ledger/slot.go +0 -127
  165. package/ledger/slot_test.go +0 -147
  166. package/ledger/state.go +0 -821
  167. package/ledger/view.go +0 -73
  168. package/localstatequery.go +0 -50
  169. package/localtxmonitor.go +0 -44
  170. package/localtxsubmission.go +0 -52
  171. package/mempool/consumer.go +0 -98
  172. package/mempool/mempool.go +0 -322
  173. package/node.go +0 -320
  174. package/peergov/event.go +0 -27
  175. package/peergov/peer.go +0 -67
  176. package/peergov/peergov.go +0 -290
  177. package/peersharing.go +0 -70
  178. package/preview-local-topology.json +0 -23
  179. package/topology/topology.go +0 -69
  180. package/topology/topology_test.go +0 -179
  181. package/tracing.go +0 -65
  182. package/txsubmission.go +0 -233
  183. package/utxorpc/query.go +0 -311
  184. package/utxorpc/submit.go +0 -395
  185. package/utxorpc/sync.go +0 -276
  186. package/utxorpc/utxorpc.go +0 -166
  187. package/utxorpc/watch.go +0 -310
package/ledger/delta.go DELETED
@@ -1,99 +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 ledger
16
-
17
- import (
18
- "fmt"
19
- "slices"
20
-
21
- "github.com/blinklabs-io/dingo/database"
22
- lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
23
- ocommon "github.com/blinklabs-io/gouroboros/protocol/common"
24
- )
25
-
26
- type LedgerDelta struct {
27
- Point ocommon.Point
28
- Produced []lcommon.Utxo
29
- Consumed []lcommon.TransactionInput
30
- PParamUpdateEpoch uint64
31
- PParamUpdates map[lcommon.Blake2b224]lcommon.ProtocolParameterUpdate
32
- Certificates []lcommon.Certificate
33
- }
34
-
35
- // nolint:unparam
36
- func (d *LedgerDelta) processTransaction(tx lcommon.Transaction) error {
37
- // Consumed UTxOs
38
- d.Consumed = slices.Concat(d.Consumed, tx.Consumed())
39
- // Produced UTxOs
40
- d.Produced = slices.Concat(d.Produced, tx.Produced())
41
- // Protocol parameter updates
42
- if updateEpoch, paramUpdates := tx.ProtocolParameterUpdates(); updateEpoch > 0 {
43
- d.PParamUpdateEpoch = updateEpoch
44
- if d.PParamUpdates == nil {
45
- d.PParamUpdates = make(
46
- map[lcommon.Blake2b224]lcommon.ProtocolParameterUpdate,
47
- )
48
- }
49
- for genesisHash, update := range paramUpdates {
50
- d.PParamUpdates[genesisHash] = update
51
- }
52
- }
53
- // Certificates
54
- d.Certificates = slices.Concat(d.Certificates, tx.Certificates())
55
- return nil
56
- }
57
-
58
- func (d *LedgerDelta) apply(ls *LedgerState, txn *database.Txn) error {
59
- // Process consumed UTxOs
60
- for _, consumed := range d.Consumed {
61
- if err := ls.consumeUtxo(txn, consumed, d.Point.Slot); err != nil {
62
- return fmt.Errorf("remove consumed UTxO: %w", err)
63
- }
64
- }
65
- // Process produced UTxOs
66
- for _, produced := range d.Produced {
67
- outAddr := produced.Output.Address()
68
- err := ls.db.NewUtxo(
69
- produced.Id.Id().Bytes(),
70
- produced.Id.Index(),
71
- d.Point.Slot,
72
- outAddr.PaymentKeyHash().Bytes(),
73
- outAddr.StakeKeyHash().Bytes(),
74
- produced.Output.Cbor(),
75
- txn,
76
- )
77
- if err != nil {
78
- return fmt.Errorf("add produced UTxO: %w", err)
79
- }
80
- }
81
- // Protocol parameter updates
82
- for genesisHash, update := range d.PParamUpdates {
83
- err := ls.db.SetPParamUpdate(
84
- genesisHash.Bytes(),
85
- update.Cbor(),
86
- d.Point.Slot,
87
- d.PParamUpdateEpoch,
88
- txn,
89
- )
90
- if err != nil {
91
- return fmt.Errorf("set pparam update: %w", err)
92
- }
93
- }
94
- // Certificates
95
- if err := ls.processTransactionCertificates(txn, d.Point, d.Certificates); err != nil {
96
- return fmt.Errorf("process transaction certificates: %w", err)
97
- }
98
- return nil
99
- }
@@ -1,154 +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 eras
16
-
17
- import (
18
- "encoding/hex"
19
- "errors"
20
- "fmt"
21
-
22
- "github.com/blinklabs-io/dingo/config/cardano"
23
- "github.com/blinklabs-io/gouroboros/cbor"
24
- "github.com/blinklabs-io/gouroboros/ledger"
25
- "github.com/blinklabs-io/gouroboros/ledger/allegra"
26
- lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
27
- "github.com/blinklabs-io/gouroboros/ledger/shelley"
28
- )
29
-
30
- var AllegraEraDesc = EraDesc{
31
- Id: allegra.EraIdAllegra,
32
- Name: allegra.EraNameAllegra,
33
- DecodePParamsFunc: DecodePParamsAllegra,
34
- DecodePParamsUpdateFunc: DecodePParamsUpdateAllegra,
35
- PParamsUpdateFunc: PParamsUpdateAllegra,
36
- HardForkFunc: HardForkAllegra,
37
- EpochLengthFunc: EpochLengthShelley,
38
- CalculateEtaVFunc: CalculateEtaVAllegra,
39
- CertDepositFunc: CertDepositAllegra,
40
- ValidateTxFunc: ValidateTxAllegra,
41
- }
42
-
43
- func DecodePParamsAllegra(data []byte) (lcommon.ProtocolParameters, error) {
44
- var ret allegra.AllegraProtocolParameters
45
- if _, err := cbor.Decode(data, &ret); err != nil {
46
- return nil, err
47
- }
48
- return &ret, nil
49
- }
50
-
51
- func DecodePParamsUpdateAllegra(data []byte) (any, error) {
52
- var ret allegra.AllegraProtocolParameterUpdate
53
- if _, err := cbor.Decode(data, &ret); err != nil {
54
- return nil, err
55
- }
56
- return ret, nil
57
- }
58
-
59
- func PParamsUpdateAllegra(
60
- currentPParams lcommon.ProtocolParameters,
61
- pparamsUpdate any,
62
- ) (lcommon.ProtocolParameters, error) {
63
- allegraPParams, ok := currentPParams.(*allegra.AllegraProtocolParameters)
64
- if !ok {
65
- return nil, fmt.Errorf(
66
- "current PParams (%T) is not expected type",
67
- currentPParams,
68
- )
69
- }
70
- allegraPParamsUpdate, ok := pparamsUpdate.(allegra.AllegraProtocolParameterUpdate)
71
- if !ok {
72
- return nil, fmt.Errorf(
73
- "PParams update (%T) is not expected type",
74
- pparamsUpdate,
75
- )
76
- }
77
- allegraPParams.Update(&allegraPParamsUpdate)
78
- return allegraPParams, nil
79
- }
80
-
81
- func HardForkAllegra(
82
- nodeConfig *cardano.CardanoNodeConfig,
83
- prevPParams lcommon.ProtocolParameters,
84
- ) (lcommon.ProtocolParameters, error) {
85
- shelleyPParams, ok := prevPParams.(*shelley.ShelleyProtocolParameters)
86
- if !ok {
87
- return nil, fmt.Errorf(
88
- "previous PParams (%T) are not expected type",
89
- prevPParams,
90
- )
91
- }
92
- ret := allegra.UpgradePParams(*shelleyPParams)
93
- return &ret, nil
94
- }
95
-
96
- func CalculateEtaVAllegra(
97
- nodeConfig *cardano.CardanoNodeConfig,
98
- prevBlockNonce []byte,
99
- block ledger.Block,
100
- ) ([]byte, error) {
101
- if len(prevBlockNonce) == 0 {
102
- tmpNonce, err := hex.DecodeString(nodeConfig.ShelleyGenesisHash)
103
- if err != nil {
104
- return nil, err
105
- }
106
- prevBlockNonce = tmpNonce
107
- }
108
- h, ok := block.Header().(*allegra.AllegraBlockHeader)
109
- if !ok {
110
- return nil, errors.New("unexpected block type")
111
- }
112
- tmpNonce, err := lcommon.CalculateRollingNonce(
113
- prevBlockNonce,
114
- h.Body.NonceVrf.Output,
115
- )
116
- if err != nil {
117
- return nil, err
118
- }
119
- return tmpNonce.Bytes(), nil
120
- }
121
-
122
- func CertDepositAllegra(
123
- cert lcommon.Certificate,
124
- pp lcommon.ProtocolParameters,
125
- ) (uint64, error) {
126
- tmpPparams, ok := pp.(*allegra.AllegraProtocolParameters)
127
- if !ok {
128
- return 0, errors.New("pparams are not expected type")
129
- }
130
- switch cert.(type) {
131
- case *lcommon.PoolRegistrationCertificate:
132
- return uint64(tmpPparams.PoolDeposit), nil
133
- case *lcommon.StakeRegistrationCertificate:
134
- return uint64(tmpPparams.KeyDeposit), nil
135
- default:
136
- return 0, nil
137
- }
138
- }
139
-
140
- func ValidateTxAllegra(
141
- tx lcommon.Transaction,
142
- slot uint64,
143
- ls lcommon.LedgerState,
144
- pp lcommon.ProtocolParameters,
145
- ) error {
146
- errs := []error{}
147
- for _, validationFunc := range allegra.UtxoValidationRules {
148
- errs = append(
149
- errs,
150
- validationFunc(tx, slot, ls, pp),
151
- )
152
- }
153
- return errors.Join(errs...)
154
- }
@@ -1,156 +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 eras
16
-
17
- import (
18
- "encoding/hex"
19
- "errors"
20
- "fmt"
21
-
22
- "github.com/blinklabs-io/dingo/config/cardano"
23
- "github.com/blinklabs-io/gouroboros/cbor"
24
- "github.com/blinklabs-io/gouroboros/ledger"
25
- "github.com/blinklabs-io/gouroboros/ledger/alonzo"
26
- lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
27
- "github.com/blinklabs-io/gouroboros/ledger/mary"
28
- )
29
-
30
- var AlonzoEraDesc = EraDesc{
31
- Id: alonzo.EraIdAlonzo,
32
- Name: alonzo.EraNameAlonzo,
33
- DecodePParamsFunc: DecodePParamsAlonzo,
34
- DecodePParamsUpdateFunc: DecodePParamsUpdateAlonzo,
35
- PParamsUpdateFunc: PParamsUpdateAlonzo,
36
- HardForkFunc: HardForkAlonzo,
37
- EpochLengthFunc: EpochLengthShelley,
38
- CalculateEtaVFunc: CalculateEtaVAlonzo,
39
- CertDepositFunc: CertDepositAlonzo,
40
- ValidateTxFunc: ValidateTxAlonzo,
41
- }
42
-
43
- func DecodePParamsAlonzo(data []byte) (lcommon.ProtocolParameters, error) {
44
- var ret alonzo.AlonzoProtocolParameters
45
- if _, err := cbor.Decode(data, &ret); err != nil {
46
- return nil, err
47
- }
48
- return &ret, nil
49
- }
50
-
51
- func DecodePParamsUpdateAlonzo(data []byte) (any, error) {
52
- var ret alonzo.AlonzoProtocolParameterUpdate
53
- if _, err := cbor.Decode(data, &ret); err != nil {
54
- return nil, err
55
- }
56
- return ret, nil
57
- }
58
-
59
- func PParamsUpdateAlonzo(
60
- currentPParams lcommon.ProtocolParameters,
61
- pparamsUpdate any,
62
- ) (lcommon.ProtocolParameters, error) {
63
- alonzoPParams, ok := currentPParams.(*alonzo.AlonzoProtocolParameters)
64
- if !ok {
65
- return nil, fmt.Errorf(
66
- "current PParams (%T) is not expected type",
67
- currentPParams,
68
- )
69
- }
70
- alonzoPParamsUpdate, ok := pparamsUpdate.(alonzo.AlonzoProtocolParameterUpdate)
71
- if !ok {
72
- return nil, fmt.Errorf(
73
- "PParams update (%T) is not expected type",
74
- pparamsUpdate,
75
- )
76
- }
77
- alonzoPParams.Update(&alonzoPParamsUpdate)
78
- return alonzoPParams, nil
79
- }
80
-
81
- func HardForkAlonzo(
82
- nodeConfig *cardano.CardanoNodeConfig,
83
- prevPParams lcommon.ProtocolParameters,
84
- ) (lcommon.ProtocolParameters, error) {
85
- maryPParams, ok := prevPParams.(*mary.MaryProtocolParameters)
86
- if !ok {
87
- return nil, fmt.Errorf(
88
- "previous PParams (%T) are not expected type",
89
- prevPParams,
90
- )
91
- }
92
- ret := alonzo.UpgradePParams(*maryPParams)
93
- alonzoGenesis := nodeConfig.AlonzoGenesis()
94
- ret.UpdateFromGenesis(alonzoGenesis)
95
- return &ret, nil
96
- }
97
-
98
- func CalculateEtaVAlonzo(
99
- nodeConfig *cardano.CardanoNodeConfig,
100
- prevBlockNonce []byte,
101
- block ledger.Block,
102
- ) ([]byte, error) {
103
- if len(prevBlockNonce) == 0 {
104
- tmpNonce, err := hex.DecodeString(nodeConfig.ShelleyGenesisHash)
105
- if err != nil {
106
- return nil, err
107
- }
108
- prevBlockNonce = tmpNonce
109
- }
110
- h, ok := block.Header().(*alonzo.AlonzoBlockHeader)
111
- if !ok {
112
- return nil, errors.New("unexpected block type")
113
- }
114
- tmpNonce, err := lcommon.CalculateRollingNonce(
115
- prevBlockNonce,
116
- h.Body.NonceVrf.Output,
117
- )
118
- if err != nil {
119
- return nil, err
120
- }
121
- return tmpNonce.Bytes(), nil
122
- }
123
-
124
- func CertDepositAlonzo(
125
- cert lcommon.Certificate,
126
- pp lcommon.ProtocolParameters,
127
- ) (uint64, error) {
128
- tmpPparams, ok := pp.(*alonzo.AlonzoProtocolParameters)
129
- if !ok {
130
- return 0, errors.New("pparams are not expected type")
131
- }
132
- switch cert.(type) {
133
- case *lcommon.PoolRegistrationCertificate:
134
- return uint64(tmpPparams.PoolDeposit), nil
135
- case *lcommon.StakeRegistrationCertificate:
136
- return uint64(tmpPparams.KeyDeposit), nil
137
- default:
138
- return 0, nil
139
- }
140
- }
141
-
142
- func ValidateTxAlonzo(
143
- tx lcommon.Transaction,
144
- slot uint64,
145
- ls lcommon.LedgerState,
146
- pp lcommon.ProtocolParameters,
147
- ) error {
148
- errs := []error{}
149
- for _, validationFunc := range alonzo.UtxoValidationRules {
150
- errs = append(
151
- errs,
152
- validationFunc(tx, slot, ls, pp),
153
- )
154
- }
155
- return errors.Join(errs...)
156
- }
@@ -1,154 +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 eras
16
-
17
- import (
18
- "encoding/hex"
19
- "errors"
20
- "fmt"
21
-
22
- "github.com/blinklabs-io/dingo/config/cardano"
23
- "github.com/blinklabs-io/gouroboros/cbor"
24
- "github.com/blinklabs-io/gouroboros/ledger"
25
- "github.com/blinklabs-io/gouroboros/ledger/alonzo"
26
- "github.com/blinklabs-io/gouroboros/ledger/babbage"
27
- lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
28
- )
29
-
30
- var BabbageEraDesc = EraDesc{
31
- Id: babbage.EraIdBabbage,
32
- Name: babbage.EraNameBabbage,
33
- DecodePParamsFunc: DecodePParamsBabbage,
34
- DecodePParamsUpdateFunc: DecodePParamsUpdateBabbage,
35
- PParamsUpdateFunc: PParamsUpdateBabbage,
36
- HardForkFunc: HardForkBabbage,
37
- EpochLengthFunc: EpochLengthShelley,
38
- CalculateEtaVFunc: CalculateEtaVBabbage,
39
- CertDepositFunc: CertDepositBabbage,
40
- ValidateTxFunc: ValidateTxBabbage,
41
- }
42
-
43
- func DecodePParamsBabbage(data []byte) (lcommon.ProtocolParameters, error) {
44
- var ret babbage.BabbageProtocolParameters
45
- if _, err := cbor.Decode(data, &ret); err != nil {
46
- return nil, err
47
- }
48
- return &ret, nil
49
- }
50
-
51
- func DecodePParamsUpdateBabbage(data []byte) (any, error) {
52
- var ret babbage.BabbageProtocolParameterUpdate
53
- if _, err := cbor.Decode(data, &ret); err != nil {
54
- return nil, err
55
- }
56
- return ret, nil
57
- }
58
-
59
- func PParamsUpdateBabbage(
60
- currentPParams lcommon.ProtocolParameters,
61
- pparamsUpdate any,
62
- ) (lcommon.ProtocolParameters, error) {
63
- babbagePParams, ok := currentPParams.(*babbage.BabbageProtocolParameters)
64
- if !ok {
65
- return nil, fmt.Errorf(
66
- "current PParams (%T) is not expected type",
67
- currentPParams,
68
- )
69
- }
70
- babbagePParamsUpdate, ok := pparamsUpdate.(babbage.BabbageProtocolParameterUpdate)
71
- if !ok {
72
- return nil, fmt.Errorf(
73
- "PParams update (%T) is not expected type",
74
- pparamsUpdate,
75
- )
76
- }
77
- babbagePParams.Update(&babbagePParamsUpdate)
78
- return babbagePParams, nil
79
- }
80
-
81
- func HardForkBabbage(
82
- nodeConfig *cardano.CardanoNodeConfig,
83
- prevPParams lcommon.ProtocolParameters,
84
- ) (lcommon.ProtocolParameters, error) {
85
- alonzoPParams, ok := prevPParams.(*alonzo.AlonzoProtocolParameters)
86
- if !ok {
87
- return nil, fmt.Errorf(
88
- "previous PParams (%T) are not expected type",
89
- prevPParams,
90
- )
91
- }
92
- ret := babbage.UpgradePParams(*alonzoPParams)
93
- return &ret, nil
94
- }
95
-
96
- func CalculateEtaVBabbage(
97
- nodeConfig *cardano.CardanoNodeConfig,
98
- prevBlockNonce []byte,
99
- block ledger.Block,
100
- ) ([]byte, error) {
101
- if len(prevBlockNonce) == 0 {
102
- tmpNonce, err := hex.DecodeString(nodeConfig.ShelleyGenesisHash)
103
- if err != nil {
104
- return nil, err
105
- }
106
- prevBlockNonce = tmpNonce
107
- }
108
- h, ok := block.Header().(*babbage.BabbageBlockHeader)
109
- if !ok {
110
- return nil, errors.New("unexpected block type")
111
- }
112
- tmpNonce, err := lcommon.CalculateRollingNonce(
113
- prevBlockNonce,
114
- h.Body.VrfResult.Output,
115
- )
116
- if err != nil {
117
- return nil, err
118
- }
119
- return tmpNonce.Bytes(), nil
120
- }
121
-
122
- func CertDepositBabbage(
123
- cert lcommon.Certificate,
124
- pp lcommon.ProtocolParameters,
125
- ) (uint64, error) {
126
- tmpPparams, ok := pp.(*babbage.BabbageProtocolParameters)
127
- if !ok {
128
- return 0, errors.New("pparams are not expected type")
129
- }
130
- switch cert.(type) {
131
- case *lcommon.PoolRegistrationCertificate:
132
- return uint64(tmpPparams.PoolDeposit), nil
133
- case *lcommon.StakeRegistrationCertificate:
134
- return uint64(tmpPparams.KeyDeposit), nil
135
- default:
136
- return 0, nil
137
- }
138
- }
139
-
140
- func ValidateTxBabbage(
141
- tx lcommon.Transaction,
142
- slot uint64,
143
- ls lcommon.LedgerState,
144
- pp lcommon.ProtocolParameters,
145
- ) error {
146
- errs := []error{}
147
- for _, validationFunc := range babbage.UtxoValidationRules {
148
- errs = append(
149
- errs,
150
- validationFunc(tx, slot, ls, pp),
151
- )
152
- }
153
- return errors.Join(errs...)
154
- }
@@ -1,42 +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 eras
16
-
17
- import (
18
- "errors"
19
-
20
- "github.com/blinklabs-io/dingo/config/cardano"
21
- "github.com/blinklabs-io/gouroboros/ledger/byron"
22
- )
23
-
24
- var ByronEraDesc = EraDesc{
25
- Id: byron.EraIdByron,
26
- Name: byron.EraNameByron,
27
- EpochLengthFunc: EpochLengthByron,
28
- }
29
-
30
- func EpochLengthByron(
31
- nodeConfig *cardano.CardanoNodeConfig,
32
- ) (uint, uint, error) {
33
- byronGenesis := nodeConfig.ByronGenesis()
34
- if byronGenesis == nil {
35
- return 0, 0, errors.New("unable to get byron genesis")
36
- }
37
- // These are known to be within uint range
38
- // #nosec G115
39
- return uint(byronGenesis.BlockVersionData.SlotDuration),
40
- uint(byronGenesis.ProtocolConsts.K * 10),
41
- nil
42
- }