iotaledger / iri

IOTA Reference Implementation
Other
1.15k stars 370 forks source link

latestSolidSubtangleMiletoneIndex does not update in getNodeInfo #585

Open footloosejava opened 6 years ago

footloosejava commented 6 years ago

With latest dev build:

latestSolidSubtangleMiletoneIndex does not update in 'getNodeInfo' until a system restart it updates. It just stays the same until a restart.

Very annoying ...

gjeee commented 6 years ago

this looks more like you are really lagging milestone wise......are u properly synced? do u have proper (mutually tethered) neighbors?

i also saw your null pointer issue ...this also had to do with neighbors (sockets throwing null).....so i think it is related.

are your tcp and udp ports open (default 14600 and 15600)

????

footloosejava commented 6 years ago

Maybe I didn't make it clear. After a program restart the latestSolidSubtangleMiletoneIndex updates to the correct state that was not showing properly beforehand in the API response.

From what I can tell, it is a bug in the system. Otherwise, how does a stop-start fix the problem?

Nick2bad4u commented 6 years ago

Im having the same issue due to neighbors taking all my resouces:

@footloosejava see here I just reported this issue: ----> #586

Araknai commented 6 years ago

I'm seeing this too.

My node was in sync for a good 2 weeks and then I restarted and it's been doing this ever since; about a week ago. I restart iri once a day now hoping it'll start incrementing the LSSMI but it only moves up when I restart iri; then gets stuck at that value immediately (typically 10 behind the current LMI). My node is not resource constrained whatsoever and is tracking the LMI just fine.

Nick2bad4u commented 6 years ago

@Araknai Try restarting with the rescan option. That worked for me.

footloosejava commented 6 years ago

latestSolidSubtangleMiletoneIndex

There are only two places where this updates in code:

(1) The first time is in the init() function of the LedgerValidator.

(2) Ongoing - the Milestone.java "Solid Milestone Tracker" thread that runs every 5 seconds, this should be updated ... but it isn't for some reason.

    void updateLatestSolidSubtangleMilestone() throws Exception {
        MilestoneViewModel milestoneViewModel;
        MilestoneViewModel latest = MilestoneViewModel.latest(tangle);
        if (latest != null) {
            for (milestoneViewModel = MilestoneViewModel.findClosestNextMilestone(tangle, latestSolidSubtangleMilestoneIndex);
                 milestoneViewModel != null && milestoneViewModel.index() <= latest.index() && !shuttingDown;
                 milestoneViewModel = milestoneViewModel.next(tangle)) {
                if (transactionValidator.checkSolidity(milestoneViewModel.getHash(), true) &&
                        milestoneViewModel.index() >= latestSolidSubtangleMilestoneIndex &&
                        ledgerValidator.updateSnapshot(milestoneViewModel)) {
                    latestSolidSubtangleMilestone = milestoneViewModel.getHash();
                    latestSolidSubtangleMilestoneIndex = milestoneViewModel.index();
                } else {
                    break;
                }
            }
        }
    }

I'll have to do some further investigating to find the cause ....

footloosejava commented 6 years ago

A little edit for clarity ... and it turns out that 'ledgerValidator.updateSnapshot(milestone);' does not return true ...

When/why/how often is it supposed to return true?

    void updateLatestSolidSubtangleMilestone() throws Exception {
        MilestoneViewModel latest = MilestoneViewModel.latest(tangle);
        if (latest != null) {
            MilestoneViewModel milestone = MilestoneViewModel.findClosestNextMilestone(tangle, latestSolidSubtangleMilestoneIndex);

            while (!shuttingDown && (milestone != null) && (milestone.index() <= latest.index())) {

                if (ledgerValidator.updateSnapshot(milestone)) {
                    log.info("updateSnapshot");

                    if (milestone.index() >= latestSolidSubtangleMilestoneIndex) {
                        log.info("milestone.index > latestSolidSubtangleMilestoneIndex");

                        if (transactionValidator.checkSolidity(milestone.getHash(), true)) {
                            log.info("Solidity");

                            latestSolidSubtangleMilestone = milestone.getHash();
                            latestSolidSubtangleMilestoneIndex = milestone.index();

                        } else {
                            break;
                        }
                    } else {
                        break;
                    }
                } else {
                    break;
                }
                milestone = milestone.next(tangle);
            }
        }
    }
alon-e commented 6 years ago

@footloosejava - you swapped the order of if evaluation, I assume the checkSolidity would fail in your case first. that means that a transaction in the history of the next milestone is missing.

footloosejava commented 6 years ago

@alon-e I see the swap now. Thanks. I'l have to revisit this and see what is happening.

footloosejava commented 6 years ago

I don't ever get milestoneViewModel.index() >= latestSolidSubtangleMilestoneIndex= true

Everything is up to date but it still doesn't update latestSolidSubtangleMilestoneIndex:

toProcess = 0 , toBroadcast = 0 , toRequest = 0 , toReply = 0 / totalTransactions = 10559771 latestMilestoneIndex: 454948, latestSolidSubtangleMilestoneIndex: 426550

for (; mvm.index() <= latest.index() && !shuttingDown; mvm = mvm.next(tangle)) {

    boolean checkSolidity = transactionValidator.checkSolidity(mvm.getHash(), true);

    if (checkSolidity) {
        log.info("checkSolidity= true");

        if (mvm.index() >= latestSolidSubtangleMilestoneIndex) {
            log.info("milestoneViewModel.index() >= latestSolidSubtangleMilestoneIndex= true");

            if (ledgerValidator.updateSnapshot(mvm)) {
                log.info("ledgerValidator.updateSnapshot(milestoneViewModel)= true");

                latestSolidSubtangleMilestone = mvm.getHash();
                latestSolidSubtangleMilestoneIndex = mvm.index();
                continue;
            }
        }
    }
    break;
}

@alon-e @Nick2bad4u

footloosejava commented 6 years ago

Someone else can post as a NEW issue if they think it warrants attention. I am closing this because I have no time to attend to it.

GalRogozinski commented 6 years ago

Why a new issue? If you don't want to tend to this issue you can unwatch it so it won't bother you with notifications.