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

Expose deployment block number of stake table contracts to clients #2647

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

sveitser
Copy link
Collaborator

@sveitser sveitser commented Feb 20, 2025

See comments in InitializedAt.sol for reasons for this change.

Some more background. When querying infura or alchemy for logs there are limits, for infura its

To prevent queries from consuming too many resources, eth_getLogs requests are currently limited by three constraints:

  • A maximum of 5,000 parameters in a single request
  • A maximum of 10,000 results can be returned by a single query
  • Query duration must not exceed 10 seconds

for alchemy its

You can make eth_getLogs requests on any block range with a cap of 10K logs in the response OR a 2K block range with no cap on logs in the response and 150MB limit on the response size

The way to limit queries is to specify a from and a to block. However, absent any other information there is no good value for the from block.

Clients can now read initializedAtBlock and start fetching events from that block.

See comments in `InitializedAt.sol` for reasons for this change.
Responding to discussion with @alxiong. This maybe simpler to reason
about and does not piggyback on openzeppelin's Initializable event.
Comment on lines +17 to +20
constructor() {
initialize();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

wait, shouldn't the upgradable's constructor be:

constructor() {
    _disableInitializers();
}

Copy link
Collaborator Author

@sveitser sveitser Feb 20, 2025

Choose a reason for hiding this comment

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

Based on the documentation https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-_disableInitializers--

I think this is equivalent, because this constructor calls the initializer, and the initializer cannot be called again so the contract is never not initialized. When we inherit from this contract in other contracts the constructor of this contract is not called unless manually invoked which is just something we must not do.

Let me add a test for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sveitser sveitser changed the title Add Initialized event for non-upgradable contracts Expose deployment block number of stake table contracts to clients Feb 20, 2025
Copy link
Contributor

@alxiong alxiong left a comment

Choose a reason for hiding this comment

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

Lgtm

@sveitser sveitser enabled auto-merge (squash) February 20, 2025 16:27
@sveitser sveitser merged commit d10b00b into main Feb 20, 2025
49 of 51 checks passed
@sveitser sveitser deleted the ma/contract-deployment-block-numbers branch February 20, 2025 16:40
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.

2 participants