Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

mempool.TransactionMetadata.Inputs().ForEach broken because of genesis slot #528

Closed
muXxer opened this issue Nov 16, 2023 · 0 comments · Fixed by #529
Closed

mempool.TransactionMetadata.Inputs().ForEach broken because of genesis slot #528

muXxer opened this issue Nov 16, 2023 · 0 comments · Fixed by #529
Labels
bug Something isn't working
Milestone

Comments

@muXxer
Copy link
Collaborator

muXxer commented Nov 16, 2023

I guess the change with the genesis slot broke the network. when the evil spammer starts to spam (I don't know what exactly is spammed), the inx server in the valdiator node throws the following error:

docker-network-node-1-validator-1  | 2023-11-16T14:36:56Z       ERROR   INX     [email protected]/component.go:115 error creating payload: commitment is before genesis: slot 0 is before genesis slot 5: failed to load commitment with slot: 0

The only code part where this error is thrown is here:

func (c *Commitments) Load(slot iotago.SlotIndex) (commitment *model.Commitment, err error) {
	genesisSlot := c.apiProvider.CommittedAPI().ProtocolParameters().GenesisSlot()
	if slot < genesisSlot {
		return nil, ierrors.Wrapf(ErrCommitmentBeforeGenesis, "slot %d is before genesis slot %d", slot, genesisSlot)
	}

	return c.store.Get(slot)
}

but I don't even understand how this is actually called from here where the error is thrown in the end:

		var consumed []*inx.LedgerSpent
		if err := transactionMetadata.Inputs().ForEach(func(stateMetadata mempool.StateMetadata) error {
			spentOutput, ok := stateMetadata.State().(*utxoledger.Output)
			if !ok {
				return ierrors.Errorf("unexpected state metadata type: %T", stateMetadata.State())
			}

			inxSpent, err := NewLedgerSpent(utxoledger.NewSpent(spentOutput, transactionMetadata.ID(), slot))
			if err != nil {
				return err
			}
			consumed = append(consumed, inxSpent)

			return nil
		}); err != nil {
			Component.LogErrorf("error creating payload: %v", err)
			cancel()
		}

I mean the ForEach does that magically, but my IDE can't follow because of all the funny interfaces and generics and whatnot.
Anyway, should it even be possible in the first place that something got included in the Inputs that breaks the Call to ForEach?
This breaks the network because the inx-indexer doesn't get updates via INX this way.

@muXxer muXxer added this to iota-core Nov 16, 2023
@muXxer muXxer converted this from a draft issue Nov 16, 2023
@muXxer muXxer added the bug Something isn't working label Nov 16, 2023
@muXxer muXxer added this to the 1.0 RC milestone Nov 16, 2023
@alexsporn alexsporn linked a pull request Nov 16, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from Backlog to Done in iota-core Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant