Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace count differs between besu and zkgeth #449

Closed
FlorianHuc opened this issue Nov 30, 2023 · 8 comments
Closed

trace count differs between besu and zkgeth #449

FlorianHuc opened this issue Nov 30, 2023 · 8 comments
Assignees

Comments

@FlorianHuc
Copy link
Collaborator

We have been generating the trace count using rpc endpoint of besu for block number 2261111

result is (Note that the result could be improved by adding block number and block hash):

{
   "jsonrpc":"2.0",
   "id":1,
   "result":{
      "tracesEngineVersion":"0.0.1-SNAPSHOT",
      "tracesCountersByModule":{
         "Add":0,
         "Ext":0,
         "LogData":0,
         "LogInfo":0,
         "Mod":0,
         "Mxp":0,
         "RlpTxrcpt":0,
         "Mul":1,
         "Wcp":0,
         "RlpTxn":0,
         "TxnData":0,
         "InstructionDecoder":256,
         "Shf":0,
         "ShfRt":2305,
         "Rom":0,
         "RomLex":0,
         "Hub":0,
         "RlpAddr":0
      }
   }
}

It is different from the trace count returned by zkget which is:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "tracesEngineVersion": "0.2.0",
        "blockNumber": "2261111",
        "blockL1Size": "4035",
        "tracesCounters": {
            "ADD": 5490,
            "BIN": 2864,
            "BIN_RT": 0,
            "EC_DATA": 12,
            "EXT": 80,
            "HUB": 8439,
            "INSTRUCTION_DECODER": 0,
            "MMIO": 3864,
            "MMU": 2271,
            "MMU_ID": 0,
            "MOD": 256,
            "MUL": 433,
            "MXP": 2032,
            "PHONEY_RLP": 0,
            "PUB_HASH": 80,
            "PUB_HASH_INFO": 18,
            "PUB_LOG": 16,
            "PUB_LOG_INFO": 4,
            "RLP": 8,
            "ROM": 66722,
            "SHF": 1936,
            "SHF_RT": 0,
            "TX_RLP": 1516,
            "WCP": 2548,
            "BLOCK_TX": 9,
            "BLOCK_L2L1LOGS": 0,
            "BLOCK_KECCAK": 70,
            "PRECOMPILE_ECRECOVER": 0,
            "PRECOMPILE_SHA2": 0,
            "PRECOMPILE_RIPEMD": 0,
            "PRECOMPILE_IDENTITY": 0,
            "PRECOMPILE_MODEXP": 0,
            "PRECOMPILE_ECADD": 0,
            "PRECOMPILE_ECMUL": 0,
            "PRECOMPILE_ECPAIRING": 0,
            "PRECOMPILE_BLAKE2F": 0
        }
    }
}

They should be identical.
Note that Besu gives result that 'looks' better for a more recent block (2314707).

@FlorianHuc
Copy link
Collaborator Author

@ahamlat and @jonesho can add more details on how to reproduce the testing.

@delehef
Copy link
Contributor

delehef commented Nov 30, 2023

This looks like the tracing has not been triggered; the lines are (i) ShfRT and InstructionDecoder (which are static and do not depend on the block), and (ii) the one line for mul that is static as well and encodes 0×0 (IIRC).

@delehef delehef closed this as completed Nov 30, 2023
@delehef delehef reopened this Nov 30, 2023
@ahamlat
Copy link
Contributor

ahamlat commented Nov 30, 2023

Could be related to Bonsai because the results I shared were on a Bonsai/Snap Sync node, I will double check with a forest archive node.

@jonesho
Copy link

jonesho commented Dec 1, 2023

As mentioned in the Slack thread here, it would be great if we can get the full mappings of trace counts from besu to zkgeth (e.g. rlpAddr txnData logData rlpTxRcpt, how do they map to their zkgeth counterparts), and also it would be great if we have consistent naming of the trace count fields here, at least not some as CamelCase and some as underscored cc @delehef

@jonesho
Copy link

jonesho commented Dec 1, 2023

E.g. trace counts from Besu (ec2-18-222-142-230.us-east-2.compute.amazonaws.com):

{
    "add": 25856,
    "ext": 72,
    "instruction-decoder": 256,
    "mod": 7240,
    "mxp": 62266,
    "rlpTxRcpt": 31720,
    "mul": 2520,
    "wcp": 20031,
    "logInfo": 2398,
    "shf": 4832,
    "rom": 3929808,
    "txnData": 1340,
    "shfRT": 2305,
    "logData": 2666,
    "romLex": 520,
    "rlpTxn": 80590,
    "rlpAddr": 92,
    "hub_v2_off": 359392
}

@ahamlat
Copy link
Contributor

ahamlat commented Dec 1, 2023

Testing PR #335 on a Besu Forest Archive node on Linea return an output different from what is expected :

 curl -X POST --data '{"jsonrpc":"2.0","method":"rollup_getTracesCountersByBlockNumberV0","params":["1287000", "0.0.1-SNAPSHOT"],"id":1}' http://localhost:8545
 
 {
   "jsonrpc":"2.0",
   "id":1,
   "result":{
      "tracesEngineVersion":"0.0.1-SNAPSHOT",
      "tracesCountersByModule":{
         "Add":0,
         "Ext":0,
         "LogData":0,
         "LogInfo":0,
         "Mod":0,
         "Mxp":0,
         "RlpTxrcpt":0,
         "Mul":1,
         "Wcp":0,
         "RlpTxn":0,
         "TxnData":0,
         "InstructionDecoder":256,
         "Shf":0,
         "ShfRt":2305,
         "Rom":0,
         "RomLex":0,
         "Hub":0,
         "RlpAddr":0
      }
   }
}

I also see this error when I first test the RPC endpoint

{"@timestamp":"2023-12-01T14:42:19,890","level":"ERROR","thread":"vert.x-worker-thread-7","class":"BlockchainQueries","message":"failed worldstate query for 0x654ae22b7cadb8d85f46b205d1ebdf3233b6321f30ed252835e5c1eaa52d6a2f","throwable":" java.lang.NullPointerException: Cannot invoke \"net.consensys.linea.zktracer.module.hub.DeploymentInfo.number(org.hyperledger.besu.datatypes.Address)\" because the return value of \"net.consensys.linea.zktracer.runtime.stack.ConflationInfo.deploymentInfo()\" is null
at net.consensys.linea.zktracer.module.romLex.RomLex.lambda$traceStartTx$0(RomLex.java:142)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at net.consensys.linea.zktracer.module.romLex.RomLex.traceStartTx(RomLex.java:139)
at net.consensys.linea.zktracer.module.hub.Hub.traceStartTx(Hub.java:588)
at net.consensys.linea.zktracer.ZkTracer.traceStartTransaction(ZkTracer.java:156)
at org.hyperledger.besu.services.TraceServiceImpl.lambda$trace$6(TraceServiceImpl.java:215)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.hyperledger.besu.services.TraceServiceImpl.trace(TraceServiceImpl.java:202)
at org.hyperledger.besu.services.TraceServiceImpl.lambda$trace$4(TraceServiceImpl.java:182)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.lambda$processTracing$0(Tracer.java:52)
at org.hyperledger.besu.ethereum.api.query.BlockchainQueries.lambda$getAndMapWorldState$24(BlockchainQueries.java:918)
at java.base/java.util.Optional.flatMap(Optional.java:289)
at org.hyperledger.besu.ethereum.api.query.BlockchainQueries.getAndMapWorldState(BlockchainQueries.java:914)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.lambda$processTracing$1(Tracer.java:50)
at java.base/java.util.Optional.flatMap(Optional.java:289)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.processTracing(Tracer.java:48)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.processTracing(Tracer.java:38)
at org.hyperledger.besu.services.TraceServiceImpl.trace(TraceServiceImpl.java:178)
at org.hyperledger.besu.services.TraceServiceImpl.traceBlock(TraceServiceImpl.java:101)
at org.hyperledger.besu.services.TraceServiceImpl.traceBlock(TraceServiceImpl.java:80)
at net.consensys.linea.tracegeneration.LineCountsByBlockCache.getBlockTraces(LineCountsByBlockCache.java:41)
at net.consensys.linea.tracegeneration.rpc.RollupGetTracesCountersByBlockNumberV0.getTracesCounters(RollupGetTracesCountersByBlockNumberV0.java:68)
at net.consensys.linea.tracegeneration.rpc.RollupGetTracesCountersByBlockNumberV0.execute(RollupGetTracesCountersByBlockNumberV0.java:55)
at net.consensys.linea.tracegeneration.rpc.RollupGetTracesCountersByBlockNumberV0.execute(RollupGetTracesCountersByBlockNumberV0.java:26)
at org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.PluginJsonRpcMethod.response(PluginJsonRpcMethod.java:53)
at org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor.process(BaseJsonRpcProcessor.java:44)
at org.hyperledger.besu.ethereum.api.jsonrpc.execution.TracedJsonRpcProcessor.process(TracedJsonRpcProcessor.java:41)
at org.hyperledger.besu.ethereum.api.jsonrpc.execution.TimedJsonRpcProcessor.process(TimedJsonRpcProcessor.java:45)
at org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor.execute(JsonRpcExecutor.java:92)
at org.hyperledger.besu.ethereum.api.handlers.AbstractJsonRpcExecutor.executeRequest(AbstractJsonRpcExecutor.java:87)
at org.hyperledger.besu.ethereum.api.handlers.JsonRpcObjectExecutor.execute(JsonRpcObjectExecutor.java:57)
at org.hyperledger.besu.ethereum.api.handlers.JsonRpcExecutorHandler.lambda$handler$0(JsonRpcExecutorHandler.java:57)
at java.base/java.util.Optional.ifPresentOrElse(Optional.java:196)
at org.hyperledger.besu.ethereum.api.handlers.JsonRpcExecutorHandler.lambda$handler$2(JsonRpcExecutorHandler.java:54)
at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
at io.vertx.core.impl.ContextBase.lambda$null$0(ContextBase.java:137)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
at io.vertx.core.impl.ContextBase.lambda$executeBlocking$1(ContextBase.java:135)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)\n"}

Whe testing with PR #451 with the same block number on the same node, I have this result

{
   "jsonrpc":"2.0",
   "id":1,
   "result":{
      "tracesEngineVersion":"0.0.1-SNAPSHOT",
      "blockNumber":1287000,
      "tracesCounters":{
         "EXT":0,
         "TX_RLP":650,
         "ADD":4768,
         "MXP":3168,
         "PRECOMPILE_ECMUL":0,
         "ROM_LEX":30,
         "PUB_LOG":56,
         "TRM":96,
         "SHF":384,
         "HUB":27711,
         "rlpAddr":0,
         "PRECOMPILE_ECPAIRING":0,
         "PRECOMPILE_MODEXP":0,
         "BLOCK_TX":2,
         "MOD":1904,
         "rlpTxRcpt":522,
         "MUL":933,
         "wcp":2881,
         "PRECOMPILE_ECADD":0,
         "PRECOMPILE_ECRECOVER":0,
         "ROM":128048,
         "txnData":14,
         "PRECOMPILE_SHA2":0,
         "ecpairingWeightedCall":0,
         "PRECOMPILE_BLAKE2F":0,
         "MMU":0,
         "PUB_LOG_INFO":48,
         "PRECOMPILE_RIPEMD":0
      }
   }
}

@letypequividelespoubelles
Copy link
Collaborator

it would be great if we can get the full mappings of trace counts from besu to zkgeth (e.g. rlpAddr txnData logData rlpTxRcpt, how do they map to their zkgeth counterparts)

  • rlpAddr (previously called rlp): it changed from 16 rows per CREATE to 8 rows for CREATE and 6 rows for CREATE2.
  • rlpTxn should be almost the same
  • logData, logInfo, txnData, rlpTxRcpt were not traced in Geth AFAIK (were specified in august / september)
  • rom should be a little bit bigger in Besu (<5% I think)
  • romLex should be the same
  • for the stateless module (wcp, mul, mod, etc) it should be way bigger in Besu as these modules are called by other modules. So the more implemented module, the bigger they are.
  • for mxp I think it's stricly the same @lorenzogentile404
  • for mmu and mmio idk : @powerslider

@delehef
Copy link
Contributor

delehef commented Dec 11, 2023

Superseded by #467

@delehef delehef closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants