Skip to content
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

Consider changing BlockSyncStorage interface in block sync to rely on GetLastCommittedBlockHeight instead of LastCommittedBlockHeight #338

Closed
talkol opened this issue Oct 20, 2018 · 7 comments
Assignees

Comments

@talkol
Copy link
Member

talkol commented Oct 20, 2018

The block sync separate unit relies on the block storage service via this interface:

type BlockSyncStorage interface {
	LastCommittedBlockHeight() primitives.BlockHeight
	CommitBlock(ctx context.Context, input *services.CommitBlockInput) (*services.CommitBlockOutput, error)
	ValidateBlockForCommit(ctx context.Context, input *services.ValidateBlockForCommitInput) (*services.ValidateBlockForCommitOutput, error)
}

Most of these functions are public functions of the service defined in the service proto defining its public well-known interface.

The only exception is LastCommittedBlockHeight.

The service has a public known function in the protos called GetLastCommittedBlockHeight. This function also takes the context. Consider for esthetic reasons to switch to it instead of the internal version LastCommittedBlockHeight.

This would also enable us to make LastCommittedBlockHeight lowercase and not exported. It's a smell to export service methods that aren't defined in the protos.

@netoneko
Copy link
Contributor

It was done because there is a lot of boxing/unboxing one has to do in case of calling GetLastCommittedBlockHeight vs LastCommittedBlockHeight. Of course we could move this boxing/unboxing into block sync instead of keeping it inside of the block storage.

@jlevison
Copy link
Contributor

acutally this got me looking at the code and i found a bug in GetLastCommittedBlockHeight .. the return value holds both height and timestamp, and there exists a case where it would return the wrong timestamp for the requested block (race condition) - i'll fix that, and i will play around with refactoring as the issue describes here and see how it feels

@jlevison
Copy link
Contributor

jlevison commented Nov 5, 2018

@talkol , this is waiting for a spec change as we discussed, see orbs-network/orbs-spec#107

@jlevison jlevison assigned OdedWx and unassigned jlevison Nov 5, 2018
@jlevison
Copy link
Contributor

@tal, asking as i cannot remember right now, you decided this should not be changed and the tests were changed, LastCommittedBlockHeight was removed as far as i know, right?

@electricmonk
Copy link
Contributor

@ronnno please evaluate and either close or assign for Q32019 milestone

@OdedWx
Copy link
Contributor

OdedWx commented Jun 10, 2019

Will close the discussion in spec #109.

@ronnno
Copy link
Contributor

ronnno commented Jun 12, 2019

This issue is stale. was fixed by @danokoch in rev 0346001 on 2018-11-05

@ronnno ronnno closed this as completed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants