-
Notifications
You must be signed in to change notification settings - Fork 193
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
Pps sandbox #1860
Conversation
rpc/block_test.go
Outdated
log := utils.NewNopZapLogger() | ||
n := utils.Ptr(utils.Mainnet) | ||
chain := blockchain.New(pebble.NewMemTest(t), n) | ||
handler := rpc.New(chain, nil, nil, "", n, log) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Skip()?
You should also remove the changes to cmd/juno, and the juno/*.sst files. After that run Finally, just make sure the tests pass on the workflows (you may need to ping someone from the juno team to run the workflows) |
on running the tests. 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
} |
Hi @rianhughes |
}, "/v0_6" | ||
} | ||
|
||
func (h *Handler) JunoGetNodesFromRoot(key felt.Felt) (string, *jsonrpc.Error) { |
There was a problem hiding this comment.
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 :)
rpc/handlers_test.go
Outdated
@@ -99,3 +99,21 @@ func TestThrottledVMError(t *testing.T) { | |||
assert.Equal(t, throttledErr, rpcErr.Data) | |||
}) | |||
} | |||
|
|||
func TestJunoGetBlockFromRoot(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
juno/ | ||
cmd/juno/pps_rpc.go | ||
cmd/juno/rpc_respReceipts.go | ||
cmd/juno/rpc_respTxns.go | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
// 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 | ||
// }) | ||
// } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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")
}
Hi @rianhughes |
I also want to ask one more thing... |
Closing the PR since there is more fresh impl here #1870 |
Note: this is an exercise - it's NOT to be merged