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

Why dBFT requires NeoGO package #2

Closed
im-kulikov opened this issue Nov 27, 2019 · 16 comments · Fixed by #94
Closed

Why dBFT requires NeoGO package #2

im-kulikov opened this issue Nov 27, 2019 · 16 comments · Fixed by #94
Labels
enhancement Improving existing functionality help wanted Extra attention is needed I4 No visible changes S1 Highly significant U4 Nothing urgent
Milestone

Comments

@im-kulikov
Copy link
Contributor

im-kulikov commented Nov 27, 2019

It's strange to understand that the dBFT package requires NeoGo, which requires dBFT.

I propose to move dependencies into the dBFT package.

That adds the possibility to use the package separately in other projects without NeoGo requirements.

cc @fyrchik @realloc @anatoly-bogatyrev @roman-khimov

@im-kulikov im-kulikov added help wanted Extra attention is needed question Further information is requested labels Nov 27, 2019
@roman-khimov
Copy link
Member

These are all modules, it makes no sense to shuffle them around. Just use modules from the origin repository that developed them.

That adds the possibility to use the package separately in other projects without NeoGo requirements.

I don't think this potential move would change anything.

@im-kulikov
Copy link
Contributor Author

I don't think this potential move would change anything.

That adds a possibility to ignore NeoGO mono repo as a dependency.

The dBFT used two types from NeoGO and only for that it requires it. That sounds strange.

@im-kulikov
Copy link
Contributor Author

My point is in moving or rewrites that types into dBFT and remove unnecessary dependencies.

@roman-khimov
Copy link
Member

That adds a possibility to ignore NeoGO mono repo as a dependency.

And that gives us like... what, really? It's not a linux repository, it's like 18M repository.

The dBFT used two types from NeoGO and only for that it requires it. That sounds strange.

Not so much, it reuses module that it needs to and that's it.

My point is in moving or rewrites that types into dBFT and remove unnecessary dependencies.

My point is that moving code between repositories completely destroys changes history and I just hate that.

And rewriting is like... please, don't. There is a module that implements exactly what you need, hoooray! just use it.

@im-kulikov
Copy link
Contributor Author

Not so much, it reuses module that it needs to and that's it.

Nope. It adds a lot of unnecessary dependencies from NeoGO module.

And that gives us like... what, really? It's not a Linux repository, it's like 18M repository.
Not so much, it reuses module that it needs to and that's it.

For two types I should import 18MB? It sounds ugly.

@im-kulikov
Copy link
Contributor Author

It was assumed that part of the NeoGO package (pkg) will be allocated to separate repositories. Now we are turning NeoGO into a mono repo. What then was the point of putting dBFT as a separate repository, if it still requires NeoGO?

@roman-khimov
Copy link
Member

roman-khimov commented Nov 27, 2019

Nope. It adds a lot of unnecessary dependencies from NeoGO module.

Like io module? That's the only one being added. And to be fair it's only added to satisfy data type, no code should be pulled from it.

For two types I should import 18MB? It sounds ugly.

That's git repository size, I don't think anyone cares about that. But you only really add one tiny module to the executable and that's it.

@roman-khimov
Copy link
Member

After discussion with @im-kulikov we've settled upon abstracting away this types with interfaces if there is a need to really separate this two repositories.

But looking at how these types are used (throughout the whole repository) it probably won't be that easy.

@im-kulikov
Copy link
Contributor Author

Yep. An interface would be a great decision.

@fyrchik
Copy link
Contributor

fyrchik commented Dec 2, 2019

What then was the point of putting dBFT as a separate repository, if it still requires NeoGO?

@im-kulikov to be able to use it from both neo-go and neofs.

@fyrchik
Copy link
Contributor

fyrchik commented Dec 2, 2019

Well, we can probably hide util.Uint* behind something like interface { Equal(..) bool } and require making wrappers in client, because function type can't be a subtype of another type.

But io package from neo-go simplifies marshalling a lot and makes it a lot more readable. It is used mostly for default implementations and we can get rid of it but then require client to implement all possible payloads. I'd rather prefer to be able to use a library that "just works" in simple cases and at the same time is rather flexible to be used in more picky situations.

@im-kulikov
Copy link
Contributor Author

But io package from neo-go simplifies marshalling a lot and makes it a lot more readable.

It's just syntactic sugar and I don't see any problems to use the binary package as is.

@im-kulikov
Copy link
Contributor Author

Well, we can probably hide util.Uint* behind something like interface { Equal(..) bool } and require making wrappers in client, because function type can't be a subtype of another type.

As we discuss with @roman-khimov, there is ok to use Hasher interface and returns the slice of bytes ([]byte). On the usage side, you can wrap it with an internal type as you want.

roman-khimov added a commit that referenced this issue Mar 14, 2023
models: adjust MoreThanFNodesCommitted check
@roman-khimov
Copy link
Member

I don't think we'll ever untie these.

@roman-khimov roman-khimov closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
@roman-khimov roman-khimov reopened this Dec 21, 2023
@roman-khimov roman-khimov added enhancement Improving existing functionality U4 Nothing urgent S2 Regular significance I4 No visible changes and removed question Further information is requested labels Dec 21, 2023
@fyfyrchik
Copy link

fyfyrchik commented Dec 21, 2023

I have cleaned modcache and after this I have:

$ go env GOPROXY
direct

$ go test -count=1 ./...
go: downloading github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09
crypto/hash.go:6:2: github.com/nspcc-dev/neo-go@v0.73.1-pre.0.20200303142215-f5a1b928ce09: invalid pseudo-version: preceding tag (v0.73.1-pre) not found
block/block.go:6:2: github.com/nspcc-dev/neo-go@v0.73.1-pre.0.20200303142215-f5a1b928ce09: invalid pseudo-version: preceding tag (v0.73.1-pre) not found

$ GOPROXY=proxy.golang.org go test -count=1 ./...
?       github.com/nspcc-dev/dbft/simulation    [no test files]
ok      github.com/nspcc-dev/dbft       0.007s
ok      github.com/nspcc-dev/dbft/block 0.003s
ok      github.com/nspcc-dev/dbft/crypto        0.003s
ok      github.com/nspcc-dev/dbft/merkle        0.003s
ok      github.com/nspcc-dev/dbft/payload       0.003s
ok      github.com/nspcc-dev/dbft/timer 1.304s

Makes me appreciate what Go team has done regarding versioning, though.

@roman-khimov
Copy link
Member

This can be useful for Bane, btw. As suggested in #87 the only real problem is util.Uint* types. Coincidentally, it'd be easier for us to use different native types there (avoiding conversion we have currently).

@roman-khimov roman-khimov added S1 Highly significant and removed S2 Regular significance labels Jan 30, 2024
AnnaShaleva added a commit that referenced this issue Feb 9, 2024
Implement custom payloads serialization using gob package. A part of #2.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 9, 2024
Implement custom payloads serialization using gob package. A part of #2.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 9, 2024
Implement custom payloads serialization using gob package. A part of #2.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use generics instead of util.Uint160 and util.Uint256
types for DBFT and related components. Keep util.Uint160 and util.Uint256
only for specific DBFT implementation in testing code.

The following regressions/behaviour changes were made to properly
apply generics:
1. `dbft.Option` alias is removed since type parameters can't be defined
   on aliases (generic type aliases are prohibited). Ref.
   golang/go#46477.
2. Default dBFT configuration is reduced: all payload-specific defaults
   are removed, as described in #91.
   It is done because default dBFT configuration should not depend on any
   implementation-specific hash type.
3. DBFT configuration validation check is extended wrt point 2.
4. The check if generic `dbft.DBFT` type implements generic `dbft.Service`
   interface is removed since such check should be performed on particular
   (non-generic) DBFT implementation.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use custom Hash/Address implementation, get rid of
util.Uint256/util.Uint160 NeoGo dependency.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2, not needed anymore.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva added this to the v0.2.0 milestone Feb 13, 2024
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use generics instead of util.Uint160 and util.Uint256
types for DBFT and related components. Keep util.Uint160 and util.Uint256
only for specific DBFT implementation in testing code.

The following regressions/behaviour changes were made to properly
apply generics:
1. `dbft.Option` alias is removed since type parameters can't be defined
   on aliases (generic type aliases are prohibited). Ref.
   golang/go#46477.
2. Default dBFT configuration is reduced: all payload-specific defaults
   are removed, as described in #91.
   It is done because default dBFT configuration should not depend on any
   implementation-specific hash type.
3. DBFT configuration validation check is extended wrt point 2.
4. The check if generic `dbft.DBFT` type implements generic `dbft.Service`
   interface is removed since such check should be performed on particular
   (non-generic) DBFT implementation.
5. `dbft.Service` interface is removed since it's unused.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use custom Hash/Address implementation, get rid of
util.Uint256/util.Uint160 NeoGo dependency.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2, not needed anymore.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use generics instead of util.Uint160 and util.Uint256
types for DBFT and related components. Keep util.Uint160 and util.Uint256
only for specific DBFT implementation in testing code.

The following regressions/behaviour changes were made to properly
apply generics:
1. `dbft.Option` alias is removed since type parameters can't be defined
   on aliases (generic type aliases are prohibited). Ref.
   golang/go#46477.
2. Default dBFT configuration is reduced: all payload-specific defaults
   are removed, as described in #91.
   It is done because default dBFT configuration should not depend on any
   implementation-specific hash type.
3. DBFT configuration validation check is extended wrt point 2.
4. The check if generic `dbft.DBFT` type implements generic `dbft.Service`
   interface is removed since such check should be performed on particular
   (non-generic) DBFT implementation.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use custom Hash/Address implementation, get rid of
util.Uint256/util.Uint160 NeoGo dependency.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2, not needed anymore.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use generics instead of util.Uint160 and util.Uint256
types for DBFT and related components. Keep util.Uint160 and util.Uint256
only for specific DBFT implementation in testing code.

The following regressions/behaviour changes were made to properly
apply generics:
1. `dbft.Option` alias is removed since type parameters can't be defined
   on aliases (generic type aliases are prohibited). Ref.
   golang/go#46477.
2. Default dBFT configuration is reduced: all payload-specific defaults
   are removed, as described in #91.
   It is done because default dBFT configuration should not depend on any
   implementation-specific hash type.
3. DBFT configuration validation check is extended wrt point 2.
4. The check if generic `dbft.DBFT` type implements generic `dbft.Service`
   interface is removed since such check should be performed on particular
   (non-generic) DBFT implementation.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2. Use custom Hash/Address implementation, get rid of
util.Uint256/util.Uint160 NeoGo dependency.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
AnnaShaleva added a commit that referenced this issue Feb 13, 2024
A part of #2, not needed anymore.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving existing functionality help wanted Extra attention is needed I4 No visible changes S1 Highly significant U4 Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants