-
Notifications
You must be signed in to change notification settings - Fork 103
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
Sequencer catchup #1151
Sequencer catchup #1151
Conversation
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.
Definitely on the right track. Let's ask the consensus team about where to get the view number
sequencer/src/catchup.rs
Outdated
} | ||
} | ||
tracing::warn!("Could not fetch account from any peer, retrying"); | ||
// TODO: backoff? for testing a function that doesn't loop forever is probably more convenient. |
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.
IMO:
- Make backoff a parameter to set in the constructor. We can set it really short for tests that are expected to fail a few times before eventually succeeding (testing the backoff case)
- Make a separate function that returns an error, for easy unit testing. Then the main function just call that function in a loop.
sequencer/src/state.rs
Outdated
Some(balance.cloned().unwrap_or_default().add(amount)) | ||
}) | ||
.expect("update_with succeeds"); | ||
// TODO: can this really not fail? |
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.
I don't think so, b/c both Some
or None
cases are handled in the closure. I feel that this can be written more succinctly, though, by remembering the account balance in the Ok(NotInMemory)
case of the match on update_with
(as you've done ~line 143).
8ac034a
to
d652382
Compare
5834477
to
a01aad7
Compare
525719e
to
0586141
Compare
sequencer/src/header.rs
Outdated
.await; | ||
|
||
// Insert missing fee state entries | ||
let mut state = parent_state.clone(); |
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.
Since we're cloning state
here we could pass it into from_info
by value and avoid a second clone (although clone
should be fairly cheap now that stuff is Arc
ed)
Edit: the issue sees to be the impl Into Iterator in the function and the wrong error message from the compiler mentioned in the issue below. So I'm unblocked again. @jbearer I tried to use box dyn trait in the last commit 053d95f, this fails to compile with the error message
full error message at the end. I wonder if the actual problem is object safety due to using async in the trait and the error message is just wrong (rust-lang/rust#119502). I saw here here that using
|
- Add functions to fetch from peers. [squashed version of #1151]
sequencer/src/header.rs
Outdated
.chain(l1_deposits.iter().map(|info| info.account())), | ||
); | ||
|
||
// Fetch missing fee state entries |
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.
We also need to fetch the blocks frontier if missing
sequencer/src/catchup.rs
Outdated
.expect_ok() | ||
.unwrap(); | ||
mt.remember(view.get_u64(), elem, proof.clone()) |
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 currently where the test panics. The element
returned by lookup doesn't match the one passed in to the function.
@@ -338,6 +477,12 @@ impl FeeAmount { | |||
} | |||
} | |||
|
|||
impl From<u64> for FeeAmount { |
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.
I think we had this before, but we removed it. Why are we putting it back again?
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.
I think it's currently only used in one place, when deleting it I get:
error[E0277]: the trait bound `state::FeeAmount: From<{integer}>` is not satisfied
--> sequencer/src/api.rs:920:56
|
920 | state.prefund_account(Default::default(), 1000.into());
| ^^^^ the trait `From<{integer}>` is not implemented for `state::FeeAmount`
|
= help: the trait `From<ethers::types::U256>` is implemented for `state::FeeAmount`
= help: for that trait implementation, expected `ethers::types::U256`, found `{integer}`
= note: required for `{integer}` to implement `Into<state::FeeAmount>`
I don't really mind keeping it, it's simple and will probably be used more once we add more tests.
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.
I think it's just something that makes sense since FeeAmount
is supposed to act like a number. E.g. U256
also implements 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.
Yea I don't think it hurts anything either but you can just do: U256::from(1000).into()
.
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.
@sveitser I did review your changes so if you've reviewed my changes I think we're good
- Add functions to fetch from peers. - Re-organize block building 1. Check what's missing 2. Fetch missing data from peers 3. Build block - Restore merkle tree frontier - dd backoff to state peers - Make state peers configurable - Add nightly dev shell - Initial mock implementation of StateCatchup - Address review comments
This commit adds catchup to the restartability test, so that it should in theory pass now. However, it is still failing due to an error from HotShot: "Couldn't find parent view in state map". I will look into this more next week. For now, the test remains ignored.
7cbf7d5
to
f1cee9b
Compare
TODO