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

Pps sandbox #1860

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

Pps sandbox #1860

wants to merge 26 commits into from

Conversation

rianhughes
Copy link
Contributor

@rianhughes rianhughes commented May 7, 2024

Note: this is an exercise - it's NOT to be merged

rpc/block.go Show resolved Hide resolved
Comment on lines 716 to 719
log := utils.NewNopZapLogger()
n := utils.Ptr(utils.Mainnet)
chain := blockchain.New(pebble.NewMemTest(t), n)
handler := rpc.New(chain, nil, nil, "", n, log)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit : I think we can push this outside of the loop

Choose a reason for hiding this comment

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

resolved

mainnetGw := adaptfeeder.New(client)

t.Run("pending block", func(t *testing.T) {
t.Skip()
Copy link
Contributor Author

@rianhughes rianhughes May 9, 2024

Choose a reason for hiding this comment

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

t.Skip()?

@rianhughes
Copy link
Contributor Author

You should also remove the changes to cmd/juno, and the juno/*.sst files.

After that run make format, make lint, and fix any lint errors.

Finally, just make sure the tests pass on the workflows (you may need to ping someone from the juno team to run the workflows)

@PsychoPunkSage
Copy link

PsychoPunkSage commented May 11, 2024

Hi..
I'm getting this error
image

on running the tests.
Can anyone help?

I think I am getting error here..

func (h *Handler) JunoGetNodesFromRoot(key felt.Felt) (string, *jsonrpc.Error) {
	stateReader, _, error := h.bcReader.HeadState()
	if error != nil {
		return "", ErrBlockNotFound
	}
@>	try, _, errTry := stateReader.NodeFromRoot()
@>	if errTry != nil {
@>		return "", ErrBlockNotFound
@>	}

	k := try.FeltToKeyConverter(&key)
	storageNodes, err := try.GetNodesFromRoot(&k)
	if err != nil {
		return "", ErrBlockNotFound
	}

	parsedNodes := try.NodeParser(storageNodes)

	jsonBytes, err := json.Marshal(parsedNodes)
	if err != nil {
		return "", ErrParsingError
	}
	return string(jsonBytes), nil
}

@PsychoPunkSage
Copy link

Hi @rianhughes
Please have a look at task 5

}, "/v0_6"
}

func (h *Handler) JunoGetNodesFromRoot(key felt.Felt) (string, *jsonrpc.Error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be easier to review if you created a new PR for this :)

@@ -99,3 +99,21 @@ func TestThrottledVMError(t *testing.T) {
assert.Equal(t, throttledErr, rpcErr.Data)
})
}

func TestJunoGetBlockFromRoot(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo

@rianhughes rianhughes self-assigned this May 13, 2024
Comment on lines +11 to 15
juno/
cmd/juno/pps_rpc.go
cmd/juno/rpc_respReceipts.go
cmd/juno/rpc_respTxns.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just fyi, in a real PR these shouldn't be here

Choose a reason for hiding this comment

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

Yes, I just wanted to keep previous code intact (I'm experimenting with it).
I thought this PR won't be merged so I kept it this way.

Comment on lines +113 to +123
// func (b *Blockchain) JunoGetNodesFromRoot(key *felt.Felt) (core.StateReader /*, StateCloser*/, error) {
// b.listener.OnRead("JunoGetNodesFromRoot")
// var state core.StateReader
// // var closer StateCloser
// return state, b.database.View(func(txn db.Transaction) error {
// var err error
// state, _, err = core.NewState(txn).NodeFromRoot(key)
// return err
// })
// }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same with this

Choose a reason for hiding this comment

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

You mentioned about writing some codes in blockchain.go file right? (in the message thread)
I was not sure about whether I'm doing correct thing here. So I just commented it.

@@ -122,6 +123,10 @@ func (s *State) Root() (*felt.Felt, error) {
return crypto.PoseidonArray(stateVersion, storageRoot, classesRoot), nil
}

func (s *State) NodeFromRoot() (*trie.Trie, func() error, error) {
return s.globalTrie(db.StateTrie, trie.NewTriePedersen)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are returning the state trie here, not the nodes from the root to a leaf


handler := rpc.New(mockReader, nil, nil, "", utils.Ptr(utils.Mainnet), log)

t.Run("Key DNE", func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is panicking because you are calling
// NodeFromRoot implements core.StateHistoryReader.
func (m *MockStateHistoryReader) NodeFromRoot() (*trie.Trie, func() error, error) {
panic("unimplemented")
}

@PsychoPunkSage
Copy link

PsychoPunkSage commented May 17, 2024

Hi @rianhughes
I tried to implement NodesFromRoot Mock... but I'm facing little difficulty in doing so...
Can you please have a look at the code and tell me what I'm doing Wrong?? Or what changes I have to make??

Link to Mocks

@PsychoPunkSage
Copy link

I also want to ask one more thing...
I have to also do exercise 6?? Or after completing 5 I can do some contribution to juno??

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.

None yet

2 participants