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: calculate arbitrum block number for start of epoch #71

Merged
merged 6 commits into from
Oct 25, 2024

Conversation

jahabeebs
Copy link
Collaborator

🤖 Linear

Closes GRT-214

Description

  • ProtocolProvider.getCurrentEpoch now returns the correct firstBlockNumber value using L2 block number.

@jahabeebs jahabeebs self-assigned this Oct 24, 2024
Copy link

linear bot commented Oct 24, 2024

Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Some quick comments and it's good to go!

@@ -309,10 +313,18 @@ export class ProtocolProvider implements IProtocolProvider {
blockNumber: epochFirstBlockNumber,
});

const startTimestamp = epochFirstBlock.timestamp as UnixTimestamp;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make the blockNumberService dependency optional so we don't have to worry about creating a mocked version of it within the recently developed scripts. Let's make it so ProtocolProvider fails if someone tries to get a current epoch without passing a block number service when initializing 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.

const expectedAddress = privateKeyToAccount(mockedPrivateKey).address;
const expectedAddress = privateKeyToAccount(
mockedPrivateKey,
mockBlockNumberService,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this ok? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is not, it appears my linter is on strike. I removed it

@@ -247,10 +255,15 @@ describe("ProtocolProvider", () => {
const mockEpochBlock = BigInt(12345);
const mockEpochTimestamp = BigInt(Date.UTC(2024, 1, 1, 0, 0, 0, 0)) / 1000n;

const mockBlockNumberService = {
getEpochBlockNumber: vi.fn().mockResolvedValue(mockEpochBlock),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should differentiate the getEpochBlockNumber from block number service from the block number returned by the epoch manager contract, just to be sure that one is the L1 block number (contract's one) and the BN service response is L2 (which should actually be used in the return value).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@0xnigir1 0xnigir1 left a comment

Choose a reason for hiding this comment

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

good to go after addressing Yaco's comments

…-arbitrum-block-num

# Conflicts:
#	packages/automated-dispute/src/providers/protocolProvider.ts
#	packages/automated-dispute/tests/services/protocolProvider.spec.ts
@jahabeebs jahabeebs requested review from 0xnigir1 and 0xyaco October 25, 2024 19:17
Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

One little thing more and it's ready to go

rpcConfig,
contracts,
env.PRIVATE_KEY as Hex,
mockBlockNumberService,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to drop this with the new changes! I think you'll need to add the optionality for BlockNumberService in the ProtocolProvider constructor

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops this got filtered out in the merge

@jahabeebs jahabeebs requested a review from 0xyaco October 25, 2024 19:23
@jahabeebs jahabeebs merged commit df1481c into dev Oct 25, 2024
5 checks passed
@jahabeebs jahabeebs deleted the feat/grt-214-calculate-arbitrum-block-num branch October 25, 2024 22:43
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