Skip to content

feat(stylus) - initialize and update fees for pyth contract #2795

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

Merged
merged 63 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
1442303
finished first steps of update_prices. need to test that CPI works + …
ayushboss Jun 19, 2025
9c43c5d
set up framework for contract initialization (i.e. constructor) and u…
ayushboss Jun 20, 2025
e10d2d8
set up framework for contract initialization (i.e. constructor) and u…
ayushboss Jun 20, 2025
7252ffd
updated abi
ayushboss Jun 26, 2025
cfcdc0a
quick refactoring
ayushboss Jun 26, 2025
e044c3b
created crate for shared structs
ayushboss Jun 26, 2025
2fb67fe
Merge branch 'pyth-stylus-sdk-crate' into pyth-stylus-update-and-init…
ayushboss Jun 26, 2025
1ceadcf
cleaned initialize and sorted out stylus storage type issue for now. …
ayushboss Jun 26, 2025
d35a5ea
proof confirmation logic set up, callback function established
ayushboss Jun 27, 2025
b08600d
almost done with updating price, need to reinsert into StorageMap
ayushboss Jun 27, 2025
0bb1763
fix: use StorageMap.setter() to properly store price feed updates
devin-ai-integration[bot] Jun 27, 2025
1ecd765
improved error handling + variable names
ayushboss Jun 30, 2025
28598b9
feat: convert DataSource structs to use serde serialization
devin-ai-integration[bot] Jun 30, 2025
b3ddc02
feat: convert DataSource structs to use proper serde serialization
devin-ai-integration[bot] Jun 30, 2025
5c9453c
added serde deserialization
ayushboss Jun 30, 2025
a6f300e
verified vaa from valid source
ayushboss Jul 1, 2025
c4f3c4e
test framework
ayushboss Jul 1, 2025
3152bef
feat: complete initialize function test with parameter validation and…
devin-ai-integration[bot] Jul 1, 2025
bb02f9f
Merge pull request #2825 from pyth-network/devin/1751389548-stylus-in…
ayushboss Jul 1, 2025
47479f8
fix: remove unused import in integration_tests.rs to clean up warnings
devin-ai-integration[bot] Jul 1, 2025
1caff31
framework for tests
ayushboss Jul 1, 2025
fd2bdc2
feat: clean up stylus test suite with realistic parameters from Starknet
devin-ai-integration[bot] Jul 1, 2025
319f012
fix: add mut to contract variables in test functions to resolve compi…
devin-ai-integration[bot] Jul 1, 2025
870e661
feat: clean up stylus test suite with realistic parameters and stylus…
devin-ai-integration[bot] Jul 1, 2025
b9cd402
added real test data from mock hermes calls
ayushboss Jul 1, 2025
e4ea5a0
Merge branch 'main' into pyth-stylus-update-and-initialize
ayushboss Jul 1, 2025
9eef20a
figuring out mini-alloc
ayushboss Jul 2, 2025
1b62ed1
fixing versioning for wormhole contract
ayushboss Jul 2, 2025
31d7747
fix: resolve wormhole contract compilation and dependency issues for …
devin-ai-integration[bot] Jul 2, 2025
f5a9d45
wormhole integration with tests works + type parsing in pyth contract…
ayushboss Jul 3, 2025
f924e76
fixed test case signatures
ayushboss Jul 3, 2025
e2cc702
fixed test case verification
ayushboss Jul 3, 2025
04fad13
added function for multiple price updates
ayushboss Jul 3, 2025
07c7cf0
added second good update function for the same priceid
ayushboss Jul 3, 2025
e449601
Add 6 integration test cases for Pyth Stylus Receiver contract
devin-ai-integration[bot] Jul 3, 2025
2c0886c
Implement timestamp manipulation for age validation testing
devin-ai-integration[bot] Jul 3, 2025
ae38e3a
clarifying comment
ayushboss Jul 3, 2025
28b402a
added fee handling and a test for it
ayushboss Jul 4, 2025
629f40e
uncommented
ayushboss Jul 4, 2025
c9758cc
got rid of unused imports and calls
ayushboss Jul 4, 2025
27d0fe4
struct comment
ayushboss Jul 4, 2025
e69f3ee
removed extraneous comment
ayushboss Jul 4, 2025
0148862
Merge branch 'main' into pyth-stylus-update-and-initialize
ayushboss Jul 7, 2025
c6df39e
fixed unwrap and expect issues
ayushboss Jul 7, 2025
8c19af9
cargo fmt
ayushboss Jul 8, 2025
aaa05cd
deleted pyth-types crate
ayushboss Jul 8, 2025
a37cab9
moved pyth and wormhole init in tests to init function
ayushboss Jul 8, 2025
1f6b92b
fixed integration test names
ayushboss Jul 8, 2025
9233120
addressed nit
ayushboss Jul 8, 2025
e3155fd
cleaned test_data file, removed explicit function inlining
ayushboss Jul 8, 2025
94bf971
fixed get_update_fee function to match other EVM contracts
ayushboss Jul 8, 2025
c8380bb
stopped hardcoding update fees
ayushboss Jul 8, 2025
cb47ed3
mock get update fee name change
ayushboss Jul 8, 2025
ac3d505
removing extraneous comments
ayushboss Jul 9, 2025
0f9de33
cleaned serialization
ayushboss Jul 9, 2025
ab0b2a3
cleaned up test_data file usage
ayushboss Jul 9, 2025
3a559c0
fixed update and parse functions to take in a vector of vector of u8s…
ayushboss Jul 9, 2025
7f6afc9
added test to verify multiple updates configured
ayushboss Jul 9, 2025
a0310a2
imported mock_instant crate
ayushboss Jul 9, 2025
0681af5
feat: implement mock_instant integration for get_current_timestamp
devin-ai-integration[bot] Jul 9, 2025
ba64927
feat: add cfg(test) attributes to all test_data.rs functions
devin-ai-integration[bot] Jul 9, 2025
5ded54c
final fixes
ayushboss Jul 11, 2025
de11375
Merge branch 'main' into pyth-stylus-update-and-initialize
ayushboss Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
633 changes: 599 additions & 34 deletions target_chains/stylus/Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions target_chains/stylus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[workspace]
members = [
"contracts/wormhole",
"contracts/pyth-receiver"
]
"contracts/pyth-receiver"]
resolver = "2"

[workspace.package]
Expand All @@ -12,7 +11,7 @@ repository = "https://github.com/pyth-network/pyth-crosschain"
version = "0.1.0"

[workspace.dependencies]
stylus-sdk = { version = "0.6.0", default-features = false }
stylus-sdk = { version = "0.9.0", default-features = false }
alloy-primitives = { version = "0.7.6", default-features = false }
mini-alloc = { version = "0.4.2", default-features = false }
motsu = "0.1.0"
Expand Down
28 changes: 16 additions & 12 deletions target_chains/stylus/contracts/pyth-receiver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
[package]
name = "stylus-hello-world"
name = "pyth-receiver-stylus"
version = "0.1.11"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/OffchainLabs/stylus-hello-world"
repository = "https://github.com/OffchainLabs/stylus-hello-world"
keywords = ["arbitrum", "ethereum", "stylus", "alloy"]
description = "Stylus hello world example"
homepage = "https://github.com/pyth-network/pyth-crosschain"
repository = "https://github.com/pyth-network/pyth-crosschain"
keywords = ["arbitrum", "ethereum", "stylus", "alloy", "pyth"]
description = "Pyth receiver contract for the Arbitrum networks, built on Arbitrum Stylus"

[dependencies]
alloy-primitives = "=0.8.20"
alloy-sol-types = "=0.8.20"
stylus-sdk = "0.9.0"
byteorder = { version = "1.4.3" }
hex = { version = "0.4", default-features = false }
pythnet-sdk = { path = "../../../../pythnet/pythnet_sdk" }
serde = { version = "1.0", features = ["derive"] }
wormhole-vaas = "0.1.1"

[dev-dependencies]
alloy-primitives = { version = "=0.8.20", features = ["sha3-keccak"] }
Expand All @@ -21,6 +24,9 @@ ethers = "2.0"
eyre = "0.6.8"
stylus-sdk = { version = "0.9.0", features = ["stylus-test"] }
dotenv = "0.15.0"
motsu = "0.9.0"
wormhole-contract = { path = "../wormhole" }
mock_instant = "0.6.0"

[features]
default = ["mini-alloc"]
Expand All @@ -29,18 +35,16 @@ debug = ["stylus-sdk/debug"]
mini-alloc = ["stylus-sdk/mini-alloc"]

[[bin]]
name = "stylus-hello-world"
name = "pyth-receiver-stylus"
path = "src/main.rs"

[lib]
crate-type = ["lib", "cdylib"]

[profile.release]
codegen-units = 1
strip = true
opt-level = "s"
lto = true
debug = false
panic = "abort"

# If you need to reduce the binary size, it is advisable to try other
# optimization levels, such as "s" and "z"
opt-level = 3
overflow-checks = true
33 changes: 31 additions & 2 deletions target_chains/stylus/contracts/pyth-receiver/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
use alloc::vec::Vec;

#[derive(PartialEq)]
pub enum PythReceiverError {
PriceUnavailable
PriceUnavailable,
InvalidUpdateData,
VaaVerificationFailed,
InvalidVaa,
InvalidWormholeMessage,
InvalidMerkleProof,
InvalidAccumulatorMessage,
InvalidMerkleRoot,
InvalidMerklePath,
InvalidUnknownSource,
NewPriceUnavailable,
InvalidAccumulatorMessageType,
InsufficientFee,
InvalidEmitterAddress,
TooManyUpdates,
}

impl core::fmt::Debug for PythReceiverError {
Expand All @@ -14,6 +29,20 @@ impl From<PythReceiverError> for Vec<u8> {
fn from(error: PythReceiverError) -> Vec<u8> {
vec![match error {
PythReceiverError::PriceUnavailable => 1,
PythReceiverError::InvalidUpdateData => 2,
PythReceiverError::VaaVerificationFailed => 3,
PythReceiverError::InvalidVaa => 4,
PythReceiverError::InvalidWormholeMessage => 5,
PythReceiverError::InvalidMerkleProof => 6,
PythReceiverError::InvalidAccumulatorMessage => 7,
PythReceiverError::InvalidMerkleRoot => 8,
PythReceiverError::InvalidMerklePath => 9,
PythReceiverError::InvalidUnknownSource => 10,
PythReceiverError::NewPriceUnavailable => 11,
PythReceiverError::InvalidAccumulatorMessageType => 12,
PythReceiverError::InsufficientFee => 13,
PythReceiverError::InvalidEmitterAddress => 14,
PythReceiverError::TooManyUpdates => 15,
}]
}
}
}
Loading