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

Migrate governance-contracts #89

Merged
merged 63 commits into from
Jul 3, 2024
Merged

Conversation

felix-shin-wt
Copy link

  1. The version control for the governance-contract is managed in go-wemix. (commit: e04c2b07fd0d773cc3e07cacddadd182074a1863)
    go-wemix/wemix/governance-contract
    1-1. The contract code, excluding the hardhat part, was copied to go-wemix/wemix/governance-contract/contracts.
    1-2. Test code to verify the operation was written in Golang and can be found at go-wemix/wemix/governance-contracts/test.

  2. The contract bound in the wemix package is used.
    go-wemix/wemix/bind
    2-1. The code for binding the contract was done in go-wemix/wemix/governance-contract/contracts/abigen.go.
    2-2. All instances of using 'metclient.RemoteContract' were removed and replaced with the bound contract.

  3. A 'SimulatedBackend' including the governance-contract was created.
    'go-wemix/wemix/bind/backends'
    3-1. Functions were added and some were modified in 'go-wemix/accounts/abi/bind/backends'.
    3-2. Modifications were made to prevent errors from occurring when adding a future block in simulation mode (ModeFake of ethash).

@jed-wemade
Copy link

jed-wemade commented May 29, 2024

ABIs in wemix/governance_abi.go is generated based on wemix/contracts/WemixGovernance.js. (The abi definitions are used in wemix/admin.go)

wemix/governance_abi.go: wemix/contracts/WemixGovernance.js
	@cat $< | awk $(AWK_CODE_2) > $@

Currently, the js file must be updated manually whenever governance contracts are changed.
For smoother integration, I suggest change Makefile updating the js file or generating abi.go directly by compiling governance contracts.

This PR makes wemix/admin.go no longer use wemix/governance_abi.go.
So generating abi.go is not needed anymore.

wemix/admin.go Outdated Show resolved Hide resolved
wemix/admin.go Outdated Show resolved Hide resolved
wemix/admin.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@egonspace egonspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cmd/geth/wemixcmd.go Show resolved Hide resolved
cmd/geth/wemixcmd.go Outdated Show resolved Hide resolved
wemix/bind/backends/wemix_simulated_test.go Outdated Show resolved Hide resolved
wemix/bind/backends/wemix_simulated_test.go Show resolved Hide resolved
wemix/bind/backends/wemix_simulated_test.go Outdated Show resolved Hide resolved
wemix/metclient/util.go Outdated Show resolved Hide resolved
wemix/governance-contract/test/contracts.go Outdated Show resolved Hide resolved
@steve-oh-wt
Copy link

To ensure compile-time checking for commonly used contract names, it would be beneficial to declare them as constants.
("Registry" "Gov", "GovImp", "NCPExit", "NCPExitImp" "Staking", "StakingImp", "BallotStorage", "BallotStorageImp", "EnvStorage", "EnvStorageImp")

const (
    Registry         = "Registry"
    Gov              = "Gov"
    GovImp           = "GovImp"
    NCPExit          = "NCPExit"
    NCPExitImp       = "NCPExitImp"
    Staking          = "Staking"
    StakingImp       = "StakingImp"
    BallotStorage    = "BallotStorage"
    BallotStorageImp = "BallotStorageImp"
    EnvStorage       = "EnvStorage"
    EnvStorageImp    = "EnvStorageImp"
)

@jed-wemade
Copy link

In Ethereum, error is created by errors.New() for simple messages and fmt.Errorf() for formatted messages.
Also "pkg/errors" package is no longer maintained (pkg/errors#245) so I recommend to replace the package with "errors" standard library.

Currently, the below codes use "github.com/pkg/errors".

  • wemix/bind/structs.go
  • wemix/governance-contract/test/contracts.go
  • wemix/governance-contract/compiler.go
  • wemix/admin.go

cmd/geth/wemixcmd.go Outdated Show resolved Hide resolved
@felix-shin-wt felix-shin-wt merged commit 71325e9 into dev Jul 3, 2024
4 checks passed
jennwiederholen added a commit that referenced this pull request Sep 12, 2024
* Add release ci (#102)

* Create release.yml

* fix: typo

* fix: remove sha

* fix: specify ubuntu version in ci files

* fix: setup packages in ci files to match dependency

* fix: integrate file name rule to keep consistency between ci files

* fix: use gwemix version instead of ref name

* feat: update snapshot pending state

* Migrate governance-contracts (#89)

* migrate : governance-contract

* panic: core.GenerateChain

* fix: test panic

* fix : FakeMode, escape futureBlock

* fix : panic bad block

* refact : mv wemix_backends -> wemix package

* refact : remove common/bn

* refact : GovContracts

* fix : remove unused

* fix : rename confusing variable

* fix : unhandled error

* fix : code style

* refact: migrate openzeppelin contract:v4.6.0, contracts-upgrade:v4.7.0

* feat : update governancedeploy use wemix/bind

* fix : remove unused

* fix : default init envstorage values

* fix : gwemix.sh

* fix : compare fixed bytes

* fix : compare fixed bytes

* fix : typo

* fix : Flag type

* feat : update genesisConfig

* fix : remove unused code

* fix : deploy log

* feat : wemix simulated OptionFn

* feat : install solc

* fix : typo

* fix : typo

* fix : error verifyBlockSig

* fix : remove unused file

* fix : gwemix.sh

* fix: go.mod

* refact : using bind structs

* docs : gwemix.sh comment

* refact : submodule openzeppelin

* feat : using NCPExit

* wip : dev-ci

* fix : unuse generic

* fix : TestWemixBackends$

* feat : using generic, remove lint_test [email protected]

* fix: go:generate

* fix : clean code

* fix : remove comment

* fix : clean code

* feat : (governance abigen) compare data before writing to the file

* refact : using compiledTy

* feat : include sigs wemix/bind contracts

* refacet : move compiled, remove simulated-backend

* fix : clean code

* fix : clean code

* fix : detailed tick processing

* feat : [init-gov] add option password

* fix : gwemix.sh init-gov params

* fix : [init-gov] add option password

* refact : use const

* fix : use constant

* fix : loadGenesisConfig

* fix : check bootnodeExists

---------

Co-authored-by: egonspace <[email protected]>

* fix : call staker address (#114)

fix : get contracts address StakingReward domain

* Feat: add local test scripts (#113)

* migrate : governance-contract

* panic: core.GenerateChain

* fix: test panic

* fix : FakeMode, escape futureBlock

* fix : panic bad block

* refact : mv wemix_backends -> wemix package

* refact : remove common/bn

* refact : GovContracts

* fix : remove unused

* fix : rename confusing variable

* fix : unhandled error

* fix : code style

* refact: migrate openzeppelin contract:v4.6.0, contracts-upgrade:v4.7.0

* feat : update governancedeploy use wemix/bind

* fix : remove unused

* fix : default init envstorage values

* fix : gwemix.sh

* fix : compare fixed bytes

* fix : compare fixed bytes

* fix : typo

* fix : Flag type

* feat : update genesisConfig

* fix : remove unused code

* fix : deploy log

* feat : wemix simulated OptionFn

* feat : install solc

* fix : typo

* fix : typo

* fix : error verifyBlockSig

* fix : remove unused file

* fix : gwemix.sh

* fix: go.mod

* refact : using bind structs

* docs : gwemix.sh comment

* refact : submodule openzeppelin

* feat : using NCPExit

* wip : dev-ci

* fix : unuse generic

* fix : TestWemixBackends$

* feat : using generic, remove lint_test [email protected]

* fix: go:generate

* fix : clean code

* fix : remove comment

* fix : clean code

* feat : (governance abigen) compare data before writing to the file

* refact : using compiledTy

* feat : include sigs wemix/bind contracts

* refacet : move compiled, remove simulated-backend

* fix : clean code

* fix : clean code

* fix : detailed tick processing

* Feat: add local test scripts

* Fix: minor fix

* feat : [init-gov] add option password

* fix : gwemix.sh init-gov params

* Chore: typo fix

* fix : [init-gov] add option password

* Fix: fix set-nodekey.sh

* Chore: push for test

* refact : use const

* Feat: add init-boot.sh

* Fix: minor fix

* chore: minor typo

* chore: add waiting message for port to open in init-boot.sh

* Chore: minor test

* chore: improve waiting message for port to open in init-boot.sh

* feat: add executable permission to gwemix.sh in init-boot.sh

* chore: improve gwemix start confirmation in init-boot.sh

* chore: update log file path and success message in init-boot.sh

* chore: Update init-boot.sh to improve gwemix start confirmation

* chore: Add pcscd service to Dockerfile.local.boot and start it in init-boot.sh

* chore: Update init-boot.sh to start gwemix service and improve start confirmation

* chore: Update Dockerfile and gen-docker-compose.sh for wemix node configuration

* chore: Refactor key generation and configuration scripts

* chore: Clean up unnecessary files and improve entrypoint in Dockerfile.local.boot and Dockerfile.local.node

* chore: Update init-boot.sh to start gwemix service and improve start confirmation

* chore: Update init-boot.sh to improve gwemix start confirmation

* chore: Update Makefile and Dockerfile.local.boot to include init-node.sh in build process

* chore: Update init-node.sh to check if the boot node has started before executing commands

* chore: Update init-node.sh to include datadir for wemix

* chore: Improve gwemix start confirmation and add etcd initialization

* chore: Update init-boot.sh to use console command for etcd initialization

* chore: Add curl and netcat-traditional to Dockerfile

* chore: Refactor local-docker-env scripts for key generation and configuration

* chore: Update Makefile-local-env to include wemix configuration files in build process

* Feat: Refactor local-docker-env scripts for key generation and configuration

* Chore: revert makefile

* chore: Update local-docker-env scripts for key generation and configuration

* chore: Update Dockerfile to include missing command for updating CA certificates

* chore: change local test readme to english

* chore: Refactor local-docker-env scripts for key generation and configuration

* chore: Update Dockerfile to use specified Ubuntu version in the Docker image

---------

Co-authored-by: felix-shin-wt <[email protected]>
Co-authored-by: egonspace <[email protected]>
Co-authored-by: felix-shin-wt <[email protected]>

* add .prettierrc [solidity formatter] (#115)

* feat : add prettierrc

* fix : remove unuseful comment

* [add proposal type] governance general purpose (#116)

* feat : add execute

* fix : upgrade issue

* test : execute

* feat : append gap

* fix : gap size

* fix : [execute fail] return value

* fix : typo

* fix : typo

* feat : test code

* feat : gov abigen

* fix: update rocksdb to v6.28.2 (#120)

fix: update rocksdb v6.27.3 -> v6.28.2

* fix : remove memsize (#122)

* Feat: remove mem-size to support go1.23

* Fix: remove memsize from mobile/geth

* feat: add eth 68 protocol (#117)

* fix: eth 68 protocol

* fix: test failure

* fix: test failure

* fix: protocol name for eth68

* fix: support eth protocol name

* fix: lint error

* fix: use  protocol name when handshaking

* fix: protocol name

* fix: protocol match bug

* fix: not load NCPExit contract

* fix: apply comment

* Feat: version patch to 9 (#126)

:Feat: version patch to 9

---------

Co-authored-by: jed-wemade <[email protected]>
Co-authored-by: egonspace <[email protected]>
Co-authored-by: felix-shin-wt <[email protected]>
Co-authored-by: egonspace <[email protected]>
Co-authored-by: paul ahn <[email protected]>
Co-authored-by: felix-shin-wt <[email protected]>
This was referenced Oct 8, 2024
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

Successfully merging this pull request may close these issues.

5 participants