Skip to content

Commit 4a9c2c1

Browse files
Merge branch 'pyth-network:main' into stylus-sdk
2 parents 9e34259 + 224924e commit 4a9c2c1

File tree

260 files changed

+16360
-5764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+16360
-5764
lines changed

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,20 @@ and [examples](https://github.com/pyth-network/pyth-examples/tree/main/price_fee
3535
3636
Fortuna is an off-chain service which can be used by [Entropy](https://pyth.network/entropy) providers.
3737

38-
## Development
38+
## Local Development
39+
40+
### Setup
41+
42+
Please install the following tools in order to work in this repository:
43+
44+
- [NVM](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) to manage your node version, then run `nvm use 20` to ensure you are using node version 20.
45+
- [Foundry](https://book.getfoundry.sh/getting-started/installation) in order to use `forge` for Ethereum contract development
46+
- [Solana CLI](https://solana.com/docs/intro/installation) for working with Solana programs.
47+
- After installing, please run `solana keygen new` to generate a local private key.
48+
- [Anchor](https://www.anchor-lang.com/docs/installation) for developing Solana programs.
49+
- [Pre-commit](https://pre-commit.com/) is used to automatically format and lint the repository.
50+
- After installing, please run `pre-commit install` in the root of the repo to configure the checks to run on each git commit.
51+
- [Rust](https://www.rust-lang.org/tools/install)
3952

4053
### Pull requests
4154

@@ -45,14 +58,16 @@ to update the package versions following the [Semantic Versioning](https://semve
4558

4659
### Releases
4760

48-
The repository has a CI workflow that will release javascript packages whose version number has changed.
49-
To perform a release, follow these steps:
61+
The repository has several CI workflows that automatically release new versions of the various components when a new Github release is published.
62+
Each component's workflow uses a specific tag format including the component name and version number (e.g., Fortuna uses the tag `fortuna-vX.Y.Z`).
63+
The general process for creating a new release is:
5064

51-
1. Update the version number in the `package.json` file for the package(s) you wish to release. Please follow [Semantic Versioning](https://semver.org/) for package versions.
65+
1. Update the version number of the component in the repo, e.g., in `package.json` or `Cargo.toml` or wherever. Please follow [Semantic Versioning](https://semver.org/) for package versions.
5266
2. Submit a PR with the changes and merge them in to main.
53-
3. Create a new tag `pyth-js-v<number>` and push to github. You can simply increment the version number each time -- it doesn't affect any of the published information.
54-
4. Pushing the tag automatically triggers a CI workflow to publish the updated packages to NPM.
67+
3. Create a new release on github. Configure the release to create a new tag when published. Set the tag name and version for the component you wish to release -- see the [Releases](https://github.com/pyth-network/pyth-crosschain/releases) page to identify the relevant tag.
68+
4. Publish the release. This step will automatically trigger a Github Action to build the package and release it. This step will e.g., publish packages to NPM, or build and push docker images.
5569

70+
Note that all javascript packages are released together using a tag of the form `pyth-js-v<number>`. (The `number` is arbitrary.)
5671
If you have a javascript package that shouldn't be published, simply add `"private": "true"` to the `package.json` file
5772
and it will be excluded from the publishing workflow. If you are creating a new public javascript package, you should add
5873
the following config option to `package.json`:
@@ -63,16 +78,6 @@ the following config option to `package.json`:
6378
},
6479
```
6580

66-
### pre-commit hooks
67-
68-
pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following [their website](https://pre-commit.com/). In order to enable checks for this repo run `pre-commit install` from command-line in the root of this repo.
69-
70-
The checks are also performed in the CI to ensure the code follows consistent formatting.
71-
72-
### Tilt CI
73-
74-
Integration tests run in Tilt (via the `tilt ci` command). The Tilt CI workflow requires approval from a member of the Pyth team. If you are a member, click on "Details" next to the "Workflow / ci-pyth-crosschain" check in a pull request, and then on the "Resume" button on the workflow page.
75-
7681
### Typescript Monorepo
7782

7883
All of the typescript / javascript packages in this repository are part of a

apps/api-reference/jsx.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* This file only exists because in react 19, the JSX namespace was moved under
3+
* the React export. However, some libraries (e.g. react-markdown) still have
4+
* some things typed as `JSX.<Something>`. Until those libraries update to
5+
* import the namespace correctly, we'll need this declaration file in place to
6+
* expose JSX via the old global location.
7+
*/
8+
9+
import type { JSX as Jsx } from "react/jsx-runtime";
10+
11+
declare global {
12+
namespace JSX {
13+
type ElementClass = Jsx.ElementClass;
14+
type Element = Jsx.Element;
15+
type IntrinsicElements = Jsx.IntrinsicElements;
16+
}
17+
}

apps/api-reference/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/api-reference/src/markdown-components.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ export const MARKDOWN_COMPONENTS = {
3131
</Code>
3232
);
3333
} else {
34-
// @ts-expect-error react-markdown doesn't officially support react 19
35-
// yet; there's no issues here in practice but the types don't currently
36-
// unify
3734
return <pre {...props} />;
3835
}
3936
},

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
[package]
2-
name = "fortuna"
3-
version = "6.5.5"
2+
name = "fortuna"
3+
version = "6.7.1"
44
edition = "2021"
55

66
[dependencies]
7-
anyhow = "1.0.75"
8-
axum = { version = "0.6.20", features = ["json", "ws", "macros"] }
9-
axum-macros = { version = "0.3.8" }
10-
base64 = { version = "0.21.0" }
7+
anyhow = "1.0.75"
8+
axum = { version = "0.6.20", features = ["json", "ws", "macros"] }
9+
axum-macros = { version = "0.3.8" }
10+
base64 = { version = "0.21.0" }
1111
bincode = "1.3.3"
12-
byteorder = "1.5.0"
13-
clap = { version = "4.4.6", features = ["derive", "cargo", "env"] }
14-
ethabi = "18.0.0"
15-
ethers = { version = "2.0.14", features = ["ws"] }
16-
futures = { version = "0.3.28" }
12+
byteorder = "1.5.0"
13+
clap = { version = "4.4.6", features = ["derive", "cargo", "env"] }
14+
ethabi = "18.0.0"
15+
ethers = { version = "2.0.14", features = ["ws"] }
16+
futures = { version = "0.3.28" }
1717
hex = "0.4.3"
18-
prometheus-client = { version = "0.21.2" }
18+
prometheus-client = { version = "0.21.2" }
1919
pythnet-sdk = { path = "../../pythnet/pythnet_sdk", features = ["strum"] }
20-
rand = "0.8.5"
21-
reqwest = { version = "0.11.22", features = ["json", "blocking"] }
22-
serde = { version = "1.0.188", features = ["derive"] }
23-
serde_qs = { version = "0.12.0", features = ["axum"] }
24-
serde_json = "1.0.107"
20+
rand = "0.8.5"
21+
reqwest = { version = "0.11.22", features = ["json", "blocking"] }
22+
serde = { version = "1.0.188", features = ["derive"] }
23+
serde_qs = { version = "0.12.0", features = ["axum"] }
24+
serde_json = "1.0.107"
2525
serde_with = { version = "3.4.0", features = ["hex", "base64"] }
2626
serde_yaml = "0.9.25"
27-
sha3 = "0.10.8"
28-
tokio = { version = "1.33.0", features = ["full"] }
29-
tower-http = { version = "0.4.0", features = ["cors"] }
30-
tracing = { version = "0.1.37", features = ["log"] }
27+
sha3 = "0.10.8"
28+
tokio = { version = "1.33.0", features = ["full"] }
29+
tower-http = { version = "0.4.0", features = ["cors"] }
30+
tracing = { version = "0.1.37", features = ["log"] }
3131
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
32-
utoipa = { version = "3.4.0", features = ["axum_extras"] }
33-
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
32+
utoipa = { version = "3.4.0", features = ["axum_extras"] }
33+
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
3434
once_cell = "1.18.0"
3535
lazy_static = "1.4.0"
3636
url = "2.5.0"
37-
chrono = { version = "0.4.38", features = ["clock", "std"] , default-features = false}
37+
chrono = { version = "0.4.38", features = [
38+
"clock",
39+
"std",
40+
], default-features = false }
3841
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
3942
thiserror = "1.0.61"
4043
futures-locks = "0.7.1"

apps/fortuna/config.sample.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ chains:
1212
# How much to charge in fees
1313
fee: 1500000000000000
1414

15+
# Multiplier for the priority fee estimate, as a percentage (i.e., 100 = no change).
16+
# Defaults to 100 if the field is omitted.
17+
priority_fee_multiplier_pct: 100
18+
1519
# Configuration for dynamic fees under high gas prices. The keeper will set
1620
# on-chain fees to make between [min_profit_pct, max_profit_pct] of the max callback
1721
# cost in profit per transaction.

apps/fortuna/src/chain/eth_gas_oracle.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ pub const EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE: i64 = 200;
3939
#[must_use]
4040
pub struct EthProviderOracle<M: Middleware> {
4141
provider: M,
42+
priority_fee_multiplier_pct: u64,
4243
}
4344

4445
impl<M: Middleware> EthProviderOracle<M> {
45-
pub fn new(provider: M) -> Self {
46-
Self { provider }
46+
pub fn new(provider: M, priority_fee_multiplier_pct: u64) -> Self {
47+
Self {
48+
provider,
49+
priority_fee_multiplier_pct,
50+
}
4751
}
4852
}
4953

@@ -61,10 +65,19 @@ where
6165
}
6266

6367
async fn estimate_eip1559_fees(&self) -> Result<(U256, U256)> {
64-
self.provider
68+
let (max_fee_per_gas, max_priority_fee_per_gas) = self
69+
.provider
6570
.estimate_eip1559_fees(Some(eip1559_default_estimator))
6671
.await
67-
.map_err(|err| GasOracleError::ProviderError(Box::new(err)))
72+
.map_err(|err| GasOracleError::ProviderError(Box::new(err)))?;
73+
74+
// Apply the multiplier to max_priority_fee_per_gas
75+
let max_priority_fee_per_gas = max_priority_fee_per_gas
76+
.checked_mul(U256::from(self.priority_fee_multiplier_pct))
77+
.and_then(|x| x.checked_div(U256::from(100)))
78+
.unwrap_or(max_priority_fee_per_gas);
79+
80+
Ok((max_fee_per_gas, max_priority_fee_per_gas))
6881
}
6982
}
7083

@@ -79,12 +92,14 @@ pub fn eip1559_default_estimator(base_fee_per_gas: U256, rewards: Vec<Vec<U256>>
7992
U256::from(EIP1559_FEE_ESTIMATION_DEFAULT_PRIORITY_FEE),
8093
)
8194
};
95+
8296
let potential_max_fee = base_fee_surged(base_fee_per_gas);
8397
let max_fee_per_gas = if max_priority_fee_per_gas > potential_max_fee {
8498
max_priority_fee_per_gas + potential_max_fee
8599
} else {
86100
potential_max_fee
87101
};
102+
88103
(max_fee_per_gas, max_priority_fee_per_gas)
89104
}
90105

apps/fortuna/src/chain/ethereum.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
211211
provider: Provider<T>,
212212
) -> Result<SignablePythContractInner<T>> {
213213
let chain_id = provider.get_chainid().await?;
214-
let gas_oracle = EthProviderOracle::new(provider.clone());
214+
let gas_oracle =
215+
EthProviderOracle::new(provider.clone(), chain_config.priority_fee_multiplier_pct);
215216
let wallet__ = private_key
216217
.parse::<LocalWallet>()?
217218
.with_chain_id(chain_id.as_u64());

apps/fortuna/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ pub struct EthereumConfig {
166166
/// Maximum number of hashes to record in a request.
167167
/// This should be set according to the maximum gas limit the provider supports for callbacks.
168168
pub max_num_hashes: Option<u32>,
169+
170+
/// The percentage multiplier to apply to the priority fee (100 = no change, e.g. 150 = 150% of base fee)
171+
#[serde(default = "default_priority_fee_multiplier_pct")]
172+
pub priority_fee_multiplier_pct: u64,
169173
}
170174

171175
/// A commitment that the provider used to generate random numbers at some point in the past.
@@ -215,6 +219,10 @@ fn default_chain_sample_interval() -> u64 {
215219
1
216220
}
217221

222+
fn default_priority_fee_multiplier_pct() -> u64 {
223+
100
224+
}
225+
218226
/// Configuration values for the keeper service that are shared across chains.
219227
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
220228
pub struct KeeperConfig {

0 commit comments

Comments
 (0)