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(pulse): add pulse contracts #2090

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft

feat(pulse): add pulse contracts #2090

wants to merge 19 commits into from

Conversation

cctdaniel
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Nov 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 0:01am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 0:01am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 0:01am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Nov 18, 2024 0:01am
insights ⬜️ Ignored (Inspect) Visit Preview Nov 18, 2024 0:01am

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

As we've discussed before, having provider doesn't make much sense for the Pulse and it seems that this code is very centered towards different providers (from requesting one, updating, separate fees, ...). I think the options are either 1) allow all providers to fullfill a request 2) remove providers entirely and make it permissionless.

@cctdaniel
Copy link
Contributor Author

As we've discussed before, having provider doesn't make much sense for the Pulse and it seems that this code is very centered towards different providers (from requesting one, updating, separate fees, ...). I think the options are either 1) allow all providers to fullfill a request 2) remove providers entirely and make it permissionless.

yeah this makes sense, I have gone with option 2 and removed providers entirely

uint256 callbackGasLimit
) external view returns (uint128 feeAmount);

function getPythFeeInWei() external view returns (uint128 pythFeeInWei);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this?

_state.pyth = pythAddress;
_state.currentSequenceNumber = 1;

if (prefillRequestStorage) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this for :?

function executeCallback(
uint64 sequenceNumber,
bytes[] calldata updateData,
bytes32[] calldata priceIds
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm thinking about it, now that we don't emit the ids and don't store them (we store the hash of it), how argus is supposed to understand it :? parse the transactions?

);

// Check if enough gas remains for the callback
if (gasleft() < req.callbackGasLimit) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend allocating an extra overhead for cross-contract calls.

clearRequest(sequenceNumber);
}

function emitPriceUpdate(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's good to emit something (for debugging purposes), just be aware that it might be expensive to do this in ethereum mainnet.

Comment on lines +146 to +152
function getFee(
uint256 callbackGasLimit
) public view override returns (uint128 feeAmount) {
uint128 baseFee = _state.pythFeeInWei;
uint256 gasFee = callbackGasLimit * tx.gasprice;
feeAmount = baseFee + SafeCast.toUint128(gasFee);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering how this works in Entropy. Do we update pythFee regularly based on gasPrice? @m30m might know better but similar products charge fee as % of the tx fee.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is also one DoS attack vector in our price feeds use case regarding gas prices. People can ask for price updates anytime in the future and it won't be fullfilled immediately (opposed to Entropy) and this might make tx.gasprice a worse estimate on normal usage (only a few seconds after that) or can be taken advantage of to make hundreds of requests in the future when the gas price is lower.

My recommendation is to not allow a publish time that is more than 1min in the future. Or charge higher fees as it goes more into the future.

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