Skip to content

feat(stylus) - governance (minus upgrade contract) #2877

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 54 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0965156
started governance work
ayushboss Jul 11, 2025
4656faf
feat(stylus): complete governance_structs.rs implementation
devin-ai-integration[bot] Jul 11, 2025
7ff104b
cleaning up byte compression
ayushboss Jul 11, 2025
3fa19cd
fixing skeleton of lib script
ayushboss Jul 11, 2025
616fc3e
pushing governancepayload struct
ayushboss Jul 11, 2025
6fcfeba
fix(stylus): resolve governance match statement compilation errors
devin-ai-integration[bot] Jul 11, 2025
bdc5747
finished skeleton of set fee function
ayushboss Jul 11, 2025
32216ce
adding untracked files
ayushboss Jul 14, 2025
092347e
Merge branch 'pyth-stylus-final-functions' into pyth-stylus-governanc…
ayushboss Jul 14, 2025
bfad57d
setup first set of governance functions for evaluation
ayushboss Jul 14, 2025
2047dbf
fix: resolve governance function compilation errors
devin-ai-integration[bot] Jul 14, 2025
38d1f61
fix: implement proper data source clearing in set_data_sources
devin-ai-integration[bot] Jul 14, 2025
cf1c462
feat: implement Erase trait for DataSourceStorage
devin-ai-integration[bot] Jul 14, 2025
2cf7ef8
st
ayushboss Jul 14, 2025
f25ac83
fix: add missing SetTransactionFee and WithdrawFee governance actions
devin-ai-integration[bot] Jul 14, 2025
8fabb89
feat: add Stylus events for governance instructions
devin-ai-integration[bot] Jul 14, 2025
c783efa
feat: complete governance event implementation
devin-ai-integration[bot] Jul 14, 2025
421b780
formatted
ayushboss Jul 14, 2025
35a333b
fix: replace deprecated evm::log with stylus_core::log
devin-ai-integration[bot] Jul 15, 2025
f792e26
finishing first governance test
ayushboss Jul 15, 2025
a6c588d
Complete test_set_data_sources function to verify governance instruct…
devin-ai-integration[bot] Jul 15, 2025
c1e6bad
pushing temp changes.
ayushboss Jul 15, 2025
8367d4a
fix: implement proper Debug and Display traits for PythReceiverError …
devin-ai-integration[bot] Jul 15, 2025
50ca713
temp stash
ayushboss Jul 15, 2025
5de37ea
fixing hex vaa address
ayushboss Jul 17, 2025
9927f8a
Merge branch 'main' into pyth-stylus-governance-impl
ayushboss Jul 17, 2025
2aae277
figured out test_set_data_source errors
ayushboss Jul 17, 2025
561be32
added new governance tests, set valid data sources not working yet th…
ayushboss Jul 18, 2025
9d968ca
Add governance VAA test cases for SetFeeInToken, SetWormholeAddress, …
devin-ai-integration[bot] Jul 21, 2025
42a4142
Update VAA hex strings with properly signed governance VAAs
devin-ai-integration[bot] Jul 21, 2025
e63f83c
Update governance test VAAs with corrected hex strings
devin-ai-integration[bot] Jul 21, 2025
0b71196
Update withdraw_fee test VAA to use Alice's address as fee recipient
devin-ai-integration[bot] Jul 21, 2025
76afb02
Add debug changes and VAA generation helper
devin-ai-integration[bot] Jul 21, 2025
d62b352
commnented out withdraw fee test
ayushboss Jul 21, 2025
8676709
Add internal verification to governance test functions
devin-ai-integration[bot] Jul 21, 2025
a308034
Add sequence number verification to remaining governance test functions
devin-ai-integration[bot] Jul 21, 2025
27ab032
Fix test_set_valid_period and clean up imports
devin-ai-integration[bot] Jul 21, 2025
4bd1552
Fix VAA validation in test_authorize_governance_data_source_transfer
devin-ai-integration[bot] Jul 21, 2025
52f5243
commented out motsu-incompatible tests, cargo fmt
ayushboss Jul 21, 2025
e5bb84c
Merge branch 'main' into pyth-stylus-governance-impl
ayushboss Jul 21, 2025
946f6e5
removed generate vaa script
ayushboss Jul 21, 2025
2441d0a
Update test_set_wormhole_address with wormhole_contract_2 parameter a…
devin-ai-integration[bot] Jul 21, 2025
b8f6dad
Fix VAA construction in test_set_wormhole_address to include address …
devin-ai-integration[bot] Jul 21, 2025
066d45d
first fixes
ayushboss Jul 22, 2025
f7f6f4e
Merge branch 'pyth-stylus-governance-impl' of https://github.com/pyth…
ayushboss Jul 22, 2025
c7be32b
f
ayushboss Jul 22, 2025
2082a85
Implement event assertions in pyth_governance_test.rs
devin-ai-integration[bot] Jul 22, 2025
e36fdc1
removed SetFeeInToken
ayushboss Jul 23, 2025
2e17cc9
cleaned byte reading checks, fixed authorize_governance_transfer vers…
ayushboss Jul 23, 2025
daa97c3
Merge branch 'main' into pyth-stylus-governance-impl
ayushboss Jul 23, 2025
2251d34
restoring jrpc_handle.rs file
ayushboss Jul 23, 2025
849e149
fixing jrpc_handle.rs cargo fmt
ayushboss Jul 23, 2025
28d4a4a
fixing import order jrpc_handle.rs
ayushboss Jul 23, 2025
61a5a5c
addressed nit
ayushboss Jul 23, 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
106 changes: 104 additions & 2 deletions target_chains/stylus/contracts/pyth-receiver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,105 @@ pub enum PythReceiverError {
PriceFeedNotFoundWithinRange,
NoFreshUpdate,
PriceFeedNotFound,
InvalidGovernanceMessage,
InvalidGovernanceTarget,
InvalidGovernanceAction,
InvalidGovernanceDataSource,
OldGovernanceMessage,
GovernanceMessageAlreadyExecuted,
InvalidWormholeAddressToSet,
WormholeUninitialized,
}

impl core::fmt::Debug for PythReceiverError {
fn fmt(&self, _: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Ok(())
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
PythReceiverError::PriceUnavailable => write!(f, "PriceUnavailable"),
PythReceiverError::InvalidUpdateData => write!(f, "InvalidUpdateData"),
PythReceiverError::VaaVerificationFailed => write!(f, "VaaVerificationFailed"),
PythReceiverError::InvalidVaa => write!(f, "InvalidVaa"),
PythReceiverError::InvalidWormholeMessage => write!(f, "InvalidWormholeMessage"),
PythReceiverError::InvalidMerkleProof => write!(f, "InvalidMerkleProof"),
PythReceiverError::InvalidAccumulatorMessage => write!(f, "InvalidAccumulatorMessage"),
PythReceiverError::InvalidMerkleRoot => write!(f, "InvalidMerkleRoot"),
PythReceiverError::InvalidMerklePath => write!(f, "InvalidMerklePath"),
PythReceiverError::InvalidUnknownSource => write!(f, "InvalidUnknownSource"),
PythReceiverError::NewPriceUnavailable => write!(f, "NewPriceUnavailable"),
PythReceiverError::InvalidAccumulatorMessageType => {
write!(f, "InvalidAccumulatorMessageType")
}
PythReceiverError::InsufficientFee => write!(f, "InsufficientFee"),
PythReceiverError::InvalidEmitterAddress => write!(f, "InvalidEmitterAddress"),
PythReceiverError::TooManyUpdates => write!(f, "TooManyUpdates"),
PythReceiverError::PriceFeedNotFoundWithinRange => {
write!(f, "PriceFeedNotFoundWithinRange")
}
PythReceiverError::NoFreshUpdate => write!(f, "NoFreshUpdate"),
PythReceiverError::PriceFeedNotFound => write!(f, "PriceFeedNotFound"),
PythReceiverError::InvalidGovernanceMessage => write!(f, "InvalidGovernanceMessage"),
PythReceiverError::InvalidGovernanceTarget => write!(f, "InvalidGovernanceTarget"),
PythReceiverError::InvalidGovernanceAction => write!(f, "InvalidGovernanceAction"),
PythReceiverError::InvalidGovernanceDataSource => {
write!(f, "InvalidGovernanceDataSource")
}
PythReceiverError::OldGovernanceMessage => write!(f, "OldGovernanceMessage"),
PythReceiverError::GovernanceMessageAlreadyExecuted => {
write!(f, "GovernanceMessageAlreadyExecuted")
}
PythReceiverError::InvalidWormholeAddressToSet => {
write!(f, "InvalidWormholeAddressToSet")
}
PythReceiverError::WormholeUninitialized => {
write!(f, "Wormhole is uninitialized, please set the Wormhole address and initialize the contract first")
}
}
}
}

impl core::fmt::Display for PythReceiverError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
PythReceiverError::PriceUnavailable => write!(f, "Price unavailable"),
PythReceiverError::InvalidUpdateData => write!(f, "Invalid update data"),
PythReceiverError::VaaVerificationFailed => write!(f, "VAA verification failed"),
PythReceiverError::InvalidVaa => write!(f, "Invalid VAA"),
PythReceiverError::InvalidWormholeMessage => write!(f, "Invalid Wormhole message"),
PythReceiverError::InvalidMerkleProof => write!(f, "Invalid Merkle proof"),
PythReceiverError::InvalidAccumulatorMessage => {
write!(f, "Invalid accumulator message")
}
PythReceiverError::InvalidMerkleRoot => write!(f, "Invalid Merkle root"),
PythReceiverError::InvalidMerklePath => write!(f, "Invalid Merkle path"),
PythReceiverError::InvalidUnknownSource => write!(f, "Invalid unknown source"),
PythReceiverError::NewPriceUnavailable => write!(f, "New price unavailable"),
PythReceiverError::InvalidAccumulatorMessageType => {
write!(f, "Invalid accumulator message type")
}
PythReceiverError::InsufficientFee => write!(f, "Insufficient fee"),
PythReceiverError::InvalidEmitterAddress => write!(f, "Invalid emitter address"),
PythReceiverError::TooManyUpdates => write!(f, "Too many updates"),
PythReceiverError::PriceFeedNotFoundWithinRange => {
write!(f, "Price feed not found within range")
}
PythReceiverError::NoFreshUpdate => write!(f, "No fresh update"),
PythReceiverError::PriceFeedNotFound => write!(f, "Price feed not found"),
PythReceiverError::InvalidGovernanceMessage => write!(f, "Invalid governance message"),
PythReceiverError::InvalidGovernanceTarget => write!(f, "Invalid governance target"),
PythReceiverError::InvalidGovernanceAction => write!(f, "Invalid governance action"),
PythReceiverError::InvalidGovernanceDataSource => {
write!(f, "Invalid governance data source")
}
PythReceiverError::OldGovernanceMessage => write!(f, "Old governance message"),
PythReceiverError::GovernanceMessageAlreadyExecuted => {
write!(f, "Governance message already executed")
}
PythReceiverError::InvalidWormholeAddressToSet => {
write!(f, "Invalid Wormhole address to set")
}
PythReceiverError::WormholeUninitialized => {
write!(f, "Wormhole is uninitialized, please set the Wormhole address and initialize the contract first")
}
}
}
}

Expand All @@ -49,6 +143,14 @@ impl From<PythReceiverError> for Vec<u8> {
PythReceiverError::PriceFeedNotFoundWithinRange => 16,
PythReceiverError::NoFreshUpdate => 17,
PythReceiverError::PriceFeedNotFound => 18,
PythReceiverError::InvalidGovernanceMessage => 19,
PythReceiverError::InvalidGovernanceTarget => 20,
PythReceiverError::InvalidGovernanceAction => 21,
PythReceiverError::InvalidGovernanceDataSource => 22,
PythReceiverError::OldGovernanceMessage => 23,
PythReceiverError::GovernanceMessageAlreadyExecuted => 24,
PythReceiverError::InvalidWormholeAddressToSet => 25,
PythReceiverError::WormholeUninitialized => 26,
}]
}
}
Loading