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

Implementation of the debug_traceChain method #411

Merged
merged 16 commits into from
Nov 14, 2024

Conversation

novosandara
Copy link

Description

Implementation of the debug_traceChain method

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Documentation update

Additional comments

@novosandara novosandara marked this pull request as ready for review October 25, 2024 08:44
jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
@@ -843,6 +927,50 @@ func (d *Debug) GetAccessibleState(from, to BlockNumber) (interface{}, error) {
)
}

// ChaindbProperty returns leveldb properties of the key-value database.
func (d *Debug) ChaindbProperty(property string) (interface{}, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChaindbProperty doesn't have a param as an input. It returns leveldb stats. Stat() method in ethdb/leveldb/leveldb.go.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I’m not following. I need to think. This is the final code:

// Stat returns a particular internal stat of the database.
func (kv *KVStorage) Stat(property string) (string, error) {
return kv.db.GetProperty(property)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to test what happens if you send "" as a property name. In that case you want to return DB stats, which is correct, but LevelDB has a method Stat() to return all stats. I am not sure it will work like this. If we can make it working to return all properties (stats) when sending "" and to return only 1 property when sending property name then keep it as it is. Geth has a different implementation to always return Stat() and there is no param property in ChaindbProperty() method, but as said we can go with your implementation if it works ok for all cases :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
It works, I hope and as expected :)

@@ -55,6 +55,18 @@ type State interface {
// Returns:
// - bool: A boolean indicating whether the item exists.
Has(hash types.Hash) bool

// Stat returns a particular internal stat of the database.
Stat(property string) (string, error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No input param.

@@ -107,6 +110,22 @@ func (kv *KVStorage) Has(k []byte) (bool, error) {
return ok, nil
}

// Stat returns a particular internal stat of the database.
func (kv *KVStorage) Stat(property string) (string, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No input param.

@@ -37,6 +38,8 @@ type Storage interface {
Batch() Batch
SetCode(hash types.Hash, code []byte) error
GetCode(hash types.Hash) ([]byte, bool)
Stat(property string) (string, error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No input param.

jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
jsonrpc/debug_endpoint.go Show resolved Hide resolved
state/immutable-trie/storage.go Outdated Show resolved Hide resolved
@oliverbundalo oliverbundalo merged commit 54d704f into develop Nov 14, 2024
10 checks passed
@oliverbundalo oliverbundalo deleted the Implementation_of_the_debug_traceChain_method branch November 14, 2024 11:55
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

Successfully merging this pull request may close these issues.

3 participants