go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

3315 Genesis address format - address size and type change

Open abergasov opened this issue 3 years ago • 25 comments

Motivation

Closes #3315

Changes

  • address moved to separate pkg. probably in future will be as independent library
  • address still array of bytes ([24]byte), but implement bech32 algorithm. Additional first byte reserved for contain HumanReadablePart of address (now contain info about networkID - test|main net), so result is [25]byte
  • all api endpoints will be changed to use string instead []byte (related pr https://github.com/spacemeshos/api/pull/173)

Test Plan

unit tests

TODO

  • [ ] Explain motivation or link existing issue(s)
  • [ ] Test changes and document test plan
  • [ ] Update documentation as needed

DevOps Notes

  • [ ] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
  • [ ] This PR does not affect public APIs
  • [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
  • [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)

abergasov avatar Jul 06 '22 13:07 abergasov

could you please use aliases for such refactoring?

package types

type Address = address.Address

they were created specifically to make such changes reviewable

dshulyak avatar Jul 27 '22 15:07 dshulyak

why cosmos/bech32 and not one from btcd repo? are they different?

source code almost the same. small difference between const|wrappers, but in generally code the same. it can easy replaced by fixing go.mod

i chose cosmos cause it's approach - to get necessary functions and types, for crypto projects. in case btcd repo - we need to vendor other blockchein implementation, that's look little bit weird for me.

abergasov avatar Aug 01 '22 17:08 abergasov

i am generally surprised by the number of files changed for this PR.

what is the advantage of having a separate pkg for address? in another words, what is the disadvantage of maintaining the flat structure inside common/types?

alias type Address = address.Address in common/type reduce total edited files =)

one of idea was to move address implementation to separate library, which will be included as dependency. in this case i moved to nested pkg. when we will publish as single library - just change imports

abergasov avatar Aug 01 '22 19:08 abergasov

one of idea was to move address implementation to separate library, which will be included as dependency

This is not a terrible idea - do we think other projects will have this dependency? (And would they want to use just an address module without relying on all of go-spacemesh?) E.g., sm-repl, dash/explorer, etc.

lrettig avatar Aug 01 '22 19:08 lrettig

one of idea was to move address implementation to separate library, which will be included as dependency

This is not a terrible idea - do we think other projects will have this dependency? (And would they want to use just an address module without relying on all of go-spacemesh?) E.g., sm-repl, dash/explorer, etc.

but why? what is the problem with having the impl inside common/types/address.go? the functionality you are providing in the new pkg look highly similar to the old ones. @abergasov

countvonzero avatar Aug 01 '22 19:08 countvonzero

This is not a terrible idea - do we think other projects will have this dependency? (And would they want to use just an address module without relying on all of go-spacemesh?) E.g., sm-repl, dash/explorer, etc.

there is no strong arguments that we should move it to separate pkg, only this 2:

  1. our possibly moving address in separate lib in future
  2. current situation in common/types, where we have 25 different files aka 25 different types (there are total 33 files with tests) and some of this files contains lot of code - this look like place where we can add more pkg separation and make it more strict

if you think that it better move back to common/types - ok, i'll do. arguments for separate pkg not very strong

abergasov avatar Aug 01 '22 19:08 abergasov

This is not a terrible idea - do we think other projects will have this dependency? (And would they want to use just an address module without relying on all of go-spacemesh?) E.g., sm-repl, dash/explorer, etc.

there is no strong arguments that we should move it to separate pkg, only this 2:

  1. our possibly moving address in separate lib in future

i think this is a future thing and should be separated from this discussion.

  1. current situation in common/types, where we have 25 different files aka 25 different types (there are total 33 files with tests) and some of this files contains lot of code - this look like place where we can add more pkg separation and make it more strict

right. but changing only 1 makes it even more confusing. i'd support if you make a sweeping change later to change all of them. but the code inside each file (tho large) are mostly very simple code... i personally don't think it's worth the effort now.

if you think that it better move back to common/types - ok, i'll do. arguments for separate pkg not very strong

that will be my preference. and worry about separate library when the use case arise.

countvonzero avatar Aug 01 '22 19:08 countvonzero

bors try

dshulyak avatar Aug 03 '22 10:08 dshulyak

try

Build failed:

bors[bot] avatar Aug 03 '22 11:08 bors[bot]

bors try

abergasov avatar Aug 03 '22 16:08 abergasov

try

Build failed:

bors[bot] avatar Aug 03 '22 17:08 bors[bot]

what about system tests?

dshulyak avatar Aug 04 '22 06:08 dshulyak

what about system tests?

it fails in same place cluster.Reuse with ctx timeout. Probably node fails to start in case invalid genessis|coinbase accounts

abergasov avatar Aug 04 '22 08:08 abergasov

bors try

abergasov avatar Aug 04 '22 16:08 abergasov

try

Build succeeded:

bors[bot] avatar Aug 04 '22 17:08 bors[bot]

bors try

abergasov avatar Aug 08 '22 10:08 abergasov

try

Build failed:

bors[bot] avatar Aug 08 '22 11:08 bors[bot]

bors try

abergasov avatar Aug 08 '22 13:08 abergasov

try

Build succeeded:

bors[bot] avatar Aug 08 '22 14:08 bors[bot]

bors merge

abergasov avatar Aug 09 '22 09:08 abergasov

:-1: Rejected by code reviews

bors[bot] avatar Aug 09 '22 09:08 bors[bot]

bors merge

abergasov avatar Aug 09 '22 10:08 abergasov

:-1: Rejected by code reviews

bors[bot] avatar Aug 09 '22 10:08 bors[bot]

bors try

abergasov avatar Aug 09 '22 19:08 abergasov

try

Build succeeded:

bors[bot] avatar Aug 09 '22 20:08 bors[bot]

i thought that it was merged. is there any reason why it is still open?

dshulyak avatar Aug 16 '22 09:08 dshulyak

bors try

abergasov avatar Aug 16 '22 10:08 abergasov

try

Build succeeded:

bors[bot] avatar Aug 16 '22 12:08 bors[bot]

bors merge

abergasov avatar Aug 16 '22 12:08 abergasov

Pull request successfully merged into develop.

Build succeeded:

bors[bot] avatar Aug 16 '22 13:08 bors[bot]