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_getAccessibleState and debug_dbGet methods #398

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

novosandara
Copy link

Description

Implementation of the debug_getAccessibleState and debug_dbGet methods

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 2, 2024 15:32
blockchain/storagev2/leveldb/leveldb.go Outdated Show resolved Hide resolved
blockchain/storagev2/mdbx/mdbx.go Outdated Show resolved Hide resolved
blockchain/storagev2/memory/memory.go Outdated Show resolved Hide resolved
blockchain/storagev2/storage.go Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
// of the next block.
// The (from, to) parameters are the sequence of blocks to search, which can go
// either forwards or backwards
func (d *Debug) GetAccessibleState(from, to BlockNumber) (interface{}, error) {

Choose a reason for hiding this comment

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

return uint64 instead of interface

// DbGet returns the raw value of a key stored in the database.
//
//nolint:stylecheck
func (d *Debug) DbGet(key string) (interface{}, error) {
Copy link

@oliverbundalo oliverbundalo Oct 3, 2024

Choose a reason for hiding this comment

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

Return []byte instead of interface.

There is a question from which database data needs to be returned, state or blockchain? IMO we should check both, but in that case we need to extend blockchain API with Get method. Although it's not complicated I am not sure if it's worth it. For now we can keep it this way, returning value only from state DB.

jsonrpc/debug_endpoint.go Outdated Show resolved Hide resolved
jsonrpc/debug_endpoint_test.go Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
@@ -74,6 +74,10 @@ func (s *Snapshot) GetCode(hash types.Hash) ([]byte, bool) {
return s.state.GetCode(hash)
}

func (s *Snapshot) Get(hash types.Hash) ([]byte, bool, error) {

Choose a reason for hiding this comment

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

There is no need for this method.

@@ -30,6 +30,7 @@ type readSnapshot interface {
GetStorage(addr types.Address, root types.Hash, key types.Hash) types.Hash
GetAccount(addr types.Address) (*Account, error)
GetCode(hash types.Hash) ([]byte, bool)
Get(hash types.Hash) ([]byte, bool, error)

Choose a reason for hiding this comment

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

There is no need for this method.

@@ -47,6 +47,14 @@ func (m *mockSnapshot) GetCode(hash types.Hash) ([]byte, bool) {
return nil, false
}

func (m *mockSnapshot) Has(hash types.Hash) bool {

Choose a reason for hiding this comment

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

This is not needed.

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.

2 participants