-
Notifications
You must be signed in to change notification settings - Fork 252
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
fix: simulator doesn't fail with long chains #385
Conversation
The core issue is that Block is essentially a linked list, so: * dropping it may SO * cloning it is linear and may SO Fix the drop manually and optimize the clone to be O(1) closes #379
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.
Awesome!
Awesome+1! |
@@ -87,7 +87,7 @@ impl GenesisConfig { | |||
|
|||
#[derive(Debug, Default, Clone)] | |||
pub struct Block { | |||
prev_block: Option<Box<Block>>, | |||
prev_block: Option<Arc<Block>>, |
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.
Do we actually need Arc
here? Would Rc
suffice?
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.
Good question, I haven't actually thought about this. I'd say that:
- both would probably work
- it doesn't really matter which one we pick here (like, this worked before by just copying the whole thing)
- Arc seems to be a better default choice, as that preserves Sync-ness of the Block
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 wonder if we use Box
recursively somewhere in nearcore as well
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.
@evgenykuzyakov nerdsniped! Here's the list of recursive types from nearcore:
rust-lang/rust-analyzer@ffd9283
Nothing there seems problematic.
Though, the tool is rather simplistic, it might've misssed some
The core issue is that Block is essentially a linked list, so:
Fix the drop manually and optimize the clone to be O(1)
closes #379