generated from ethereum-optimism/.github
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add a onchain execution on forked network with Hardcoded values. #54
Merged
+279
−119
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… `TestDefenderInitialization` and `TestHandlePostMockFetch`
zchn
suggested changes
Aug 29, 2024
…ow useless from the API
zchn
approved these changes
Aug 30, 2024
Co-authored-by: Kevin Z Chen <kevin.zchn@gmail.com>
Co-authored-by: Kevin Z Chen <kevin.zchn@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A PR to execute a hard-coded transaction (sent 1wei to
0x4141414142424242414141414242424241414141
with data=0x414243
) on forked L1 on Sepolia using a well known privatekey.From a simple cURL will trigger the onchain execution.
We can see that the transaction on tenderly is a simple movemement of 1 wei to
![image](https://private-user-images.githubusercontent.com/23560242/362666184-61975626-6abe-433c-825a-85b0e699fb65.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4OTczMTcsIm5iZiI6MTczOTg5NzAxNywicGF0aCI6Ii8yMzU2MDI0Mi8zNjI2NjYxODQtNjE5NzU2MjYtNmFiZS00MzNjLTgyNWEtODViMGU2OTlmYjY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDE2NDMzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhYTdiNzQwMTFmNGFmOTNhMzc3YTExNjUxODA3MWJmMDFhZjdiMWMxZTI1YjNmZTdjZjFhODgyZDcyMmZjYzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HxIUdPln2Ee_CKVg13p7MH7CB4Suo14cLjcYOfSGM_s)
0x4141414142424242414141414242424241414141
with calldata=0x414243
.Tests
I made some tests using the HTTP API directly using:
To make better testing, I had to create a mocking interface:
To achieve this, I have added a
executor
to the defender object for helping us in the future for mocking the results.I haved added multiples unit tests in the file
api_test.go
for the new created functions.TestHTTPServerHasOnlyPSPExecutionRoute()
: This ensure the API HTTP is not listenning on another methods or other routes. To make sure no undesired HTTP requests can be crafted on unknown method or path.TestDefenderInitialization()
: This ensure we can create a defender with a mockFetchAndExecute()
method.TestCheckAndReturnRPC()
: This make sure that the RPC ur is correct and valid RPC. This is particular useful for during the development part to not send transaction accidentally on undesired network.TestHandlePostMockFetch()
: This test the HTTP status code result to ensure malformed HTTP request return the correct status code.Additional context
This is the PR N°3, after this one will make 2 PRs again to complete the psp_executor.
Worth noting there is multiples
@todo
tags that would be fixed in the future PRs.I have also improve the current README with the current features.