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

Feat/readme #36

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contracts powering https://sharedstake.org / https://sharedstake.finance

Ethereum liquid staking derivatives.
Ethereum liquid staking derivatives.
Docs: https://docs.sharedstake.finance/

V2 core auditable contracts and guidance/README in `contracts/v2/core`.
Expand Down Expand Up @@ -44,8 +44,8 @@ export ALCHEMY_GOERLI_KEY='xx'
# Errors

A note on errors
To reduce bytecode size and gas costs, error strings are shortened following UNIv3 as an example.
The template is: {origin contract}:reason
To reduce bytecode size and gas costs, error strings are shortened following UNIv3 as an example.
The template is: {origin contract}:reason
Common reasons:

```
Expand Down Expand Up @@ -85,24 +85,24 @@ Spec:

# Gas profiling

Gas profiling on goerli with different optimizations.
Transfer costs:
Gas profiling on goerli with different optimizations.
Transfer costs:
Optimizations | Cost
5000000 | 51481
200 | 51553

This represents a 0.13% improvement in the cost of a transfer, arguably the most frequent interaction.
Deploy costs:
Optimizations | Cost
5000000 | 27645256739592190
This represents a 0.13% improvement in the cost of a transfer, arguably the most frequent interaction.
Deploy costs:
Optimizations | Cost
5000000 | 27645256739592190
200 | 22124896691748864

This represents a 24% increase in deployment costs with 5000000 optimizer runs vs 200.

This was carried out on Goerli using a gas price avg of 4.5 Gwei.
This was carried out on Goerli using a gas price avg of 4.5 Gwei.
Based on this a 200 run base is chosen.

Gas costs of large lists in args:
Gas costs of large lists in args:
With around ~100 addresses in a constructor arg gas price of the entire deploy stack increased by around 10%.

Added gas observations - may '23
Expand Down Expand Up @@ -166,3 +166,51 @@ Ownership transferred for TokenMigrator at 0x9615460582Efa2a9b1d8D21e7E02afE43A4
Ownership transferred for Blocklist at <redacted> to 0xeBc37F4c20C7F8336E81fB3aDf82f6372BEf777E
Ownership transferred for Allowlist at <redacted> to 0xeBc37F4c20C7F8336E81fB3aDf82f6372BEf777E
```

Here's the corrected README section:

---

## Using Development Kit

### Deploy Contracts

You can run the deploy script by specifying tags for the deploy script:

```bash
yarn deploy:sepolia --tags minter
Copy link
Owner

Choose a reason for hiding this comment

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

hmm looks like running the underlying with tags minter seems to err out

$ npx hardhat deploy --network localhost --tags minter
TypeError: Cannot read properties of undefined (reading 'address') at /04_minter.ts:24:23

same with payment splitter.
wsgeth and sgeth seem to deploy properly and addresses get reused correctly though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because deploy script uses second wallet address as mutisig address

const splitterAddresses = [accounts.deployer.address, accounts.multiSig.address, wsgEth.target];

namedAccounts: {

There are two cases can fix this.

  • don't use named account for deploy script and use static address(but named accounts provides some benefits for testing and automation).
  • we can use mnemonic or can use multiple private keys for deployment in hardhat config

Copy link
Owner

Choose a reason for hiding this comment

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

hmm, lets do what we used to do in hardhat config and use the default anvil private key for the default address? and make it clear what is expected from the script user to get it to work?

on mainnet, we wont have the priv key of the multisig as itll be a gnosis safe, but we can execute txs through it, and ideally we deploy everything first, then transfer anything needed to the multisig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah. maybe, let me change multiSig address to constant

Copy link
Contributor Author

@devlancer412 devlancer412 Jun 25, 2024

Choose a reason for hiding this comment

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

Used constant multisig address. Please check deploy script now. @chimera-defi

```

The tag should exist in the deploy scripts:

```typescript
import {DeployFunction} from "hardhat-deploy/types";

const func: DeployFunction = async function (hre) {
// deployment code
};

export default func;
func.tags = ["minter"];
func.dependencies = ["sgEth", "wsgEth"];
```

When deploying contracts, the dependency scripts will run first.

### Verify Contracts

You can verify contracts by specifying the name of the contract:

```bash
yarn verify:sepolia SharedDepositMinterV2
```

Ensure you provide the correct contract name.

---

### Explanation

- **Deploying Contracts**: The `yarn deploy:sepolia --tags minter` command runs the deploy script with the specified tag (`minter`). The tag must be defined in the deploy script. Dependencies specified in `func.dependencies` will run before the tagged script.

- **Verifying Contracts**: The `yarn verify:sepolia SharedDepositMinterV2` command verifies the contract on the `sepolia` network by its name (`SharedDepositMinterV2`). Ensure the contract name is accurate to avoid verification errors.
4 changes: 3 additions & 1 deletion deploy/03_paymentSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const func: DeployFunction = async hre => {

const wsgEth = (await connect(WSGETH__factory)) as WSGETH;

const splitterAddresses = [accounts.deployer.address, accounts.multiSig.address, wsgEth.target];
const multiSig = hre.network.tags.hardhat ? accounts.multiSig.address : "0x610c92c70eb55dfeafe8970513d13771da79f2e0";

const splitterAddresses = [accounts.deployer.address, multiSig, wsgEth.target];
const splitterValues = [6, 3, 31];

await deploy(PaymentSplitter__factory, {
Expand Down
4 changes: 3 additions & 1 deletion deploy/04_minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const func: DeployFunction = async hre => {
const numValidators = 1000;
const adminFee = 0;

const multiSig = hre.network.tags.hardhat ? accounts.multiSig.address : "0x610c92c70eb55dfeafe8970513d13771da79f2e0";

// const FeeCalc = await ethers.getContractFactory("FeeCalc");
// const feeCalc = await FeeCalc.deploy(parseEther("0"), parseEther("0"));
// await feeCalc.deployed();
Expand All @@ -21,7 +23,7 @@ const func: DeployFunction = async hre => {
//feeCalc.address, // fee splitter
sgEth.target, // sgETH address
wsgEth.target, // wsgETH address
accounts.multiSig.address, // government address
multiSig, // government address
ZeroAddress, // deposit contract address - can't find deposit contract - using dummy address
];

Expand Down
5 changes: 1 addition & 4 deletions deploy/05_withdrawalQueue.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import {DeployFunction} from "hardhat-deploy/types";
import Ship from "../utils/ship";
import {
SgETH,
SgETH__factory,
SharedDepositMinterV2,
SharedDepositMinterV2__factory,
WSGETH,
WSGETH__factory,
WithdrawalQueue__factory,
} from "../types";
import {ZeroAddress} from "ethers";

const func: DeployFunction = async hre => {
const {deploy, connect, accounts} = await Ship.init(hre);
const {deploy, connect} = await Ship.init(hre);

const wsgEth = (await connect(WSGETH__factory)) as WSGETH;
const minter = (await connect(SharedDepositMinterV2__factory)) as SharedDepositMinterV2;
Expand Down
1 change: 1 addition & 0 deletions deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading
Loading