@blinklabs/dingo 0.6.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.
- package/.dockerignore +5 -0
- package/.github/CODEOWNERS +5 -0
- 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 +19 -0
- package/.github/dingo-20241210.png +0 -0
- package/.github/dingo.md +56 -0
- package/.github/workflows/ci-docker.yml +36 -0
- package/.github/workflows/conventional-commits.yml +17 -0
- package/.github/workflows/go-test.yml +29 -0
- package/.github/workflows/golangci-lint.yml +23 -0
- package/.github/workflows/publish.yml +207 -0
- package/.golangci.yml +71 -0
- package/Dockerfile +25 -0
- package/LICENSE +201 -0
- package/Makefile +53 -0
- package/README.md +150 -0
- package/blockfetch.go +144 -0
- package/chain/chain.go +504 -0
- package/chain/chain_test.go +468 -0
- package/chain/errors.go +80 -0
- package/chain/event.go +33 -0
- package/chain/iter.go +64 -0
- package/chainsync/chainsync.go +97 -0
- package/chainsync.go +223 -0
- package/cmd/dingo/load.go +52 -0
- package/cmd/dingo/main.go +118 -0
- package/cmd/dingo/serve.go +49 -0
- package/config/cardano/node.go +192 -0
- package/config/cardano/node_test.go +85 -0
- package/config/cardano/preview/README.md +4 -0
- package/config/cardano/preview/alonzo-genesis.json +196 -0
- package/config/cardano/preview/byron-genesis.json +117 -0
- package/config/cardano/preview/config.json +114 -0
- package/config/cardano/preview/conway-genesis.json +297 -0
- package/config/cardano/preview/shelley-genesis.json +68 -0
- package/config.go +245 -0
- package/connmanager/connection_manager.go +105 -0
- package/connmanager/connection_manager_test.go +185 -0
- package/connmanager/event.go +37 -0
- package/connmanager/listener.go +140 -0
- package/connmanager/outbound.go +93 -0
- package/connmanager/socket.go +55 -0
- package/connmanager/unix.go +78 -0
- package/custom-p2p-topology.json +24 -0
- package/custom-p2p-topology.json.backup +24 -0
- package/custom-p2p-topology.json.mainnet +37 -0
- package/database/account.go +138 -0
- package/database/block.go +362 -0
- package/database/certs.go +53 -0
- package/database/commit_timestamp.go +77 -0
- package/database/database.go +118 -0
- package/database/database_test.go +62 -0
- package/database/drep.go +27 -0
- package/database/epoch.go +121 -0
- package/database/immutable/chunk.go +182 -0
- package/database/immutable/immutable.go +350 -0
- package/database/immutable/immutable_test.go +59 -0
- package/database/immutable/primary.go +106 -0
- package/database/immutable/secondary.go +103 -0
- 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 +4 -0
- package/database/plugin/blob/badger/commit_timestamp.go +50 -0
- package/database/plugin/blob/badger/database.go +152 -0
- package/database/plugin/blob/badger/logger.go +63 -0
- package/database/plugin/blob/badger/metrics.go +98 -0
- package/database/plugin/blob/blob.go +19 -0
- package/database/plugin/blob/store.go +40 -0
- package/database/plugin/log.go +27 -0
- package/database/plugin/metadata/metadata.go +19 -0
- package/database/plugin/metadata/sqlite/account.go +224 -0
- package/database/plugin/metadata/sqlite/certs.go +58 -0
- package/database/plugin/metadata/sqlite/commit_timestamp.go +68 -0
- package/database/plugin/metadata/sqlite/database.go +218 -0
- package/database/plugin/metadata/sqlite/epoch.go +120 -0
- package/database/plugin/metadata/sqlite/models/account.go +81 -0
- package/database/plugin/metadata/sqlite/models/auth_committee_hot.go +26 -0
- package/database/plugin/metadata/sqlite/models/deregistration_drep.go +26 -0
- package/database/plugin/metadata/sqlite/models/drep.go +27 -0
- package/database/plugin/metadata/sqlite/models/epoch.go +31 -0
- package/database/plugin/metadata/sqlite/models/models.go +45 -0
- package/database/plugin/metadata/sqlite/models/pool.go +97 -0
- package/database/plugin/metadata/sqlite/models/pparam_update.go +27 -0
- package/database/plugin/metadata/sqlite/models/pparams.go +27 -0
- package/database/plugin/metadata/sqlite/models/registration_drep.go +28 -0
- package/database/plugin/metadata/sqlite/models/resign_committee_cold.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_registration_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_vote_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_vote_registration_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/tip.go +26 -0
- package/database/plugin/metadata/sqlite/models/update_drep.go +27 -0
- package/database/plugin/metadata/sqlite/models/utxo.go +30 -0
- package/database/plugin/metadata/sqlite/models/vote_delegation.go +26 -0
- package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +26 -0
- package/database/plugin/metadata/sqlite/pool.go +240 -0
- package/database/plugin/metadata/sqlite/pparams.go +110 -0
- package/database/plugin/metadata/sqlite/tip.go +83 -0
- package/database/plugin/metadata/sqlite/utxo.go +292 -0
- package/database/plugin/metadata/store.go +168 -0
- package/database/plugin/option.go +190 -0
- package/database/plugin/plugin.go +20 -0
- package/database/plugin/register.go +118 -0
- package/database/pparams.go +145 -0
- package/database/tip.go +45 -0
- package/database/txn.go +147 -0
- package/database/types/types.go +74 -0
- package/database/types/types_test.go +83 -0
- package/database/utxo.go +263 -0
- package/dist/artifacts.json +1 -0
- package/dist/checksums.txt +22 -0
- package/dist/config.yaml +253 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz +0 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz.sbom.json +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +51 -0
- package/dist/metadata.json +1 -0
- package/event/event.go +141 -0
- package/event/event_test.go +115 -0
- package/event/metrics.go +44 -0
- package/go.mod +98 -0
- package/go.sum +358 -0
- package/internal/config/config.go +145 -0
- package/internal/config/config_test.go +118 -0
- package/internal/node/load.go +149 -0
- package/internal/node/node.go +176 -0
- package/internal/version/version.go +33 -0
- package/ledger/certs.go +113 -0
- package/ledger/chainsync.go +578 -0
- package/ledger/eras/allegra.go +154 -0
- package/ledger/eras/alonzo.go +156 -0
- package/ledger/eras/babbage.go +154 -0
- package/ledger/eras/byron.go +42 -0
- package/ledger/eras/conway.go +158 -0
- package/ledger/eras/eras.go +44 -0
- package/ledger/eras/mary.go +154 -0
- package/ledger/eras/shelley.go +164 -0
- package/ledger/error.go +19 -0
- package/ledger/event.go +50 -0
- package/ledger/metrics.go +53 -0
- package/ledger/queries.go +260 -0
- package/ledger/slot.go +127 -0
- package/ledger/slot_test.go +147 -0
- package/ledger/state.go +726 -0
- package/ledger/view.go +73 -0
- package/localstatequery.go +50 -0
- package/localtxmonitor.go +44 -0
- package/localtxsubmission.go +52 -0
- package/mempool/consumer.go +98 -0
- package/mempool/mempool.go +322 -0
- package/node.go +320 -0
- package/package.json +33 -0
- package/peergov/event.go +27 -0
- package/peergov/peer.go +67 -0
- package/peergov/peergov.go +290 -0
- package/peersharing.go +70 -0
- package/preview-local-topology.json +23 -0
- package/topology/topology.go +69 -0
- package/topology/topology_test.go +179 -0
- package/tracing.go +65 -0
- package/txsubmission.go +233 -0
- package/utxorpc/query.go +311 -0
- package/utxorpc/submit.go +395 -0
- package/utxorpc/sync.go +276 -0
- package/utxorpc/utxorpc.go +166 -0
- package/utxorpc/watch.go +310 -0
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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/babbage"
|
|
26
|
+
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
27
|
+
"github.com/blinklabs-io/gouroboros/ledger/conway"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
var ConwayEraDesc = EraDesc{
|
|
31
|
+
Id: conway.EraIdConway,
|
|
32
|
+
Name: conway.EraNameConway,
|
|
33
|
+
DecodePParamsFunc: DecodePParamsConway,
|
|
34
|
+
DecodePParamsUpdateFunc: DecodePParamsUpdateConway,
|
|
35
|
+
PParamsUpdateFunc: PParamsUpdateConway,
|
|
36
|
+
HardForkFunc: HardForkConway,
|
|
37
|
+
EpochLengthFunc: EpochLengthShelley,
|
|
38
|
+
CalculateEtaVFunc: CalculateEtaVConway,
|
|
39
|
+
CertDepositFunc: CertDepositConway,
|
|
40
|
+
ValidateTxFunc: ValidateTxConway,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func DecodePParamsConway(data []byte) (lcommon.ProtocolParameters, error) {
|
|
44
|
+
var ret conway.ConwayProtocolParameters
|
|
45
|
+
if _, err := cbor.Decode(data, &ret); err != nil {
|
|
46
|
+
return nil, err
|
|
47
|
+
}
|
|
48
|
+
return &ret, nil
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func DecodePParamsUpdateConway(data []byte) (any, error) {
|
|
52
|
+
var ret conway.ConwayProtocolParameterUpdate
|
|
53
|
+
if _, err := cbor.Decode(data, &ret); err != nil {
|
|
54
|
+
return nil, err
|
|
55
|
+
}
|
|
56
|
+
return ret, nil
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func PParamsUpdateConway(
|
|
60
|
+
currentPParams lcommon.ProtocolParameters,
|
|
61
|
+
pparamsUpdate any,
|
|
62
|
+
) (lcommon.ProtocolParameters, error) {
|
|
63
|
+
conwayPParams, ok := currentPParams.(*conway.ConwayProtocolParameters)
|
|
64
|
+
if !ok {
|
|
65
|
+
return nil, fmt.Errorf(
|
|
66
|
+
"current PParams (%T) is not expected type",
|
|
67
|
+
currentPParams,
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
conwayPParamsUpdate, ok := pparamsUpdate.(conway.ConwayProtocolParameterUpdate)
|
|
71
|
+
if !ok {
|
|
72
|
+
return nil, fmt.Errorf(
|
|
73
|
+
"PParams update (%T) is not expected type",
|
|
74
|
+
pparamsUpdate,
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
conwayPParams.Update(&conwayPParamsUpdate)
|
|
78
|
+
return conwayPParams, nil
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func HardForkConway(
|
|
82
|
+
nodeConfig *cardano.CardanoNodeConfig,
|
|
83
|
+
prevPParams lcommon.ProtocolParameters,
|
|
84
|
+
) (lcommon.ProtocolParameters, error) {
|
|
85
|
+
babbagePParams, ok := prevPParams.(*babbage.BabbageProtocolParameters)
|
|
86
|
+
if !ok {
|
|
87
|
+
return nil, fmt.Errorf(
|
|
88
|
+
"previous PParams (%T) are not expected type",
|
|
89
|
+
prevPParams,
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
ret := conway.UpgradePParams(*babbagePParams)
|
|
93
|
+
conwayGenesis := nodeConfig.ConwayGenesis()
|
|
94
|
+
ret.UpdateFromGenesis(conwayGenesis)
|
|
95
|
+
return &ret, nil
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
func CalculateEtaVConway(
|
|
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().(*conway.ConwayBlockHeader)
|
|
111
|
+
if !ok {
|
|
112
|
+
return nil, errors.New("unexpected block type")
|
|
113
|
+
}
|
|
114
|
+
tmpNonce, err := lcommon.CalculateRollingNonce(
|
|
115
|
+
prevBlockNonce,
|
|
116
|
+
h.Body.VrfResult.Output,
|
|
117
|
+
)
|
|
118
|
+
if err != nil {
|
|
119
|
+
return nil, err
|
|
120
|
+
}
|
|
121
|
+
return tmpNonce.Bytes(), nil
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
func CertDepositConway(
|
|
125
|
+
cert lcommon.Certificate,
|
|
126
|
+
pp lcommon.ProtocolParameters,
|
|
127
|
+
) (uint64, error) {
|
|
128
|
+
tmpPparams, ok := pp.(*conway.ConwayProtocolParameters)
|
|
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.RegistrationCertificate:
|
|
136
|
+
return uint64(tmpPparams.KeyDeposit), nil
|
|
137
|
+
case *lcommon.StakeRegistrationCertificate:
|
|
138
|
+
return uint64(tmpPparams.KeyDeposit), nil
|
|
139
|
+
default:
|
|
140
|
+
return 0, nil
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
func ValidateTxConway(
|
|
145
|
+
tx lcommon.Transaction,
|
|
146
|
+
slot uint64,
|
|
147
|
+
ls lcommon.LedgerState,
|
|
148
|
+
pp lcommon.ProtocolParameters,
|
|
149
|
+
) error {
|
|
150
|
+
errs := []error{}
|
|
151
|
+
for _, validationFunc := range conway.UtxoValidationRules {
|
|
152
|
+
errs = append(
|
|
153
|
+
errs,
|
|
154
|
+
validationFunc(tx, slot, ls, pp),
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
return errors.Join(errs...)
|
|
158
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 eras
|
|
16
|
+
|
|
17
|
+
import (
|
|
18
|
+
"github.com/blinklabs-io/dingo/config/cardano"
|
|
19
|
+
"github.com/blinklabs-io/gouroboros/ledger"
|
|
20
|
+
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
type EraDesc struct {
|
|
24
|
+
Id uint
|
|
25
|
+
Name string
|
|
26
|
+
DecodePParamsFunc func([]byte) (lcommon.ProtocolParameters, error)
|
|
27
|
+
DecodePParamsUpdateFunc func([]byte) (any, error)
|
|
28
|
+
PParamsUpdateFunc func(lcommon.ProtocolParameters, any) (lcommon.ProtocolParameters, error)
|
|
29
|
+
HardForkFunc func(*cardano.CardanoNodeConfig, lcommon.ProtocolParameters) (lcommon.ProtocolParameters, error)
|
|
30
|
+
EpochLengthFunc func(*cardano.CardanoNodeConfig) (uint, uint, error)
|
|
31
|
+
CalculateEtaVFunc func(*cardano.CardanoNodeConfig, []byte, ledger.Block) ([]byte, error)
|
|
32
|
+
CertDepositFunc func(lcommon.Certificate, lcommon.ProtocolParameters) (uint64, error)
|
|
33
|
+
ValidateTxFunc func(lcommon.Transaction, uint64, lcommon.LedgerState, lcommon.ProtocolParameters) error
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var Eras = []EraDesc{
|
|
37
|
+
ByronEraDesc,
|
|
38
|
+
ShelleyEraDesc,
|
|
39
|
+
AllegraEraDesc,
|
|
40
|
+
MaryEraDesc,
|
|
41
|
+
AlonzoEraDesc,
|
|
42
|
+
BabbageEraDesc,
|
|
43
|
+
ConwayEraDesc,
|
|
44
|
+
}
|