From e2397c2f5a4b0dcf9dfa5a0a0aa3ba9339f744a5 Mon Sep 17 00:00:00 2001 From: nicolae-leonte-go <42137924+nicolae-leonte-go@users.noreply.github.com> Date: Wed, 10 Mar 2021 12:14:52 +0000 Subject: [PATCH] add debug_privateStateRoot API (for testing purposes) (#1148) --- eth/api.go | 8 ++++++++ internal/web3ext/web3ext.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/eth/api.go b/eth/api.go index 6d8275df3b..872fdace95 100644 --- a/eth/api.go +++ b/eth/api.go @@ -319,6 +319,14 @@ func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber, typ *string) (stat return publicState.RawDump(false, false, true), nil } +func (api *PublicDebugAPI) PrivateStateRoot(ctx context.Context, blockNr rpc.BlockNumber) (common.Hash, error) { + _, privateState, err := api.getStateDbsFromBlockNumber(blockNr) + if err != nil { + return common.Hash{}, err + } + return privateState.IntermediateRoot(true), nil +} + // Quorum // DumpAddress retrieves the state of an address at a given block. // Quorum adds an additional parameter to support private state dump diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 9c6e1fcd30..1f93dfdda4 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -277,6 +277,12 @@ web3._extend({ params: 2, inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, ""] }), + new web3._extend.Method({ + name: 'privateStateRoot', + call: 'debug_privateStateRoot', + params: 1, + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] + }), new web3._extend.Method({ name: 'dumpAddress', call: 'debug_dumpAddress',