Skip to content

Commit a7502f4

Browse files
ashish10677SkandaBhatYashk767OxHimanshuShrikant1212
authored
Develop (#375)
* Update config.yml (#316) Co-authored-by: Skanda Bhat <[email protected]> * Additional tests (#317) * Increment gasLimit while confirming block. (#320) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Corrected GetNumberOfStakers() (#324) * Fix issue of isElectedProposer. (#328) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Exit the code if the stake is slashed to 0 (#334) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Dispute blockId fix (#333) * Added GetSortedProposedBlockIds * Support for tests * Modified tests * Corrected activeAssetIds in tests * Dispute influence id fix (#338) * Added check for biggestInfluence * Support for tests * Additional tests * only one dispute check * Staker info (#314) * StakerInfo command implemented. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Update README files. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Implement necessary mocks for tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix typo. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Add more tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Remove address from stakerInfo command. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix getEpoch method. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Update README. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Increase coverage on propose.go. (#340) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Added maximum gas limit while confirming block. (#335) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix withdraw (#344) * Added getUpdatedEpoch() * Fetched updated epoch in for loop * Sentry integrated to razor-go (#347) * Initialized sentry to the project. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Run golangci-lint run. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Consolidated interfaces into utilsStruct (#341) * utilsStruct call methods * consolidated interfaces into one * compilation changes * Modified functions with utilsStruct * Resolve conflicts (#349) * Update config.yml * changed addresses to v0.1.76 (#318) * Develop (#325) * Update config.yml (#316) * Additional tests (#317) * Increment gasLimit while confirming block. (#320) * Corrected GetNumberOfStakers() (#324) Co-authored-by: Ashish Kumar Mishra <[email protected]> Co-authored-by: Yashk767 <[email protected]> Co-authored-by: Skanda Bhat <[email protected]> Co-authored-by: OxHimanshu <[email protected]> * Gas limit config (#343) * Added gasLimit as a setConfig parameter. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Add code to increase gas limit by dynamic value. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Restrict gas limit to 21 million max. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Add Gas limit in config.sh Signed-off-by: Ashish Kumar Mishra <[email protected]> * Add tests for set config. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Update README Signed-off-by: Ashish Kumar Mishra <[email protected]> * Make default gas limit as 100% Signed-off-by: Ashish Kumar Mishra <[email protected]> * Apply gofmt. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Modify gas limit multiplier to be used as 2x, 3x, 1.5x, etc. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Update README. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * modified tests with more realistic values (#351) * Added tests for math.go (#353) * ConvertToNumber coverage * Moved AssignAmountInWei() to cmd-utils.go * Additional tests Added a nil testcase minor changes * requested change * fix: added jq pkg and updated build script in dockerfile. (#362) Co-authored-by: Shrikant Upadhyay <[email protected]> * Removed max gas limit from confirm block. (#359) * Removed max gas limit from confirm block. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Reduce calculations in handle dispute. (#364) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Update contract addresses. (#374) Signed-off-by: Ashish Kumar Mishra <[email protected]> * Remove unnecessary import Signed-off-by: Ashish Kumar Mishra <[email protected]> * Fix tests. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Test unstake (#350) * Seperated InitialiseUnstake() * modified functions with utilsStruct * seperate executeUnstake() * Added support for tests * Added tests for unstake * Added a UnstakeInput struct * requested changes * Mocked Sleep function * Modified AutoWithdraw function * Added tests for AutoWithdraw * feat: Adding docker-compose.yml (#365) * feat: Adding docker-compose.yml * feat: configured docker-compose and readme * feat: updated readme for docker compose * fix: updated readme and added support for silicon based MAC * fix: Updated README for silicon based MAC Signed-off-by: Shrikant Upadhyay <[email protected]> Co-authored-by: Shrikant Upadhyay <[email protected]> * Timeout duration reduced from 120 to 30 secs. (#366) * Timeout duration reduced from 120 to 30 secs. Signed-off-by: Ashish Kumar Mishra <[email protected]> * Block completion timeout made a constant value. Signed-off-by: Ashish Kumar Mishra <[email protected]> Co-authored-by: Skanda Bhat <[email protected]> Co-authored-by: Yashk767 <[email protected]> Co-authored-by: OxHimanshu <[email protected]> Co-authored-by: Shrikant upadhyay <[email protected]> Co-authored-by: Shrikant Upadhyay <[email protected]>
1 parent 3fd722a commit a7502f4

31 files changed

+1101
-329
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ COPY . /app
1515
RUN PATH="/usr/local/go/bin:${PATH}" \
1616
&& apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python \
1717
&& apk add --update make gcc musl musl-dev g++ libc-dev bash linux-headers \
18+
&& apk add --no-cache jq \
1819
&& npm install \
19-
&& npm run dockerize-build \
20+
&& npm run build-noargs \
2021
&& cp build/bin/razor /usr/local/bin/
2122

2223

README.md

+95-25
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,68 @@ Official node for running stakers in Golang.
99
### Docker quick start
1010

1111
One of the quickest ways to get `razor-go` up and running on your machine is by using Docker:
12+
1213
```
1314
docker run -d \
1415
-it \
1516
--name razor-go \
1617
-v "$(echo $HOME)"/.razor:/root/.razor \
1718
razornetwork/razor-go
1819
```
20+
1921
Note that we are leveraging docker bind-mounts to mount `.razor` directory so that we have a shared mount of `.razor` directory between the host and the container. The `.razor` directory holds keys to the addresses that we use in `razor-go`, along with logs and config. We do this to persist data in the host machine, otherwise you would lose your keys once you delete the container.
2022

2123
You need to set a provider before you can operate razor-go cli on docker:
2224

2325
```
24-
docker exec -it razor-go setconfig -p <provider_url>
26+
docker exec -it razor-go setConfig -p <provider_url>
2527
```
2628

2729
You can now execute razor-go cli commands by running:
2830

2931
```
3032
docker exec -it razor-go <command>
3133
```
34+
35+
### Setting up dev environment with docker-compose
36+
37+
You can build razor-go docker image by running:
38+
39+
```
40+
docker-compose build
41+
```
42+
> **_NOTE:_** Add platform: linux/x86_64 for Silicon based MAC in docker-compose.yml.
43+
44+
45+
46+
Run razor-go locally with:
47+
48+
```
49+
docker-compose up -d
50+
```
51+
52+
You can intract with razor:
53+
54+
```
55+
docker exec -it razor-go ...
56+
```
57+
3258
### Prerequisites
33-
* Golang 1.15 or later must be installed.
34-
* Latest stable version of node is required.
35-
* Silicon chip based Mac users must go for node 15.3.0+
36-
* `geth` and `abigen` should be installed. (Skip this step if you don't want to fetch the bindings and build from scratch)
59+
60+
- Golang 1.15 or later must be installed.
61+
- Latest stable version of node is required.
62+
- Silicon chip based Mac users must go for node 15.3.0+
63+
- `geth` and `abigen` should be installed. (Skip this step if you don't want to fetch the bindings and build from scratch)
64+
- `solc` and `jq` must be installed.
3765

3866
### Building the source
67+
3968
1. Run `npm install` to install the node dependencies.
4069
2. If you want to build from scratch i.e., by fetching the smart contract bindings as well, run `npm run build-all`.
4170

4271
_Note: To build from scratch, `geth` and `abigen` must be installed in your system._
43-
3. If you already have the `pkg/bindings` you can run `npm run build` instead of `npm run build-all` to directly build the binary.
72+
73+
3. If you already have the `pkg/bindings` you can run `npm run build` instead of `npm run build-all` to directly build the binary.
4474
4. If you want to build the binary without wanting to set the configurations use `npm run build-noargs`
4575
5. While building the binary, supply the provider RPC url and the gas multiplier.
4676
6. The binary will be generated at `build/bin`.
@@ -52,6 +82,7 @@ Go to the `build/bin` directory where the razor binary is generated.
5282
`cd build/bin`
5383

5484
### Create Account
85+
5586
Create an account using the `create` command. You'll be asked to enter a password that'll be used to encrypt the keystore file.
5687

5788
```
@@ -62,10 +93,11 @@ Example:
6293

6394
```
6495
$ ./razor create
65-
Password:
96+
Password:
6697
```
6798

6899
### Import Account
100+
69101
If you already have an account created, and have it's private key, that account can be imported into the `razor-go` client.
70102
To do that, you can use the `import` command. You'll be asked the private key first and then the password which you want to encrypt your keystore file with.
71103

@@ -78,65 +110,77 @@ Example:
78110
```
79111
$ ./razor import
80112
🔑 Private Key:
81-
Password:
113+
Password:
82114
```
83115

84-
__Before staking on Razor Network, please ensure your account has eth and RAZOR. For testnet RAZOR, please contact us on Discord.
116+
_Before staking on Razor Network, please ensure your account has eth and RAZOR. For testnet RAZOR, please contact us on Discord._
85117

86118
### Stake
87119

88120
If you have a minimum of 1000 razors in your account, you can stake those using the stake command.
121+
89122
```
90123
$ ./razor stake --address <address> --value <value> --pow <power>
91124
```
92125

93126
Example:
127+
94128
```
95129
$ ./razor stake --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --value 1000 --pow 10
96130
```
97131

98132
### Staker Info
99133

100134
If you want to know the details of a staker, you can use stakerInfo command.
135+
101136
```
102137
$ ./razor stakerInfo --stakerId <staker_id_of_the_staker>
103138
```
104139

105140
Example:
141+
106142
```
107143
$ ./razor stakerInfo --stakerId 2
108144
```
145+
109146
### Set Delegation
110147

111148
If you are a staker you can accept delegation from delegators and charge a commission from them.
149+
112150
```
113151
$ ./razor setDelegation --address <address> --status <true_or_false> --commission <commission>
114152
```
115153

116154
Example:
155+
117156
```
118157
$ ./razor setDelegation --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --status true --commission 100
119158
```
120159

121160
### Delegate
122161

123162
If you want to become a delegator use the `delegate` command. The staker whose `staker_id` is provided, their stake is increased.
163+
124164
```
125165
$ ./razor delegate --address <address> --value <value> --pow <power> --stakerId <staker_id>
126166
```
127167

128168
Example:
169+
129170
```
130171
$ ./razor delegate --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --value 1000 --pow 10 --stakerId 1
131172
```
132173

133174
### Vote
175+
134176
You can start voting once you've staked some razors
177+
135178
```
136179
$ ./razor vote --address <address>
137180
```
138181

139182
Example:
183+
140184
```
141185
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c
142186
```
@@ -146,21 +190,25 @@ If you want to report incorrect values, there is a `rogue` mode available. Just
146190
Example:
147191

148192
```
149-
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --rogue
193+
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --rogue
150194
```
151195

152196
### Unstake
197+
153198
If you wish to withdraw your funds, you can run the `unstake` command followed by the `withdraw` command.
199+
154200
```
155201
$ ./razor unstake --address <address> --stakerId <staker_id> --value <value> --pow <power> --autoWithdraw
156202
```
157203

158204
Example:
205+
159206
```
160207
$ ./razor unstake --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --stakerId 1 --amount --pow 10 1000 --autoWithdraw
161208
```
162209

163210
### Withdraw
211+
164212
Once `unstake` has been called, you can withdraw your funds using the `withdraw` command
165213

166214
```
@@ -174,7 +222,9 @@ $ ./razor withdraw --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --staker
174222
```
175223

176224
### Extend Lock
225+
177226
If the withdrawal period is over, then extendLock can be called to extend the lock period.
227+
178228
```
179229
$ ./razor extendLock --address <address> --stakerId <staker_id>
180230
```
@@ -186,27 +236,30 @@ $ ./razor extendLock --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --stak
186236
```
187237

188238
### Transfer
239+
189240
Transfers razor to other accounts.
190241

191242
```
192243
$ ./razor transfer --value <value> --to <transfer_to_address> --from <transfer_from_address>
193244
```
194245

195246
Example:
247+
196248
```
197249
$ ./razor transfer --value 100 --to 0x91b1E6488307450f4c0442a1c35Bc314A505293e --from 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c
198250
```
199251

200252
### Set Config
253+
201254
There are a set of parameters that are configurable. These include:
202255

203-
* Provider: The RPC URL of the provider you are using to connect to the blockchain.
204-
* Gas Multiplier: The value with which the gas price will be multiplied while sending every transaction.
205-
* Buffer Size: Buffer size determines, out of all blocks in a state, in how many blocks the voting or any other operation can be performed.
206-
* Wait Time: This is the number of blocks the system will wait while voting.
207-
* Gas Price: The value of gas price if you want to set manually. If you don't provide any value or simply keep it to 0, the razor client will automatically calculate the optimum gas price and send it.
208-
* Log Level: Normally debug logs are not logged into the log file. But if you want you can set `logLevel` to `debug` and fetch the debug logs.
209-
* Gas Limit: The value with which the gas limit will be multiplied while sending every transaction.
256+
- Provider: The RPC URL of the provider you are using to connect to the blockchain.
257+
- Gas Multiplier: The value with which the gas price will be multiplied while sending every transaction.
258+
- Buffer Size: Buffer size determines, out of all blocks in a state, in how many blocks the voting or any other operation can be performed.
259+
- Wait Time: This is the number of blocks the system will wait while voting.
260+
- Gas Price: The value of gas price if you want to set manually. If you don't provide any value or simply keep it to 0, the razor client will automatically calculate the optimum gas price and send it.
261+
- Log Level: Normally debug logs are not logged into the log file. But if you want you can set `logLevel` to `debug` and fetch the debug logs.
262+
- Gas Limit: The value with which the gas limit will be multiplied while sending every transaction.
210263

211264
The config is set while the build is generated, but if you need to change any of the above parameter, you can use the `setConfig` command.
212265

@@ -215,37 +268,45 @@ $ ./razor setConfig --provider <rpc_provider> --gasmultiplier <multiplier_value>
215268
```
216269

217270
Example:
271+
218272
```
219273
$ ./razor setConfig --provider https://infura/v3/matic --gasmultiplier 1.5 --buffer 20 --wait 70 --gasprice 1 --logLevel debug --gasLimit 0.8
220274
```
221275

222276
Other than setting these parameters in the config, you can use different values of these parameters in different command. Just add the same flag to any command you want to use and the new config changes will appear for that command.
223277

224278
Example:
279+
225280
```
226-
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --gasprice 10
281+
$ ./razor vote --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --gasprice 10
227282
```
228-
This will cause this particular vote command to run with a gas price of 10.
229283

284+
This will cause this particular vote command to run with a gas price of 10.
230285

231286
### Create Job
232-
Create new jobs using `creteJob` command.
287+
288+
Create new jobs using `creteJob` command.
233289

234290
_Note: This command is restricted to "Admin Role"_
291+
235292
```
236293
$ ./razor createJob --url <URL> --selector <selector_in_json_selector_format> --name <name> --address <address> --power <power> --weight <weight>
237294
```
238295

239296
Example:
297+
240298
```
241299
$ ./razor createJob --url https://www.alphavantage.co/query\?function\=GLOBAL_QUOTE\&symbol\=MSFT\&apikey\=demo --selector '[`Global Quote`][`05. price`]" --name msft --power 2 --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --weight 32
242300
```
301+
243302
OR
303+
244304
```
245305
$ ./razor createJob --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c -n ethusd --power 2 -s last -u https://api.gemini.com/v1/pubticker/ethusd --weight 10
246306
```
247307

248308
### Create Collection
309+
249310
Create new collections using `creteCollection` command.
250311

251312
_Note: This command is restricted to "Admin Role"_
@@ -255,11 +316,13 @@ $ ./razor createCollection --name <collection_name> --address <address> --jobIds
255316
```
256317

257318
Example:
319+
258320
```
259321
$ ./razor createCollection --name btcCollectionMean --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --jobIds 1,2 --aggregation 2 --power 2
260322
```
261323

262324
### Modify Asset Status
325+
263326
Modify the active status of an asset using the `modifyAssetStatus` command.
264327

265328
_Note: This command is restricted to "Admin Role"_
@@ -269,38 +332,45 @@ $ ./razor modifyAssetStatus --assetId <assetId> --address <address> --status <tr
269332
```
270333

271334
Example:
335+
272336
```
273337
$ ./razor modifyAssetStatus --assetId 1 --address 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --status false
274338
```
275339

276340
### Update Collection
341+
277342
Update the collection using `updateCollection` command.
278343

279344
_Note: This command is restricted to "Admin Role"_
280345

281346
```
282-
$ ./razor updateCollection --collectionId <collection_id> --address <address> --aggregation <aggregation_method> --power <power>
347+
$ ./razor updateCollection --collectionId <collection_id> --address <address> --aggregation <aggregation_method> --power <power>
283348
```
284349

285350
Example:
351+
286352
```
287353
$ ./razor updateCollection -a 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --collectionId 3 --aggregation 2 --power 4
288354
```
289355

290356
### Update Job
357+
291358
Update the existing parameters of the Job using `updateJob` command.
292-
359+
293360
_Note: This command is restricted to "Admin Role"_
294361

295362
```
296363
./razor updateJob --address <address> --jobID <job_Id> -s <selector> -u <job_url> --power <power> --weight <weight>
297364
```
298365

299366
Example:
367+
300368
```
301-
$ ./razor updateJob -a 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --jobId 1 -s last -u https://api.gemini.com/v1/pubticker/btcusd --power 2 --weight 10
369+
$ ./razor updateJob -a 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c --jobId 1 -s last -u https://api.gemini.com/v1/pubticker/btcusd --power 2 --weight 10
302370
```
303-
Note : *All the commands have an additional --password flag that you can provide with the file path from which password must be picked.*
304371

305-
### Contribute to razor-go
372+
Note : _All the commands have an additional --password flag that you can provide with the file path from which password must be picked._
373+
374+
### Contribute to razor-go
375+
306376
We would really appreciate your contribution. To see our [contribution guideline](https://github.com/razor-network/razor-go/blob/main/.github/CONTRIBUTING.md)

addresses.json

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
"StakedTokenFactory": "0x9A4d3E0dDBa5086FF9465979666eef04453dA023",
1111
"RandomNoManager": "0x998374A3c1d183407FE7a76e17282251c89e4CA7"
1212
}
13-
14-

0 commit comments

Comments
 (0)