Skip to content

Commit

Permalink
Feature #19: Validator command (#20)
Browse files Browse the repository at this point in the history
* Add deposit key struct

* Initial implementation of parsing deposit

* Implement basic init

* Add bindings for mock contract

* Adjust sending to contrat

* Batch transactions and fix nonce

* Generate bindgins for standard deposit + adjust validator init

* Give gas estimations

* Resolve CR comments

* Update README

* Correct gas calculations
  • Loading branch information
Wolmin authored Mar 10, 2023
1 parent 5ab9761 commit 6ec7f3b
Show file tree
Hide file tree
Showing 21 changed files with 5,318 additions and 47 deletions.
103 changes: 85 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

## Repository struct
In `./cmd/lukso` lies code of Lukso CLI
- [`./cmd/lukso`](./cmd/lukso): code of LUKSO CLI
- [`./abis`](./abis) - collection of ABIs from smart contracts that are being interacted with
- [`./contracts`](./contracts) - collection of said smart contracts
- [`./contracts/bindings`](./contracts/bindings) - bindings generated from ABIs - to generate new bindings see [Generate bindings](#generate-bindings) section.

## Installation ( Linux/MacOS )

Expand All @@ -19,15 +22,18 @@ Enter `lukso start` to start a node.
`lukso <command> [geth, prysm, validator, *all*] [--flags]`
> *all* means that you can skip an argument for all possible options to run (default, only option for download)
| Command | Description |
|----------|-----------------------------------------|
| download | Downloads all client(s) |
| init | Initializes configuration files |
| update | sets client(s) to desired version |
| start | Starts up all or specific client(s) |
| stop | Stops all or specific client(s) |
| logs | Show logs |
| status | Shows status of all or specified client |
| Command | Description |
|----------------|----------------------------------------------|
| install | Downloads all client(s) |
| init | Initializes configuration files |
| update | sets client(s) to desired version |
| start | Starts up all or specific client(s) |
| stop | Stops all or specific client(s) |
| log | Show logs |
| status | Shows status of all or specified client |
| reset | Resets data directories |
| validator | Manages validator-related commands |
| validator init | Initializes your validator with deposit keys |


### start
Expand All @@ -36,6 +42,9 @@ How to use flags with values? Provide a flag and value like: `lukso start --data

| Name | Description | Argument | Default value |
|-------------------------------------|---------------------------------------------------------|-----------------------------------|--------------------------------------------------------|
| --mainnet | Run for mainnet (default network) | Bool | false |
| --testnet | Run for testnet | Bool | false |
| --devnet | Run for devnet | Bool | false |
| --geth-datadir | A path of geth's data directory | Path | ./execution_data |
| --geth-ws | Enable WS server | None | true |
| --geth-ws-addr | Address of WS server | IP Address | 0.0.0.0 |
Expand Down Expand Up @@ -119,11 +128,69 @@ Note difference in tags between geth and prysm/validator (`v` at the beginning)
| --validator-tag | Tag of validator's version that you want to download | Tag, ex. `v1.0.0` |
| --prysm-tag | Tag of prysm's version that you want to download | Tag, ex. `v1.0.0` |

### logs
| Name | Description | Argument |
|-------------------------|-------------------------------------------------|--------------------------------------------|
| --geth-output-file | Path to geth log file that you want to log | Path, ex. `./logs/log_folder/log_file.log` |
| --prysm-output-file | Path to prysm log file that you want to log | Path, ex. `./logs/log_folder/log_file.log` |
| --validator-output-file | Path to validator log file that you want to log | Path, ex. `./logs/log_folder/log_file.log` |

NOTE: `logs` command is broken after changing structure of log files (adding timestamp to filename).
### log
| Name | Description | Argument | Default |
|-------------------------|-------------------------------------------------|----------|------------------|
| --geth-output-file | Path to geth log file that you want to log | Path | "./mainnet-logs" |
| --prysm-output-file | Path to prysm log file that you want to log | Path | "./mainnet-logs" |
| --validator-output-file | Path to validator log file that you want to log | Path | "./mainnet-logs" |
| --mainnet | Run for mainnet (default network) | Bool | false |
| --testnet | Run for testnet | Bool | false |
| --devnet | Run for devnet | Bool | false |

### reset
| Name | Description | Argument | Default |
|---------------------|-----------------------------------|----------|----------------------------|
| --geth-datadir | geth datadir | Path | "./mainnet-data/execution" |
| --prysm-datadir | prysm datadir | Path | "./mainnet-data/consensus" |
| --validator-datadir | validator datadir | Path | "./mainnet-data/validator" |
| --mainnet | Run for mainnet (default network) | Bool | false |
| --testnet | Run for testnet | Bool | false |
| --devnet | Run for devnet | Bool | false |



### validator
| Name | Description | Argument | Default |
|---------------------|-----------------------------------------------------------------------------------|----------|--------------------------------------|
| --deposit | Path to your deposit file - makes a deposit to a deposit contract | Path | "" |
| --genesis-deposit | Path to your genesis deposit file - makes a deposit to genesis validator contract | Path | "" |
| --rpc | Your RPC provider | URL | "https://rpc.2022.l16.lukso.network" |
| --gas-price | Gas price provided by user | Int | 1000000000 |
| --max-txs-per-block | Maximum amount of txs sent per single block | Int | 10 |

### validator init
| Name | Description | Argument | Default |
|----------------------------------------|---------------------------------------|----------|----------------------|
| --validator-wallet-dir value | location of generated wallet | Path | "./mainnet-keystore" |
| --validator-keys-dir value | Path to your validator keys | Path | |
| --validator-wallet-password-file value | Path to your password file | Path | |
| --mainnet | Run for mainnetFlag (default network) | Bool | false |
| --testnet | Run for testnetFlag | Bool | false |
| --devnet | Run for devnet | Bool | false |

## Generate bindings
### Prerequisites:
- solc (https://github.com/ethereum/solidity)
- abigen (https://geth.ethereum.org/docs/tools/abigen)

### Steps

1) Paste your smart contract that you want to interact with into [`./contracts`](./contracts) directory
2) Generate ABI from your smart contract:
```bash
$ solcjs --output-dir abis --abi contracts/depositContract.sol
```
3) Generate bindings using newly generated ABI
```bash
abigen --abi abis/your-abi-file --pkg bindings --out contracts/bindings/yourBindingFile.go --type TypeName
```
4) To use binding in code type in:
```go
bind, err := bindings.NewTypeName(common.HexToAddress(contractAddress), ethClient)
if err != nil {
return
}

tx, err := bind.DoSomething(...)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubkey","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"amount","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"index","type":"bytes"}],"name":"DepositEvent","type":"event"},{"inputs":[],"name":"depositCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDepositData","outputs":[{"internalType":"bytes[]","name":"returnedArray","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getDepositDataByIndex","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_count","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getsVotesPerSupply","outputs":[{"internalType":"uint256[101]","name":"votesPerSupply","type":"uint256[101]"},{"internalType":"uint256","name":"totalVotes","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isContractFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"supplyVoteCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"depositData","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"tokensReceived","outputs":[],"stateMutability":"nonpayable","type":"function"}]
1 change: 1 addition & 0 deletions abis/contracts_Helpers_LYXeMock_sol_IERC777.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"tokenHolder","type":"address"}],"name":"AuthorizedOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"operatorData","type":"bytes"}],"name":"Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"operatorData","type":"bytes"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"tokenHolder","type":"address"}],"name":"RevokedOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"operatorData","type":"bytes"}],"name":"Sent","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"authorizeOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"defaultOperators","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"granularity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"tokenHolder","type":"address"}],"name":"isOperatorFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"operatorData","type":"bytes"}],"name":"operatorBurn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"operatorData","type":"bytes"}],"name":"operatorSend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"revokeOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"send","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions abis/ethereum_deposit.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubkey","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"amount","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"index","type":"bytes"}],"name":"DepositEvent","type":"event"},{"inputs":[{"internalType":"bytes","name":"pubkey","type":"bytes"},{"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"deposit_data_root","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"get_deposit_count","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
1 change: 1 addition & 0 deletions abis/interfaces_IDepositContract_sol_IDepositContract.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubkey","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"amount","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"index","type":"bytes"}],"name":"DepositEvent","type":"event"},{"inputs":[{"internalType":"bytes","name":"pubkey","type":"bytes"},{"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"deposit_data_root","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"get_deposit_count","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions abis/interfaces_IERC165_sol_IERC165.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
1 change: 1 addition & 0 deletions abis/interfaces_IERC1820Registry_sol_IERC1820Registry.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_addr","type":"address"},{"internalType":"bytes32","name":"_interfaceHash","type":"bytes32"},{"internalType":"address","name":"_implementer","type":"address"}],"name":"setInterfaceImplementer","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Loading

0 comments on commit 6ec7f3b

Please sign in to comment.