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

Upgrade validator smart contract #450

Open
wants to merge 146 commits into
base: dev-upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
dae2413
Update XDCValidator.sol
GalaxySciTech Feb 26, 2024
34a5765
update
GalaxySciTech Mar 4, 2024
d6c9288
Update XDCValidatorV2.sol
GalaxySciTech Mar 6, 2024
4443e4c
xdv-01
GalaxySciTech Mar 12, 2024
72b56b0
Update XDCValidatorV2.sol
GalaxySciTech Mar 12, 2024
72418e6
xdv-06
GalaxySciTech Mar 12, 2024
e4ab783
xdv-06
GalaxySciTech Mar 12, 2024
4e0b890
xdv-01
GalaxySciTech Mar 14, 2024
4342984
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
6edecf3
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
1d51654
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
76036fd
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
407cdf0
xdv-06
GalaxySciTech Mar 19, 2024
2fc7af4
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
7f2fe50
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
6efc12b
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
b52721f
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
881b4d0
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
cd8901d
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
ae5a5e4
upgrade solidity version to 0.4.26 and add revert mssage
GalaxySciTech Mar 22, 2024
118abf6
change constructor
GalaxySciTech Mar 22, 2024
ab456e7
Update XDCValidatorV2.sol
GalaxySciTech Mar 22, 2024
38fa42d
Update XDCValidatorV2.sol
GalaxySciTech Mar 22, 2024
2d586d8
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
a0f4cf4
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
19562cc
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
1bbf4d2
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
ca80218
Update XDCValidatorV2.sol
GalaxySciTech Mar 26, 2024
21fce80
Update XDCValidatorV2.sol
GalaxySciTech Apr 17, 2024
45fc919
Update XDCValidatorV2.sol
GalaxySciTech Apr 18, 2024
492c16c
Update XDCValidatorV2.sol
GalaxySciTech Apr 18, 2024
16b8260
Update XDCValidatorV2.sol
GalaxySciTech Apr 19, 2024
50b6465
Update XDCValidatorV2.sol
GalaxySciTech Apr 24, 2024
e31cda2
Update XDCValidatorV2.sol
GalaxySciTech Apr 26, 2024
b110f27
Update XDCValidatorV2.sol
GalaxySciTech Apr 28, 2024
9515552
Update XDCValidatorV2.sol
GalaxySciTech May 6, 2024
7f95cb4
Update XDCValidatorV2.sol
GalaxySciTech May 12, 2024
8b5d7e1
Update XDCValidatorV2.sol
GalaxySciTech May 14, 2024
6177cce
Update XDCValidatorV2.sol
GalaxySciTech May 14, 2024
e11d755
Update XDCValidatorV2.sol
GalaxySciTech May 17, 2024
c569a2e
Update XDCValidatorV2.sol
GalaxySciTech May 17, 2024
a730b03
Update XDCValidatorV2.sol
GalaxySciTech Jun 11, 2024
aabf014
Update XDCValidatorV2.sol
GalaxySciTech Jun 11, 2024
ca6fad3
Update XDCValidatorV2.sol
GalaxySciTech Jun 22, 2024
fcdf572
Update XDCValidatorV2.sol
GalaxySciTech Jun 24, 2024
1ccd176
Update XDCValidatorV2.sol
GalaxySciTech Jun 24, 2024
271750d
Update XDCValidatorV2.sol
GalaxySciTech Jun 25, 2024
6f108fb
Update XDCValidatorV2.sol
GalaxySciTech Jun 27, 2024
6c4641a
refactor function voteInvalidKYC
gzliudan Jul 1, 2024
754a6de
Merge pull request #566 from gzliudan/voteInvalidKYC
GalaxySciTech Jul 1, 2024
2a7beeb
Update XDCValidatorV2.sol
GalaxySciTech Jul 1, 2024
4c9b1f5
add test script
GalaxySciTech Jul 5, 2024
6f89036
update
GalaxySciTech Jul 8, 2024
9d22611
update
GalaxySciTech Jul 12, 2024
775b120
Update xdcValidator.js
GalaxySciTech Jul 12, 2024
390abb1
Update image.png
GalaxySciTech Jul 12, 2024
467374c
Update xdcValidator.js
GalaxySciTech Jul 15, 2024
e32d5c7
update
GalaxySciTech Jul 15, 2024
e190cc3
Update XDCValidator.sol
GalaxySciTech Jul 26, 2024
3ae7fcf
Update XDCValidator.sol
GalaxySciTech Aug 7, 2024
307e995
update
GalaxySciTech Aug 20, 2024
42073c9
Revert "update"
GalaxySciTech Aug 20, 2024
4297a92
update to v2
GalaxySciTech Aug 20, 2024
1103881
update
GalaxySciTech Aug 20, 2024
611fcc2
update
GalaxySciTech Aug 20, 2024
0e3d7ec
Update types.go
GalaxySciTech Aug 28, 2024
31cccc5
Update deployToGenesis.js
GalaxySciTech Aug 30, 2024
18e9652
Update types.go
GalaxySciTech Aug 30, 2024
bd30cd5
right place to upgrade
wgr523 Aug 30, 2024
d3fa527
Update XDCValidator.sol
GalaxySciTech Feb 26, 2024
ba3c888
update
GalaxySciTech Mar 4, 2024
7d3fc1f
Update XDCValidatorV2.sol
GalaxySciTech Mar 6, 2024
eeee36c
xdv-01
GalaxySciTech Mar 12, 2024
0269a99
Update XDCValidatorV2.sol
GalaxySciTech Mar 12, 2024
57ea283
xdv-06
GalaxySciTech Mar 12, 2024
9c723c6
xdv-06
GalaxySciTech Mar 12, 2024
bc792e5
xdv-01
GalaxySciTech Mar 14, 2024
82a30f3
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
c22658b
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
ee30def
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
bfb6e21
Update XDCValidatorV2.sol
GalaxySciTech Mar 16, 2024
c234eb7
xdv-06
GalaxySciTech Mar 19, 2024
1300f2c
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
26ad555
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
8d49ab6
Update XDCValidatorV2.sol
GalaxySciTech Mar 20, 2024
52a6ecb
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
82eb013
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
56af003
Update XDCValidatorV2.sol
GalaxySciTech Mar 21, 2024
3c0572c
upgrade solidity version to 0.4.26 and add revert mssage
GalaxySciTech Mar 22, 2024
4b9367b
change constructor
GalaxySciTech Mar 22, 2024
4891d45
Update XDCValidatorV2.sol
GalaxySciTech Mar 22, 2024
bfcde85
Update XDCValidatorV2.sol
GalaxySciTech Mar 22, 2024
11fc450
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
c942df0
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
8ae4f5c
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
b60b93b
Update XDCValidatorV2.sol
GalaxySciTech Mar 25, 2024
40c8b4f
Update XDCValidatorV2.sol
GalaxySciTech Mar 26, 2024
7589548
Update XDCValidatorV2.sol
GalaxySciTech Apr 17, 2024
841e6d7
Update XDCValidatorV2.sol
GalaxySciTech Apr 18, 2024
0f93139
Update XDCValidatorV2.sol
GalaxySciTech Apr 18, 2024
86fa3cc
Update XDCValidatorV2.sol
GalaxySciTech Apr 19, 2024
9137b88
Update XDCValidatorV2.sol
GalaxySciTech Apr 24, 2024
a3aafb2
Update XDCValidatorV2.sol
GalaxySciTech Apr 26, 2024
23b4eaf
Update XDCValidatorV2.sol
GalaxySciTech Apr 28, 2024
bf833e4
Update XDCValidatorV2.sol
GalaxySciTech May 6, 2024
d77ccfd
Update XDCValidatorV2.sol
GalaxySciTech May 12, 2024
4ed9a55
Update XDCValidatorV2.sol
GalaxySciTech May 14, 2024
1032572
Update XDCValidatorV2.sol
GalaxySciTech May 14, 2024
4599821
Update XDCValidatorV2.sol
GalaxySciTech May 17, 2024
e4bfdd7
Update XDCValidatorV2.sol
GalaxySciTech May 17, 2024
67d04e1
Update XDCValidatorV2.sol
GalaxySciTech Jun 11, 2024
73b637d
Update XDCValidatorV2.sol
GalaxySciTech Jun 11, 2024
217dc1b
Update XDCValidatorV2.sol
GalaxySciTech Jun 22, 2024
f654e1f
Update XDCValidatorV2.sol
GalaxySciTech Jun 24, 2024
05dd01b
Update XDCValidatorV2.sol
GalaxySciTech Jun 24, 2024
bc593ee
Update XDCValidatorV2.sol
GalaxySciTech Jun 25, 2024
d51b857
Update XDCValidatorV2.sol
GalaxySciTech Jun 27, 2024
f77eb78
refactor function voteInvalidKYC
gzliudan Jul 1, 2024
f73c032
Update XDCValidatorV2.sol
GalaxySciTech Jul 1, 2024
ddc265c
add test script
GalaxySciTech Jul 5, 2024
832e089
update
GalaxySciTech Jul 8, 2024
a321691
update
GalaxySciTech Jul 12, 2024
8800837
Update xdcValidator.js
GalaxySciTech Jul 12, 2024
757ed9a
Update image.png
GalaxySciTech Jul 12, 2024
e231e7b
Update xdcValidator.js
GalaxySciTech Jul 15, 2024
287812c
update
GalaxySciTech Jul 15, 2024
db0a916
Update XDCValidator.sol
GalaxySciTech Jul 26, 2024
d04bca0
Update XDCValidator.sol
GalaxySciTech Aug 7, 2024
2e83224
update
GalaxySciTech Aug 20, 2024
a444fb0
Revert "update"
GalaxySciTech Aug 20, 2024
3203775
update to v2
GalaxySciTech Aug 20, 2024
9a887d2
update
GalaxySciTech Aug 20, 2024
d45d91c
update
GalaxySciTech Aug 20, 2024
ac42174
Update types.go
GalaxySciTech Aug 28, 2024
f8fda4b
Update deployToGenesis.js
GalaxySciTech Aug 30, 2024
638c6b7
Update types.go
GalaxySciTech Aug 30, 2024
c512408
right place to upgrade
wgr523 Aug 30, 2024
64dfda0
Update XDPoS.go
GalaxySciTech Sep 2, 2024
6d900cc
Merge branch 'upgrade-validator-smart-contract' of https://github.com…
GalaxySciTech Sep 2, 2024
4e5adf0
add ValidtorV2SMCBlock constant and setup devnet block
Sep 13, 2024
93eaa35
update
GalaxySciTech Sep 20, 2024
afe096a
update test flow
GalaxySciTech Sep 21, 2024
2f342a4
Update README.md
GalaxySciTech Sep 21, 2024
0dabb6c
update
GalaxySciTech Sep 23, 2024
90c1a2c
update
GalaxySciTech Sep 23, 2024
9204f08
update
GalaxySciTech Sep 24, 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
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var BerlinBlock = big.NewInt(76321000) // Target 19th June 2024
var LondonBlock = big.NewInt(76321000) // Target 19th June 2024
var MergeBlock = big.NewInt(76321000) // Target 19th June 2024
var ShanghaiBlock = big.NewInt(76321000) // Target 19th June 2024
var ValidtorV2SMCBlock = big.NewInt(9999999999)

var TIPXDCXTestnet = big.NewInt(38383838)
var IsTestnet bool = false
Expand Down
2 changes: 2 additions & 0 deletions common/constants/constants.go.devnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var LondonBlock = big.NewInt(16832700)
var MergeBlock = big.NewInt(16832700)
var ShanghaiBlock = big.NewInt(16832700)
var Eip1559Block = big.NewInt(9999999999)
var ValidtorV2SMCBlock = big.NewInt(22320000)

var TIPXDCXTestnet = big.NewInt(0)
var IsTestnet bool = false
Expand All @@ -77,6 +78,7 @@ var TRC21IssuerSMCTestNet = HexToAddress("0x0E2C88753131CE01c7551B726b28BFD04e44
var TRC21IssuerSMC = HexToAddress("0x8c0faeb5C6bEd2129b8674F262Fd45c4e9468bee")
var XDCXListingSMC = HexToAddress("0xDE34dD0f536170993E8CFF639DdFfCF1A85D3E53")
var XDCXListingSMCTestNet = HexToAddress("0x14B2Bf043b9c31827A472CE4F94294fE9a6277e0")

var TRC21GasPriceBefore = big.NewInt(2500)
var TRC21GasPrice = big.NewInt(250000000)
var RateTopUp = big.NewInt(90) // 90%
Expand Down
1 change: 1 addition & 0 deletions common/constants/constants.go.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var LondonBlock = big.NewInt(61290000)
var MergeBlock = big.NewInt(61290000)
var ShanghaiBlock = big.NewInt(61290000) // Target 31st March 2024
var Eip1559Block = big.NewInt(9999999999)
var ValidtorV2SMCBlock = big.NewInt(9999999999)

var TIPXDCXTestnet = big.NewInt(23779191)
var IsTestnet bool = true
Expand Down
3 changes: 3 additions & 0 deletions common/types.go

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions consensus/XDPoS/engines/engine_v2/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ func (x *XDPoS_v2) Finalize(chain consensus.ChainReader, header *types.Header, s
}
}

// upgrade smart contract after reward distribution
number := header.Number.Uint64()
log.Info("poc", "fun", "Finalize", "number", number)
if number == common.ValidtorV2SMCBlock.Uint64() {
UpgradeXDCValidtorV2(state)
}

// the state remains as is and uncles are dropped
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
header.UncleHash = types.CalcUncleHash(nil)
Expand Down Expand Up @@ -1111,3 +1118,11 @@ func (x *XDPoS_v2) periodicJob() {
func (x *XDPoS_v2) GetLatestCommittedBlockInfo() *types.BlockInfo {
return x.highestCommitBlock
}

func UpgradeXDCValidtorV2(statedb *state.StateDB) {
log.Info("poc", "MasternodeVotingSMC", common.MasternodeVotingSMC, "step", 1)
addr := common.HexToAddress(common.MasternodeVotingSMC)
// upgrade code
statedb.SetCode(addr, common.FromHex(common.XDCValidatorV2Code))
log.Info("poc", "MasternodeVotingSMC", common.XDCValidatorV2Code, "step", 2)
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@ contract XDCValidator {
msg.sender.transfer(cap);
emit Withdraw(msg.sender, _blockNumber, cap);
}
}
}
6 changes: 6 additions & 0 deletions contracts/validator/contract_v2/migrate/test/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
O1_PRIVATE_KEY=0x0000
O2_PRIVATE_KEY=0x
O3_PRIVATE_KEY=0x
O4_PRIVATE_KEY=0x
O5_PRIVATE_KEY=0x
RPC_URL=https://devnetstats.apothem.network/devnet
7 changes: 7 additions & 0 deletions contracts/validator/contract_v2/migrate/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
cache/
artifacts/
node_modules/
.vscode/
abigen
yarn.lock
59 changes: 59 additions & 0 deletions contracts/validator/contract_v2/migrate/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Here's a `README.md` file that outlines the steps you've provided:

```markdown
# Project Setup and Testing

This repository contains scripts for testing various workflows in a development environment. The steps below will guide you through setting up the environment, installing dependencies, and running tests.

## Prerequisites

- **Node.js**: Ensure that you have Node.js version 20 installed.
- **Yarn**: Yarn is used for managing dependencies.

## Environment Setup

1. **Create a `.env` file** in the root of your project directory. This file will contain the following environment variables:

```env
RPC_URL=<Your Devnet RPC URL>
M1_PRIVETE_KEY=<Owner 1 Private Key>
M2_PRIVETE_KEY=<Owner 2 Private Key>
M3_PRIVETE_KEY=<Owner 3 Private Key>
M4_PRIVETE_KEY=<Owner 4 Private Key>
M5_PRIVETE_KEY=<Owner 5 Private Key>
```

Replace the placeholders with the appropriate values.

## Installation

1. **Install dependencies** by running the following command:

```bash
yarn
```

This will install all the required packages for the project.

## Running Tests

### Test Main Workflow

To test the main workflow, execute the following command:

```bash
node scripts/testMainWorkFlow.js
```

### Test KYC Invalid Flow

To test the KYC invalid flow, execute the following command:

```bash
node scripts/testKycInvalidFlow.js
```

## Notes

- Ensure that the `.env` file is correctly configured with the required RPC URL and masternode private keys before running the tests.
- If any issues arise during the testing process, double-check the environment variables and dependency installation.
Loading