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
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
268a97f
migrate : governance-contract
felix-shin-wt May 16, 2024
406f0c4
panic: core.GenerateChain
felix-shin-wt May 22, 2024
f4a9c06
fix: test panic
egonspace May 22, 2024
34c9455
fix : FakeMode, escape futureBlock
felix-shin-wt May 24, 2024
ef1e67d
fix : panic bad block
felix-shin-wt May 28, 2024
c91f6ac
refact : mv wemix_backends -> wemix package
felix-shin-wt May 28, 2024
0591aea
refact : remove common/bn
felix-shin-wt May 28, 2024
5bd98c3
refact : GovContracts
felix-shin-wt May 29, 2024
d4b4368
fix : remove unused
felix-shin-wt May 29, 2024
14f0489
Merge branch 'dev' into feat/governance-simulationbackend
felix-shin-wt May 29, 2024
277407a
fix : rename confusing variable
felix-shin-wt May 29, 2024
8f55544
fix : unhandled error
felix-shin-wt May 29, 2024
2a13ec5
fix : code style
felix-shin-wt May 30, 2024
f7bb72a
refact: migrate openzeppelin contract:v4.6.0, contracts-upgrade:v4.7.0
felix-shin-wt May 30, 2024
4e39897
feat : update governancedeploy use wemix/bind
felix-shin-wt May 30, 2024
42e0ace
fix : remove unused
felix-shin-wt May 30, 2024
8d130ab
fix : default init envstorage values
felix-shin-wt May 31, 2024
6bd6aaf
fix : gwemix.sh
felix-shin-wt May 31, 2024
f482f1a
fix : compare fixed bytes
felix-shin-wt May 31, 2024
55e90e7
fix : compare fixed bytes
felix-shin-wt May 31, 2024
b89bc2e
fix : typo
felix-shin-wt May 31, 2024
c195e54
fix : Flag type
felix-shin-wt May 31, 2024
9c5dae9
feat : update genesisConfig
felix-shin-wt May 31, 2024
1c4100d
fix : remove unused code
felix-shin-wt May 31, 2024
befb235
fix : deploy log
felix-shin-wt May 31, 2024
b4572da
feat : wemix simulated OptionFn
felix-shin-wt May 31, 2024
df4684c
feat : install solc
felix-shin-wt Jun 3, 2024
3130e56
Merge branch 'feat/governance-simulationbackend' into feat/deploy-gov…
felix-shin-wt Jun 3, 2024
47c57b6
fix : typo
felix-shin-wt Jun 3, 2024
95eb72f
fix : typo
felix-shin-wt Jun 3, 2024
bb298bb
Merge branch 'feat/governance-simulationbackend' into feat/deploy-gov…
felix-shin-wt Jun 3, 2024
9137384
fix : error verifyBlockSig
felix-shin-wt Jun 3, 2024
c2d8e44
fix : remove unused file
felix-shin-wt Jun 3, 2024
dcdf721
fix : gwemix.sh
felix-shin-wt Jun 3, 2024
708228b
fix: go.mod
felix-shin-wt Jun 3, 2024
dc29a65
update governance deploy (#96)
felix-shin-wt Jun 4, 2024
87d3221
refact : using bind structs
felix-shin-wt Jun 4, 2024
a4c1c89
docs : gwemix.sh comment
felix-shin-wt Jun 5, 2024
e6d0ce6
refact : submodule openzeppelin
felix-shin-wt Jun 5, 2024
12c8e74
feat : using NCPExit
felix-shin-wt Jun 5, 2024
752b49f
Refact governance simulationbackend (#107)
felix-shin-wt Jun 7, 2024
5c3b855
wip : dev-ci
felix-shin-wt Jun 7, 2024
eaee291
fix : unuse generic
felix-shin-wt Jun 7, 2024
f7ee599
fix : TestWemixBackends$
felix-shin-wt Jun 7, 2024
0da8bb6
feat : using generic, remove lint_test [email protected]
felix-shin-wt Jun 17, 2024
1e8f79c
fix: go:generate
felix-shin-wt Jun 17, 2024
5d04149
fix : clean code
felix-shin-wt Jun 17, 2024
9be03e1
fix : remove comment
felix-shin-wt Jun 17, 2024
e901f4d
fix : clean code
felix-shin-wt Jun 18, 2024
62f6725
feat : (governance abigen) compare data before writing to the file
felix-shin-wt Jun 18, 2024
c4052f4
refact : using compiledTy
felix-shin-wt Jun 18, 2024
1cafddd
feat : include sigs wemix/bind contracts
felix-shin-wt Jun 18, 2024
9e06591
refacet : move compiled, remove simulated-backend
felix-shin-wt Jun 20, 2024
27c85f5
fix : clean code
felix-shin-wt Jun 20, 2024
2d2c950
fix : clean code
felix-shin-wt Jun 23, 2024
ed75adf
fix : detailed tick processing
felix-shin-wt Jun 24, 2024
01b10ae
feat : [init-gov] add option password
felix-shin-wt Jun 25, 2024
0b564d1
fix : gwemix.sh init-gov params
felix-shin-wt Jun 25, 2024
b3df4c2
fix : [init-gov] add option password
felix-shin-wt Jun 25, 2024
97a0a72
refact : use const
felix-shin-wt Jun 25, 2024
a255d56
fix : use constant
felix-shin-wt Jun 26, 2024
9b1ea37
fix : loadGenesisConfig
felix-shin-wt Jun 26, 2024
b71ab4b
fix : check bootnodeExists
felix-shin-wt Jun 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [1.17, 1.18, 1.19]
version: [1.18, 1.19]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand All @@ -38,7 +38,7 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.version }}

- name: Check Lint
run: make lint

Expand All @@ -49,6 +49,9 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Wemix Submodules
run: git submodule update --init wemix/

- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/gwemix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [1.17, 1.18, 1.19]
version: [1.18, 1.19]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand All @@ -49,6 +49,9 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Wemix Submodules
run: git submodule update --init wemix/

- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/master-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [1.17, 1.18, 1.19]
version: [1.18, 1.19]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand All @@ -49,6 +49,9 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Wemix Submodules
run: git submodule update --init wemix/

- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@
[submodule "etcd"]
path = etcd
url = https://github.com/metadium/etcd
[submodule "wemix/governance-contract/contracts/openzeppelin/contracts-upgradeable"]
path = wemix/governance-contract/contracts/openzeppelin/contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "wemix/governance-contract/contracts/openzeppelin/contracts"]
path = wemix/governance-contract/contracts/openzeppelin/contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
79 changes: 5 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ endif

gwemix.tar.gz: gwemix logrot
@[ -d build/conf ] || mkdir -p build/conf
@cp -p wemix/scripts/gwemix.sh wemix/scripts/solc.sh build/bin/
@cp -p wemix/scripts/gwemix.sh build/bin/
@cp -p wemix/scripts/config.json.example \
wemix/scripts/genesis-template.json \
wemix/contracts/WemixGovernance.js \
wemix/scripts/deploy-governance.js \
build/conf/
@(cd build; tar cfz gwemix.tar.gz bin conf)
@echo "Done building build/gwemix.tar.gz"

gwemix: rocksdb wemix/governance_abi.go
gwemix: rocksdb
ifeq ($(USE_ROCKSDB), NO)
$(GORUN) build/ci.go install $(ROCKSDB_TAG) ./cmd/gwemix
else
Expand Down Expand Up @@ -68,7 +66,7 @@ else
$(GORUN) build/ci.go install $(ROCKSDB_TAG) ./cmd/dbbench
endif

all: wemix/governance_abi.go
all:
$(GORUN) build/ci.go install

android:
Expand All @@ -89,12 +87,12 @@ test: all
test-short: all
$(GORUN) build/ci.go test -short

lint: wemix/governance_abi.go ## Run linters.
lint: ## Run linters.
$(GORUN) build/ci.go lint

clean:
env GO111MODULE=on go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/* build/conf wemix/admin_abi.go wemix/governance_abi.go
rm -fr build/_workspace/pkg/ $(GOBIN)/* build/conf
@ROCKSDB_DIR=$(ROCKSDB_DIR); \
if [ -e $${ROCKSDB_DIR}/Makefile ]; then \
cd $${ROCKSDB_DIR}; \
Expand Down Expand Up @@ -132,70 +130,3 @@ rocksdb:
@[ ! -e rocksdb/.git ] && git submodule update --init rocksdb; \
cd $(ROCKSDB_DIR) && PORTABLE=1 make -j8 static_lib;
endif

AWK_CODE=' \
BEGIN { print "package wemix"; bin = 0; name = ""; abi = ""; } \
/^{/ { bin = 1; abi = ""; name = ""; } \
/^}/ { bin = 0; abi = abi "}"; print "var " name "Abi = `" abi "`"; } \
{ \
if (bin == 1) { \
abi = abi $$0; \
if ($$1 == "\"contractName\":") { \
name = $$2; \
gsub(",|\"", "", name); \
} \
} \
}'

wemix/admin_abi.go: wemix/contracts/WemixAdmin-template.sol build/bin/solc
@PATH=${PATH}:build/bin wemix/scripts/solc.sh -f abi $< /tmp/junk.$$$$; \
cat /tmp/junk.$$$$ | awk $(AWK_CODE) > $@; \
rm -f /tmp/junk.$$$$;

AWK_CODE_2=' \
BEGIN { print "package wemix\n"; } \
/^var Registry_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Registry"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var StakingImp_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Staking"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var EnvStorageImp_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "EnvStorageImp"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var GovImp_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Gov"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
}'

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

ifneq ($(shell uname), Linux)

build/bin/solc:
@test 1

else

SOLC_URL=https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux
build/bin/solc:
@[ -d build/bin ] || mkdir -p build/bin; \
if [ ! -x build/bin/solc ]; then \
if which curl > /dev/null 2>&1; then \
curl -Ls -o build/bin/solc $(SOLC_URL); \
chmod +x build/bin/solc; \
elif which wget > /dev/null 2>&1; then \
wget -nv -o build/bin/solc $(SOLC_URL); \
chmod +x build/bin/solc; \
fi \
fi

endif
15 changes: 15 additions & 0 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -72,6 +73,20 @@ type SimulatedBackend struct {
config *params.ChainConfig
}

func NewSimulatedBackendWithEthereum(e *eth.Ethereum) *SimulatedBackend {
database := e.ChainDb()
blockchain := e.BlockChain()

backend := &SimulatedBackend{
database: database,
blockchain: blockchain,
config: blockchain.Config(),
events: filters.NewEventSystem(&filterBackend{database, blockchain}, false),
}
backend.rollback(blockchain.CurrentBlock())
return backend
}

// NewSimulatedBackendWithDatabase creates a new binding backend based on the given database
// and uses a simulated blockchain for testing purposes.
// A simulated backend always uses chainID 1337.
Expand Down
Loading
Loading