Skip to content

Commit 13fe6bf

Browse files
authored
Stateless: Implement debug_executionWitness and debug_executionWitnessByBlockHash RPC endpoints (#3479)
1 parent 52271f6 commit 13fe6bf

File tree

6 files changed

+229
-169
lines changed

6 files changed

+229
-169
lines changed

execution_chain/core/chain/persist_blocks.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ proc persistBlock*(p: var Persister, blk: Block): Result[void, string] =
187187

188188
var witness = Witness.build(witnessKeys, preStateLedger.ReadOnlyLedger)
189189
witness.addHeaderHash(header.parentHash)
190-
witness.addHeaderHash(blockHash)
191190

192191
?vmState.ledger.txFrame.persistWitness(blockHash, witness)
193192
vmState.ledger.clearWitnessKeys()

execution_chain/db/core_db/core_apps.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ proc getWitness*(db: CoreDbTxRef, blockHash: Hash32): Result[Witness, string] =
634634

635635
Witness.decode(witnessBytes)
636636

637+
proc getCodeByHash*(db: CoreDbTxRef, codeHash: Hash32): Result[seq[byte], string] =
638+
let code = db.get(contractHashKey(codeHash).toOpenArray).valueOr:
639+
return err("getCodeByHash: " & $$error)
640+
641+
ok(code)
642+
637643
# ------------------------------------------------------------------------------
638644
# End
639645
# ------------------------------------------------------------------------------

execution_chain/rpc.nim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import
1212
websock/websock,
1313
json_rpc/rpcserver,
1414
./rpc/common,
15-
#./rpc/debug,
15+
./rpc/debug,
1616
./rpc/engine_api,
1717
./rpc/jwt_auth,
1818
./rpc/cors,
@@ -56,9 +56,8 @@ func installRPC(server: RpcServer,
5656
if RpcFlag.Admin in flags:
5757
setupAdminRpc(nimbus, conf, server)
5858

59-
# # Tracer is currently disabled
60-
# if RpcFlag.Debug in flags:
61-
# setupDebugRpc(com, nimbus.txPool, server)
59+
if RpcFlag.Debug in flags:
60+
setupDebugRpc(com, nimbus.txPool, server)
6261

6362

6463
proc newRpcWebsocketHandler(): RpcWebSocketHandler =

0 commit comments

Comments
 (0)