From 94d5dd912f40a07874340842ac21741363ca501a Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Sat, 1 Feb 2025 22:58:33 -0500 Subject: [PATCH] chore: update TODO comments with issue numbers --- blockfetch.go | 4 ++-- chainsync/chainsync.go | 8 ++++---- config.go | 1 - config/cardano/node.go | 9 ++++----- database/immutable/immutable_test.go | 2 +- internal/node/node.go | 4 ++-- localstatequery.go | 4 ++-- localtxmonitor.go | 2 +- mempool/mempool.go | 4 ++-- node.go | 4 ++-- peersharing.go | 5 ++--- state/chain.go | 4 ++-- state/metrics.go | 2 +- state/queries.go | 16 +++++----------- state/state.go | 5 ++--- tracing.go | 2 +- utxorpc/sync.go | 2 +- 17 files changed, 34 insertions(+), 44 deletions(-) diff --git a/blockfetch.go b/blockfetch.go index ac9cc1c..b39785e 100644 --- a/blockfetch.go +++ b/blockfetch.go @@ -49,7 +49,7 @@ func (n *Node) blockfetchServerRequestRange( start ocommon.Point, end ocommon.Point, ) error { - // TODO: check if we have requested block range available and send NoBlocks if not + // TODO: check if we have requested block range available and send NoBlocks if not (#397) chainIter, err := n.ledgerState.GetChainFromPoint(start, true) if err != nil { return err @@ -73,7 +73,7 @@ func (n *Node) blockfetchServerRequestRange( blockBytes, ) if err != nil { - // TODO: push this error somewhere + // TODO: push this error somewhere (#398) return } // Make sure we don't hang waiting for the next block if we've already hit the end diff --git a/chainsync/chainsync.go b/chainsync/chainsync.go index 40de662..f1aa4a6 100644 --- a/chainsync/chainsync.go +++ b/chainsync/chainsync.go @@ -36,7 +36,7 @@ type State struct { eventBus *event.EventBus ledgerState *state.LedgerState clients map[ouroboros.ConnectionId]*ChainsyncClientState - clientConnId *ouroboros.ConnectionId // TODO: replace with handling of multiple chainsync clients + clientConnId *ouroboros.ConnectionId // TODO: replace with handling of multiple chainsync clients (#385) } func NewState( @@ -79,17 +79,17 @@ func (s *State) RemoveClient(connId connection.ConnectionId) { delete(s.clients, connId) } -// TODO: replace with handling of multiple chainsync clients +// TODO: replace with handling of multiple chainsync clients (#385) func (s *State) GetClientConnId() *ouroboros.ConnectionId { return s.clientConnId } -// TODO: replace with handling of multiple chainsync clients +// TODO: replace with handling of multiple chainsync clients (#385) func (s *State) SetClientConnId(connId ouroboros.ConnectionId) { s.clientConnId = &connId } -// TODO: replace with handling of multiple chainsync clients +// TODO: replace with handling of multiple chainsync clients (#385) func (s *State) RemoveClientConnId(connId ouroboros.ConnectionId) { if s.clientConnId != nil && *s.clientConnId == connId { s.clientConnId = nil diff --git a/config.go b/config.go index beb1b15..50888b3 100644 --- a/config.go +++ b/config.go @@ -107,7 +107,6 @@ func NewConfig(opts ...ConfigOptionFunc) Config { // Default logger will throw away logs // We do this so we don't have to add guards around every log operation logger: slog.New(slog.NewJSONHandler(io.Discard, nil)), - // TODO: add defaults } // Apply options for _, opt := range opts { diff --git a/config/cardano/node.go b/config/cardano/node.go index 6b6249f..f61d1f8 100644 --- a/config/cardano/node.go +++ b/config/cardano/node.go @@ -41,7 +41,6 @@ type CardanoNodeConfig struct { shelleyGenesis *shelley.ShelleyGenesis ShelleyGenesisFile string `yaml:"ShelleyGenesisFile"` ShelleyGenesisHash string `yaml:"ShelleyGenesisHash"` - // TODO: add more fields from cardano-node config as we need them } func NewCardanoNodeConfigFromReader(r io.Reader) (*CardanoNodeConfig, error) { @@ -73,7 +72,7 @@ func (c *CardanoNodeConfig) loadGenesisConfigs() error { // Load Byron genesis if c.ByronGenesisFile != "" { byronGenesisPath := path.Join(c.path, c.ByronGenesisFile) - // TODO: check genesis file hash + // TODO: check genesis file hash (#399) byronGenesis, err := byron.NewByronGenesisFromFile(byronGenesisPath) if err != nil { return err @@ -83,7 +82,7 @@ func (c *CardanoNodeConfig) loadGenesisConfigs() error { // Load Shelley genesis if c.ShelleyGenesisFile != "" { shelleyGenesisPath := path.Join(c.path, c.ShelleyGenesisFile) - // TODO: check genesis file hash + // TODO: check genesis file hash (#399) shelleyGenesis, err := shelley.NewShelleyGenesisFromFile( shelleyGenesisPath, ) @@ -95,7 +94,7 @@ func (c *CardanoNodeConfig) loadGenesisConfigs() error { // Load Alonzo genesis if c.AlonzoGenesisFile != "" { alonzoGenesisPath := path.Join(c.path, c.AlonzoGenesisFile) - // TODO: check genesis file hash + // TODO: check genesis file hash (#399) alonzoGenesis, err := alonzo.NewAlonzoGenesisFromFile(alonzoGenesisPath) if err != nil { return err @@ -105,7 +104,7 @@ func (c *CardanoNodeConfig) loadGenesisConfigs() error { // Load Conway genesis if c.ConwayGenesisFile != "" { conwayGenesisPath := path.Join(c.path, c.ConwayGenesisFile) - // TODO: check genesis file hash + // TODO: check genesis file hash (#399) conwayGenesis, err := conway.NewConwayGenesisFromFile(conwayGenesisPath) if err != nil { return err diff --git a/database/immutable/immutable_test.go b/database/immutable/immutable_test.go index 54da5cc..d64bba8 100644 --- a/database/immutable/immutable_test.go +++ b/database/immutable/immutable_test.go @@ -56,4 +56,4 @@ func TestGetTip(t *testing.T) { } } -// TODO: add tests for getting a specific block and getting a range of blocks that traverses multiple chunks +// TODO: add tests for getting a specific block and getting a range of blocks that traverses multiple chunks (#386) diff --git a/internal/node/node.go b/internal/node/node.go index e0127f9..645e94b 100644 --- a/internal/node/node.go +++ b/internal/node/node.go @@ -39,7 +39,7 @@ func Run(logger *slog.Logger) error { fmt.Sprintf("topology: %+v", config.GetTopologyConfig()), "component", "node", ) - // TODO: make this safer, check PID, create parent, etc. + // TODO: make this safer, check PID, create parent, etc. (#276) if _, err := os.Stat(cfg.SocketPath); err == nil { os.Remove(cfg.SocketPath) } @@ -87,7 +87,7 @@ func Run(logger *slog.Logger) error { dingo.WithUtxorpcTlsKeyFilePath(cfg.TlsKeyFilePath), // Enable metrics with default prometheus registry dingo.WithPrometheusRegistry(prometheus.DefaultRegisterer), - // TODO: make this configurable + // TODO: make this configurable (#387) //dingo.WithTracing(true), dingo.WithTopologyConfig(config.GetTopologyConfig()), ), diff --git a/localstatequery.go b/localstatequery.go index d9aba00..0f22510 100644 --- a/localstatequery.go +++ b/localstatequery.go @@ -31,7 +31,7 @@ func (n *Node) localstatequeryServerAcquire( acquireTarget olocalstatequery.AcquireTarget, reAcquire bool, ) error { - // TODO: create "view" from ledger state + // TODO: create "view" from ledger state (#382) return nil } @@ -45,6 +45,6 @@ func (n *Node) localstatequeryServerQuery( func (n *Node) localstatequeryServerRelease( ctx olocalstatequery.CallbackContext, ) error { - // TODO: release "view" from ledger state + // TODO: release "view" from ledger state (#382) return nil } diff --git a/localtxmonitor.go b/localtxmonitor.go index 0e397ba..01e79cb 100644 --- a/localtxmonitor.go +++ b/localtxmonitor.go @@ -19,7 +19,7 @@ import ( ) const ( - localtxmonitorMempoolCapacity = 10 * 1024 * 1024 // TODO: replace with configurable value + localtxmonitorMempoolCapacity = 10 * 1024 * 1024 // TODO: replace with configurable value (#400) ) func (n *Node) localtxmonitorServerConnOpts() []olocaltxmonitor.LocalTxMonitorOptionFunc { diff --git a/mempool/mempool.go b/mempool/mempool.go index 20935b8..990f75a 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -87,7 +87,7 @@ func NewMempool( } else { m.logger = logger } - // TODO: replace this with purging based on on-chain TXs + // TODO: replace this with purging based on on-chain TXs (#388) // Schedule initial mempool expired cleanup m.scheduleRemoveExpired() // Init metrics @@ -165,7 +165,7 @@ func (m *Mempool) Consumer(connId ouroboros.ConnectionId) *MempoolConsumer { return m.consumers[connId] } -// TODO: replace this with purging based on on-chain TXs +// TODO: replace this with purging based on on-chain TXs (#388) func (m *Mempool) removeExpired() { m.Lock() defer m.Unlock() diff --git a/node.go b/node.go index 200ca56..cc2dee9 100644 --- a/node.go +++ b/node.go @@ -137,7 +137,7 @@ func (n *Node) Run() error { } func (n *Node) Stop() error { - // TODO: use a cancelable context and wait for it above to call shutdown + // TODO: use a cancelable context and wait for it above to call shutdown (#72) return n.shutdown() } @@ -288,7 +288,7 @@ func (n *Node) handleConnClosedEvent(evt event.Event) { func (n *Node) handleOutboundConnEvent(evt event.Event) { e := evt.Data.(peergov.OutboundConnectionEvent) connId := e.ConnectionId - // TODO: replace this with handling for multiple chainsync clients + // TODO: replace this with handling for multiple chainsync clients (#385) // Start chainsync client if we don't have another n.chainsyncState.Lock() defer n.chainsyncState.Unlock() diff --git a/peersharing.go b/peersharing.go index 61ffcba..e1bce80 100644 --- a/peersharing.go +++ b/peersharing.go @@ -29,9 +29,8 @@ func (n *Node) peersharingServerConnOpts() []opeersharing.PeerSharingOptionFunc } func (n *Node) peersharingClientConnOpts() []opeersharing.PeerSharingOptionFunc { - return []opeersharing.PeerSharingOptionFunc{ - // TODO - } + // We don't provide any client options, but we have this here for consistency + return []opeersharing.PeerSharingOptionFunc{} } func (n *Node) peersharingShareRequest( diff --git a/state/chain.go b/state/chain.go index d5d19de..3a5396d 100644 --- a/state/chain.go +++ b/state/chain.go @@ -105,7 +105,7 @@ func (ci *ChainIterator) Next(blocking bool) (*ChainIteratorResult, error) { select { case blockEvt, ok := <-blockChan: if !ok { - // TODO + // TODO: return an actual error (#389) return nil, nil } blockData := blockEvt.Data.(ChainBlockEvent) @@ -114,7 +114,7 @@ func (ci *ChainIterator) Next(blocking bool) (*ChainIteratorResult, error) { ci.blockNumber++ case rollbackEvt, ok := <-rollbackChan: if !ok { - // TODO + // TODO: return an actual error (#389) return nil, nil } rollbackData := rollbackEvt.Data.(ChainRollbackEvent) diff --git a/state/metrics.go b/state/metrics.go index 7fbe74f..8a6eaa1 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -33,7 +33,7 @@ func (m *stateMetrics) init(promRegistry prometheus.Registerer) { Name: "cardano_node_metrics_blockNum_int", Help: "current block number", }) - // TODO: figure out how to calculate this + // TODO: figure out how to calculate this (#390) m.density = promautoFactory.NewGauge(prometheus.GaugeOpts{ Name: "cardano_node_metrics_density_real", Help: "chain density", diff --git a/state/queries.go b/state/queries.go index 61f6d78..5eee9ff 100644 --- a/state/queries.go +++ b/state/queries.go @@ -63,7 +63,7 @@ func (ls *LedgerState) querySystemStart() (any, error) { func (ls *LedgerState) queryChainBlockNo() (any, error) { ret := []any{ - 1, // TODO: figure out what this value is + 1, // TODO: figure out what this value is (#393) ls.currentTip.BlockNumber, } return ret, nil @@ -79,7 +79,7 @@ func (ls *LedgerState) queryHardFork( switch q := query.Query.(type) { case *olocalstatequery.HardForkCurrentEraQuery: return ls.currentEra.Id, nil - // TODO + // TODO (#321) //case *olocalstatequery.HardForkEraHistoryQuery: default: return nil, fmt.Errorf("unsupported query type: %T", q) @@ -89,7 +89,6 @@ func (ls *LedgerState) queryHardFork( func (ls *LedgerState) queryShelley( query *olocalstatequery.ShelleyQuery, ) (any, error) { - // TODO: make these era-specific switch q := query.Query.(type) { case *olocalstatequery.ShelleyEpochNoQuery: return []any{ls.currentEpoch.EpochId}, nil @@ -101,24 +100,19 @@ func (ls *LedgerState) queryShelley( return ls.queryShelleyUtxoByAddress(q.Addrs) case *olocalstatequery.ShelleyUtxoByTxinQuery: return ls.queryShelleyUtxoByTxIn(q.TxIns) - // TODO + // TODO (#394) /* case *olocalstatequery.ShelleyLedgerTipQuery: - case *olocalstatequery.ShelleyEpochNoQuery: case *olocalstatequery.ShelleyNonMyopicMemberRewardsQuery: - case *olocalstatequery.ShelleyCurrentProtocolParamsQuery: case *olocalstatequery.ShelleyProposedProtocolParamsUpdatesQuery: case *olocalstatequery.ShelleyStakeDistributionQuery: - case *olocalstatequery.ShelleyUtxoByAddressQuery: case *olocalstatequery.ShelleyUtxoWholeQuery: case *olocalstatequery.ShelleyDebugEpochStateQuery: case *olocalstatequery.ShelleyCborQuery: case *olocalstatequery.ShelleyFilteredDelegationAndRewardAccountsQuery: - case *olocalstatequery.ShelleyGenesisConfigQuery: case *olocalstatequery.ShelleyDebugNewEpochStateQuery: case *olocalstatequery.ShelleyDebugChainDepStateQuery: case *olocalstatequery.ShelleyRewardProvenanceQuery: - case *olocalstatequery.ShelleyUtxoByTxinQuery: case *olocalstatequery.ShelleyStakePoolsQuery: case *olocalstatequery.ShelleyStakePoolParamsQuery: case *olocalstatequery.ShelleyRewardInfoPoolsQuery: @@ -140,7 +134,7 @@ func (ls *LedgerState) queryShelleyUtxoByAddress( addrs []ledger.Address, ) (any, error) { ret := make(map[olocalstatequery.UtxoId]ledger.TransactionOutput) - // TODO: support multiple addresses + // TODO: support multiple addresses (#391) utxos, err := models.UtxosByAddress(ls.db, addrs[0]) if err != nil { return nil, err @@ -163,7 +157,7 @@ func (ls *LedgerState) queryShelleyUtxoByTxIn( txIns []ledger.ShelleyTransactionInput, ) (any, error) { ret := make(map[olocalstatequery.UtxoId]ledger.TransactionOutput) - // TODO: support multiple TxIns + // TODO: support multiple TxIns (#392) utxo, err := models.UtxoByRef( ls.db, txIns[0].Id().Bytes(), diff --git a/state/state.go b/state/state.go index 4838f28..52f6f7f 100644 --- a/state/state.go +++ b/state/state.go @@ -39,7 +39,7 @@ import ( const ( cleanupConsumedUtxosInterval = 15 * time.Minute - cleanupConsumedUtxosSlotWindow = 50000 // TODO: calculate this from params + cleanupConsumedUtxosSlotWindow = 50000 // TODO: calculate this from params (#395) ) type LedgerStateConfig struct { @@ -163,7 +163,6 @@ func NewLedgerState(cfg LedgerStateConfig) (*LedgerState, error) { ) // Schedule periodic process to purge consumed UTxOs outside of the rollback window ls.scheduleCleanupConsumedUtxos() - // TODO: schedule process to scan/clean blob DB for keys that don't have a corresponding metadata DB entry // Load current epoch from DB if err := ls.loadEpoch(); err != nil { return nil, err @@ -492,7 +491,7 @@ func (ls *LedgerState) consumeUtxo( // Find UTxO utxo, err := models.UtxoByRefTxn(txn, utxoId.Id().Bytes(), utxoId.Index()) if err != nil { - // TODO: make this configurable? + // TODO: make this configurable? (#396) if err == gorm.ErrRecordNotFound { return nil } diff --git a/tracing.go b/tracing.go index fea6a80..32018b1 100644 --- a/tracing.go +++ b/tracing.go @@ -42,7 +42,7 @@ func (n *Node) setupTracing() error { stdouttrace.WithPrettyPrint(), ) } else { - // TODO: make options configurable + // TODO: make options configurable (#387) traceExporter, err = otlptracehttp.New(context.TODO()) } if err != nil { diff --git a/utxorpc/sync.go b/utxorpc/sync.go index fe9bb14..b5609c0 100644 --- a/utxorpc/sync.go +++ b/utxorpc/sync.go @@ -119,7 +119,7 @@ func (s *syncServiceServer) DumpHistory( point := s.utxorpc.config.LedgerState.Tip().Point points = append(points, point) } - // TODO: make this work + // TODO: make this work (#401) // if startToken != nil { // blockIdx := startToken.GetIndex() // blockHash := startToken.GetHash()