-
Notifications
You must be signed in to change notification settings - Fork 97
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
execNewBlock: remove the parent header as parameter and sync from the db instead #1741
Conversation
ghost
commented
Sep 26, 2023
•
edited by ghost
Loading
edited by ghost
- To see the specific tasks where the Asana app for GitHub is being used, see below:
- https://app.asana.com/0/0/1205566925523372
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 can't be merged until after the release. All of my comments are pedantic stuff which barely matters, I'm extremely impressed that we can get away with this, it looks exactly like I'd expect. We need to test this on a real mining node as well before merge.
getPWOByHeader :: BlockHeader -> TestBlockDb -> IO PayloadWithOutputs | ||
getPWOByHeader h (TestBlockDb _ pdb _) = do | ||
pwo <- casLookupM pdb (_blockPayloadHash h) | ||
return pwo | ||
|
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.
Should this just be = casLookupM pdb (_blockPayloadHash h)
pwo <- liftIO $ casLookupM pdb (_blockPayloadHash h) | ||
return pwo |
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.
Can just replace this by liftIO $ casLookupM pdb (_blockPayloadHash h)
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.
Hell maybe this should be a shared utility. ModuleCacheOnRestart wants it too.
@@ -1404,6 +1418,12 @@ getPWO chid = do | |||
pwo <- liftIO $ casLookupM pdb (_blockPayloadHash h) | |||
return (pwo,h) | |||
|
|||
getPWOByHeader :: BlockHeader -> PactTestM PayloadWithOutputs | |||
getPWOByHeader h = do | |||
(TestBlockDb _ pdb _) <- view menvBdb |
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.
No need for these parens
83a638f
to
7b74390
Compare
93ce2f2
to
3349023
Compare
We actually don't really need to test this on a real mining node, fake mining with a simulated time distribution also works, as long as it's in a network with multiple mining nodes. |
@edmundnoble will wait until the master is fixed so we can merge with green CI this PR? Or can merge already? it was green before |
@ak3n I want this PR benchmarked to see how many blocks we produce with a simulated miner first. I can help with that some time when you're free. |
Actually we should probably use a load test for this benchmark. |
4d7ac96
to
a814296
Compare
8a80f6b
to
d3daded
Compare
d3daded
to
7244f32
Compare
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.
The logic looks good as per discussion, so I only have a few minor nits.
More eyes on this are definitely welcome, though.
let (T3 _ join1 pwo1) = mainLineBlocks !! 5 | ||
|
||
-- we have to execValidateBlock on `join1` block height to update the parent header | ||
void $ validateBlock join1 (payloadWithOutputsToPayloadData pwo1) pactQueue |
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 might create a helper function (for the tests only!) like
updateParentHeader join pwo queue = void $ validateBlock join (payloadWithOutputsToPayloadData pwo) queue
avoiding the comments in the tests and making the tests a bit more expressive.
src/Chainweb/Pact/PactService.hs
Outdated
tryOne "execNewBlock" _newResultVar $ | ||
execNewBlock memPoolAccess _newBlockHeader _newMiner | ||
() 1 $ | ||
tryOne "execNewBlock" _newResultVar $ do |
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.
Tiny nit: this do
isn't necessary.
src/Chainweb/Pact/Service/Types.hs
Outdated
, _newResultVar :: !(PactExMVar PayloadWithOutputs) | ||
} | ||
instance Show NewBlockReq where show NewBlockReq{..} = show (_newBlockHeader, _newMiner) | ||
instance Show NewBlockReq where show NewBlockReq{..} = show (_newMiner) |
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.
The parens are probably no longer needed.
7244f32
to
1a4ee00
Compare
9bb4573
to
619de66
Compare
619de66
to
01b4531
Compare
Merged in #1803 |