Replies: 2 comments
-
Thanks for opening this discussion, @razgraf.
We've envisaged the periphery contracts to be stateless, so we will not have any storage variables. What we can have are constants, since they are inlined in the contract bytecode. I will continue writing my response assuming that this is what you were referring to.
I see what you're getting at, and I would add to this the issue of having to manage periphery contracts if we hard-code the Sablier contract addresses. Whereas if we pass them as function arguments, there would be less of a hassle in terms of contract management.
See for yourself below - it costs ~566 more gas to use the function argument. I concede that this gas difference may not be significant enough to be worthy of our attention, especially since we're talking about large-volume users in the context of the Click to see code snippet that shows gas comparisonpragma solidity >=0.8.17;
contract Foo {
event LogFunc();
function func() external {
emit LogFunc();
}
}
contract Bar {
Foo internal immutable foo;
constructor(Foo foo_) {
foo = foo_;
}
// 28,667 gas
function callFoo() external {
foo.func();
}
}
contract Baz {
// 29,233 gas
function callFoo(Foo foo) external {
foo.func();
}
} |
Beta Was this translation helpful? Give feedback.
-
Locking, we agreed not to use constructor args. |
Beta Was this translation helpful? Give feedback.
-
The batch-create functions will target linear/dynamic contracts. The question becomes: should we store those addresses as local variables (through the constructor and/or getters/setters) or pass them as function arguments.
@andreivladbrg already implemented a change from variables to arguments (3349d80) which leaves room for us to use the periphery with any matching deployment of the protocol. Having in mind that both the app and the subgraph have already been designed to support multiple deployments, this periphery update would be following that theme.
@PaulRBerg brought the idea of gas optimizations in discussions, related to the case where addresses are stored directly into the contract (tbd: immutable or not).
Beta Was this translation helpful? Give feedback.
All reactions