Conversation
| pub fn init(allocator: Allocator, config: configs.ChainConfig, anchorState: types.BeamState) !Self { | ||
| const fork_choice = try fcFactory.ForkChoice.init(allocator, config, anchorState); | ||
|
|
||
| var states = std.AutoHashMap(types.Root, types.BeamState).init(allocator); |
There was a problem hiding this comment.
I don't see deinit being called anywhere
There was a problem hiding this comment.
yes, will add later for now it doesn't matter as it's life is as long as program run
pkgs/types/src/lib.zig
Outdated
| // a super hacky cloning utility for ssz - replace by a better mechanis | ||
| // should be upstreated into the ssz lib even with a proper impl | ||
| pub fn sszClone(allocator: Allocator, comptime T: type, data: T) !T { | ||
| var bytes = std.ArrayList(u8).init(std.testing.allocator); | ||
| defer bytes.deinit(); | ||
|
|
||
| try ssz.serialize(T, data, &bytes); | ||
| var cloned: T = undefined; | ||
| try ssz.deserialize(T, bytes.items[0..], &cloned, allocator); | ||
| return cloned; | ||
| } | ||
|
|
There was a problem hiding this comment.
ouch, you weren't lying when you said this is hacky. Could it be possible to not do the SSZ serialization and simply implement a clone function on BeamState? That could simply start being just this function, but over time would evolve to be a proper cloning function? I just can't imagine this approach being very efficient (I agree it's easy to maintain, though)
There was a problem hiding this comment.
yes thats the plan to move to a proper function
pkgs/node/src/chain.zig
Outdated
|
|
||
| const BlockProcessingError = error{MissingPreState}; | ||
|
|
||
| test "build mock chain" { |
There was a problem hiding this comment.
I suggest changing this description to explain what is being tested, I'm pretty sure all of our tests will be building a mock chain
* add 3sf forkchoice to apply votes and choose head * some preliminary setup * enrich mock data * update test * add ssz clone util * setup beamchain processing * basic block processing * add vote processing skeleton * track the latest votes * compute deltas * calc and apply deltas due to votes * some restructuring and add justified to fcstore * update head completion * complete fix update head * fcstore checkpoint update * add head tracking to mockchain and match it against fchead in the beam chain test * apply feedback * improv comment
WIP -
(prev PR #27 got closed by mistaken deletion of the branch whhile doing branch cleanuP)