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

Include periphery in this repo #979

Merged
merged 8 commits into from
Jul 30, 2024
Merged

Include periphery in this repo #979

merged 8 commits into from
Jul 30, 2024

Conversation

andreivladbrg
Copy link
Member

@andreivladbrg andreivladbrg commented Jul 24, 2024

This PR addresses the first point in package tethering issue #808

The idea here is to create multiple PRs, to make the review process easier (some of PRs will have a failing CI, because the fixes are done in the upcoming ones).

Note

This PR is meant to be merged into staging after #980 and #981 (and more to come) are merged into it (Merge order: last created –> second last –> … –> first created). The review would be easier if it is done in the order these PRs were created: first 979, second 980, third 981 and so on..

Each PR is going to be left as "draft" until the upcoming one is merged into it.
last created (not draft), second last(draft) … first created(draft)

Changes

  • Add core dir in src
  • Move all production contracts into core
  • Add periphery dir in src
  • Move all production periphery contracts here
  • Update script import paths

Question: I have thought about merging the Errors libraries into a single one and adding a dedicated errors directory in the src root. Also, I was considering whether we should move all interfaces (both core and periphery) to the root

current
├── core
│   └──everything the same
└── periphery
    └── everything the same

idea
├── core
│   └──everything the same but without errors and interfaces
├── errors
│   └── both core and periphery errors
├── interfaces
│   └── both core and periphery interfaces
└── periphery
    └── everything the same but without errors and interfaces

But, I consider that it is better to separate them for an easier repo structure to manage (current version), wdyt, do you have a better suggestion on how to structure the src?

@andreivladbrg andreivladbrg marked this pull request as draft July 24, 2024 16:23
@andreivladbrg
Copy link
Member Author

@PaulRBerg and @smol-ninja could you please provide your input on the question raised in the PR comment?

@PaulRBerg
Copy link
Member

This is not an easy choice. I need time to review this PR properly before sharing my input, and I don't yet know when I will be able to take a look at it. I'm sorry.

@andreivladbrg andreivladbrg changed the title feat: add periphery contracts in src Include periphery in this repo Jul 26, 2024
@smol-ninja smol-ninja force-pushed the feat/add-periphery branch from 41524b5 to 9c5bb99 Compare July 29, 2024 11:40
Copy link
Member

@smol-ninja smol-ninja left a comment

Choose a reason for hiding this comment

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

Looks good. Just a note that when we merge these changes into the staging branch, we should make sure to add all the authors of v2-periphery as co-authors of the commit.

@PaulRBerg
Copy link
Member

I would rename the PR title to "Merge the Periphery contracts"

@smol-ninja
Copy link
Member

do you have a better suggestion on how to structure the src?

@andreivladbrg I would suggest to keep core and periphery separate for these PRs and then start a separate discussion about the new structure that you have in your mind. Combining all the interfaces into a separate folder is a good topic to discuss.

@andreivladbrg
Copy link
Member Author

andreivladbrg commented Jul 29, 2024

I would rename the PR title to "Merge the Periphery contracts"

the idea is to merge each PR into this branch, and then merge it to staging, as stated in the OP comment (see notes):
image

so, "Include periphery in this repo" is better, since it will have all relevant files (src, tests, scripts, etc..)

@smol-ninja smol-ninja self-requested a review July 29, 2024 15:59
@andreivladbrg andreivladbrg marked this pull request as ready for review July 29, 2024 19:42
@@ -288,7 +288,7 @@ for chain in "${provided_chains[@]}"; do
if [[ ${DETERMINISTIC_DEPLOYMENT} == true ]]; then
echo -e "${SC}+${NC} Deterministic address"
if [[ ${sol_script} == "" ]]; then
deployment_command+=("script" "script/DeployDeterministicCore.s.sol")
deployment_command+=("script" "script/DeployDeterministicProtocol.s.sol")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this would ever work. We have discussed this previously that deploying the entire protocol in a single tx would cause gas to exceed block limit.

As a solution what we can do is add two new options --core and --periphery to select which one to deploy.

But lets create another issue for that.

Copy link
Member Author

@andreivladbrg andreivladbrg Jul 30, 2024

Choose a reason for hiding this comment

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

We have discussed this previously that deploying the entire protocol in a single tx would cause gas to exceed block limit.

the problem before was not about gas, but about different optimizer runs between core/periphery which lead to a NFTDescriptor and Dynamic contracts being too big, now since we use the same foundry configuration it would work (tested):

optimizer_runs = 1000

https://github.com/sablier-labs/v2-periphery/blob/2d338a7ff6452b20a25e779f5a960f047a5d16af/foundry.toml#L20

But lets create another issue for that

don't think we need one as per above reason

Copy link
Member

Choose a reason for hiding this comment

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

Oh. I tested it yesterday and it showed gas to be over 30M. How much gas requirement it shows to you?

@smol-ninja
Copy link
Member

smol-ninja commented Jul 29, 2024

c00cf23

  • I have moved generic functions to Base test contract, such as expectMultipleCallsToTransferFrom as they relate to ERC20 transfers.
  • I've also created another section called CALL EXPECTS - LOCKUP (please have a look at the base file). expectMultipleCallsToCreateWithDurationsLD etc. also relate to the core function even though they are used in periphery.
  • Periphery_Test only contains MERKLE-LOCKUP section which imo can also be moved to Base. I don't think it makes Base less readable.

We should use super.setUp() instead of <PARENT_CONTRACT>.setUp(). Why? So that, we can remove the setup functions which has no other logic than just calling the parent setup function.

// This would not be required if we use super.setUp().
function setUp() public virtual override {
    Base_Test.setUp();
}

You can argue that <PARENT_CONTRACT>.setUp() increases clarity. However, setup functions are always right below the inheritance statements. So its easy to look at the parent contract.

contract CHILD is PARENT {
function setUp() public virtual override {
    PARENT.setup();
}

PARENT.setup() is useful when we are inheriting multiple contracts which is not case here.

@andreivladbrg thoughts?

@andreivladbrg
Copy link
Member Author

@andreivladbrg thoughts?

no strong opinions on setUp, but you are right about: "<PARENT_CONTRACT>.setUp() increases clarity"
do as you wish

the commit looks good

andreivladbrg and others added 3 commits July 30, 2024 12:12
feat: add core dir in src

refactor: remove redundant imports
refactor: precompile constants

test: merge Base_Test contracts for both core and periphery
test: add Periphery_Test contract

test: add params for create with null broker

test: use broker null param functions in batch

test: update the starting timestamp

test: use recipient0 in core tests

test: fix periphery tests

test: use recipient0 in core tests
test: add an init merkle tree function
test: add tranches functions for merkle lockup

test: remove unneeded brokerFee declarations

test(periphery-fork): use null broker in batch

test(fork): make the admin the caller to fix merkle tests

test: add caller param in computeMerkleAddress function

refactor: remove core and periphery remappings

test: replace block.timestamp with getBlockTimestamp
test: remove unused imports
andreivladbrg and others added 5 commits July 30, 2024 12:12
feat: add core and periphery dirs under script
feat: implement DeployDeterministicProtocol script

refactor(shell): update CLI run in generate-svg script

refactor(script): use count maps in deploy protocol

chore: re-order imports
ci: use JSON inputs in generate svg workflow

ci: lower the fuzz runs to 2000

ci: remove periphery path where not needed

chore: fix use of fromJSON
refactor(benchmark): use users.recipient0
refactor(benchmark): dry-fy params return
chore(benchmark): run benchmark to update results
build(shell): use deploy protocol deployment script
test: rename recipient0 to recipient

test: refactor variables in Defaults

test(fork): allow leadData to have length 1
@andreivladbrg andreivladbrg merged commit eb679a1 into staging Jul 30, 2024
8 checks passed
@smol-ninja
Copy link
Member

smol-ninja commented Jul 30, 2024

do as you wish

Then I would refactor it to use super.setUp in the next PR so that we can remove those redundant setup functions. They take up 7 lines.

I have decided to keep <CONTRACT>.setUp().

@PaulRBerg
Copy link
Member

I have decided to keep <CONTRACT>.setUp().

gud, me like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants