Problems Displaying Blockchain in Forging Mode After Exception

Hello,

Thanks for providing this framework.

I'm using the nxt-clone-starter kit and have followed the YouTube video plus a Medium article for creating a Proof-of-Stake crypto using NXT.

I'm able to get my new crypto node up and running, and I can see the available balance for the seed balances, but I'm not able to view the blocks in the GUI when the node is forging.

An exception is constantly thrown with little detail about why it's being thrown. Repeat, this exception is thrown in forging mode.

Blocks are getting made. I'm getting a log statement to output:

2021-04-19 01:03:55 FINE: Account generated block 3519090056612070497 at height 25 timestamp 47017 fee 0.0

I am able to view the blocks when the system IS NOT forging.

I'm running version 1.12.2. Here's the stack trace of what is thrown:
2021-04-19 01:04:25 FINE: Error processing API request

java.lang.RuntimeException: java.lang.IllegalStateException: Attempting to load invalid block

at nxt.db.DbIterator.next(DbIterator.java:73)

at nxt.http.GetBlocks.processRequest(GetBlocks.java:49)

at nxt.http.APIServlet$APIRequestHandler.processRequest(APIServlet.java:94)

at nxt.http.APIServlet.process(APIServlet.java:265)

at nxt.http.APIServlet.doGet(APIServlet.java:187)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1780)

at nxt.http.API$XFrameOptionsFilter.doFilter(API.java:548)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)

at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:308)

at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:262)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:435)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:513)

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)

at org.eclipse.jetty.server.Server.handle(Server.java:539)

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)

at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)

at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)

at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)

at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)

at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)

at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)

at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.IllegalStateException: Attempting to load invalid block

at nxt.BlockDb.loadBlock(BlockDb.java:250)

at nxt.BlockDb.loadBlock(BlockDb.java:233)

at nxt.db.DbIterator.next(DbIterator.java:68)

... 35 more

Thanks for your assistance.

Thanks,
Will

1 Like

I have the same issue. Any idea?

I am running a node of GitHub - lucidddreams/VcashPay-core: VcashPay - Digital money for the modern world the node displays this error.

I cannot connect any other wallet to this node because I get blacklisted.
I use docker with java-1.8.0-amazon-corretto-jdk_8.212.04-2 to run the node and the local wallet.

They have been both compiled using openjdk version "1.8.0_265"

Here is the full error log:

nxt.BlockchainProcessorImpl.addGenesisBlock(BlockchainProcessorImpl.java:1330)
nxt.BlockchainProcessorImpl.lambda$new$6(BlockchainProcessorImpl.java:995)
nxt.util.ThreadPool.lambda$runAll$1(ThreadPool.java:126)
2021-04-23 16:46:17 INFO: nxt.forceScan = "false"
2021-04-23 16:46:17 FINE: Running 2 final tasks...
2021-04-23 16:46:17 INFO: nxt.apiServerEnforcePOST = "true"
2021-04-23 16:46:17 INFO: nxt.apiFixResponseContentType = "false"
2021-04-23 16:46:17 INFO: Started API server at 0.0.0.0:16876
2021-04-23 16:46:17 INFO: Started peer networking server at 0.0.0.0:16874
2021-04-23 16:46:17 FINE: Starting 9 background jobs
2021-04-23 16:46:17 FINE: Starting 2 delayed tasks
2021-04-23 16:46:17 FINE: Known peers: 0
2021-04-23 16:46:17 INFO: Initialization took 39 seconds
2021-04-23 16:46:17 INFO: VcashPay server 1.12.2 started successfully.
2021-04-23 16:46:17 INFO: Copyright © 2013-2016 The Nxt Core Developers.
2021-04-23 16:46:17 INFO: Copyright © 2016-2020 Jelurida IP B.V.
2021-04-23 16:46:17 INFO: Distributed under the Jelurida Public License version 1.2 for the Nxt Public Blockchain Platform, with ABSOLUTELY NO WARRANTY.
2021-04-23 16:46:17 INFO: Client UI is at http://localhost:16876/index.html
2021-04-23 16:47:30 FINE: Forger 9932994002424087667 deadline 383 hit 383 started
2021-04-23 16:47:30 FINE: Forger 9932994002424087667 deadline 383 hit 383
2021-04-23 16:47:30 FINE: Average database transaction time is 0.007 seconds
2021-04-23 16:47:30 FINE: Account 9932994002424087667 generated block 14023259031767277185 at height 1 timestamp 25631 fee 0.0
2021-04-23 16:47:44 FINE: Error processing API request
java.lang.RuntimeException: java.lang.IllegalStateException: Attempting to load invalid block
at nxt.db.DbIterator.next(DbIterator.java:73)
at nxt.http.GetBlocks.processRequest(GetBlocks.java:49)
at nxt.http.APIServlet$APIRequestHandler.processRequest(APIServlet.java:94)
at nxt.http.APIServlet.process(APIServlet.java:265)
at nxt.http.APIServlet.doGet(APIServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1780)
at nxt.http.API$XFrameOptionsFilter.doFilter(API.java:548)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:308)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:262)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:493)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:513)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:539)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Attempting to load invalid block
at nxt.BlockDb.loadBlock(BlockDb.java:250)
at nxt.BlockDb.loadBlock(BlockDb.java:233)
at nxt.db.DbIterator.next(DbIterator.java:68)
... 35 more
2021-04-23 16:48:02 FINE: Forger 9932994002424087667 deadline 92 hit 25723
2021-04-23 16:48:37 FINE: Error processing POST request: java.lang.IllegalStateException: Attempting to load invalid block
2021-04-23 16:48:37 FINE: Blacklisting 81.61.116.152 because of: java.lang.IllegalStateException: Attempting to load invalid block
java.lang.IllegalStateException: Attempting to load invalid block
at nxt.BlockDb.loadBlock(BlockDb.java:250)
at nxt.BlockchainImpl.getBlocksAfter(BlockchainImpl.java:308)
at nxt.peer.GetNextBlocks.processRequest(GetNextBlocks.java:58)
at nxt.peer.PeerServlet.process(PeerServlet.java:290)
at nxt.peer.PeerServlet.doPost(PeerServlet.java:207)
at nxt.peer.PeerWebSocket.lambda$onMessage$0(PeerWebSocket.java:356)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2021-04-23 16:48:40 FINE: Error processing API request
java.lang.RuntimeException: java.lang.IllegalStateException: Attempting to load invalid block
at nxt.db.DbIterator.next(DbIterator.java:73)
at nxt.http.GetBlocks.processRequest(GetBlocks.java:49)
at nxt.http.APIServlet$APIRequestHandler.processRequest(APIServlet.java:94)
at nxt.http.APIServlet.process(APIServlet.java:265)
at nxt.http.APIServlet.doGet(APIServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1780)
at nxt.http.API$XFrameOptionsFilter.doFilter(API.java:548)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:308)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:262)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1767)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:493)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:513)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:539)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Attempting to load invalid block
at nxt.BlockDb.loadBlock(BlockDb.java:250)
at nxt.BlockDb.loadBlock(BlockDb.java:233)
at nxt.db.DbIterator.next(DbIterator.java:68)
... 35 more
2021-04-23 16:49:02 FINE: Account 9932994002424087667 generated block 1656806431255393505 at height 2 timestamp 25724 fee 0.0

A weird fact is that I don't see the blocks:
image

And when I click more info I see
No blocks found.

Actually when I open the chrome console I see this error again

{errorDescription: "java.lang.IllegalStateException: Attempting to load invalid block", errorCode: 4,…}

When the javascript queries this:

https://coin.vcashpay.com/nxt?requestType=getBlocks&firstIndex=0&lastIndex=15&random=0.28261531308451326

It looks like something specific to the nxt-starter-kit or even to a modified version of it
See VcashPay-core/BlockDb.java at main · regedittap/VcashPay-core · GitHub

if (nextBlockId == 0 && !rs.wasNull()) {                
    throw new IllegalStateException("Attempting to load invalid block");            
}

What is the origin of the VcashPay-core repository?

Hi @lior.yaffe

Thanks for your answer.
VcashPay-core is based on nxt-starter-kit.

You can find the same code here:
https://bitbucket.org/Jelurida/nxt-clone-starter/src/master/src/java/nxt/BlockDb.java

Any idea how to solve this?

Note that I didn't have this issue with the nxt-starter-kit v1.11.13

Did you start with an earlier nxt-clone-starter version, and then upgraded to 1.12.2? I don't think the NxtDbVersion code in the starter kit supports in-place update of the db from a previous version. Do you see the same problem if you start a new node and let it download the blockchain from its peers?

Hi @tomislav I started from 1.12.2 directly from block 0.

I tried a few things:

  • to popOff from block 1
  • to bootstrap the nxt_db until block 1 and add it to the folder of other nodes

I still have the error from time to times, some of the blocks seems to have this issue "Attempting to load invalid block". Nevertheless having more than 1 node up and running, helps, it let the nodes syncs fully and does not block me (but I think it was the same previously after waiting).

I still do have the error

{errorDescription: "java.lang.IllegalStateException: Attempting to load invalid block", errorCode: 4,…}

When the browser call this

https://coin.vcashpay.com/nxt?requestType=getBlocks&firstIndex=0&lastIndex=15&random=0.28261531308451326

But forging still seems to work!

I reverted back to 1.11 to get it working using your articles and process.

It seems to be running fine, but I'd like to run the latest as well.

Could be a bug indeed, we will investigate.

We will fix it in the next release. For now you can fix it on your side by adding

BlockDb.commit(block);

after

accept(block, validPhasedTransactions, invalidPhasedTransactions, duplicates);

in BlockchainProcessorImpl.pushBlock

Here's a patch

Index: src/java/nxt/BlockchainProcessorImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/java/nxt/BlockchainProcessorImpl.java b/src/java/nxt/BlockchainProcessorImpl.java
--- a/src/java/nxt/BlockchainProcessorImpl.java	(revision 688b34d9f75e604da2614d3b9a8d3d08ecd2b7cb)
+++ b/src/java/nxt/BlockchainProcessorImpl.java	(revision fc159da0d8b155e6aa9a92539ec382901c756eff)
@@ -1366,7 +1366,7 @@
                 try {
                     addBlock(block);
                     accept(block, validPhasedTransactions, invalidPhasedTransactions, duplicates);
-
+                    BlockDb.commit(block);
                     Db.db.commitTransaction();
                 } catch (Exception e) {
                     Logger.logInfoMessage("Failed to accept an already validated block", e);
1 Like

It seems to work, well done again @petko.petkov you are a genius!

I'll give this a try as well and report back.

Thanks,
Will

Your fixed worked for me. Thanks, @petko.petkov!