Skip to content
Merged
Show file tree
Hide file tree
Changes from 191 commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
ac1aa41
Add the algorithm code
MitchTurner Jun 7, 2024
bc9efa0
WIP
MitchTurner Jun 7, 2024
31ea5c4
Add some tests to define the updater behavior
Jun 8, 2024
7e6546a
Add a couple more tests, WIP getting the second to pass
MitchTurner Jun 8, 2024
6707c3e
Fix test, refactor out single update into two
MitchTurner Jun 9, 2024
09a0c95
Refactor
MitchTurner Jun 9, 2024
da3c887
WIP rewrite the chart generation stuff
MitchTurner Jun 9, 2024
cdfc206
Add profit stuff to chart, add rewards
MitchTurner Jun 9, 2024
15a45ed
Add some naive profit corrections
MitchTurner Jun 9, 2024
03c6a4a
Remove the old stuff that is not being used
MitchTurner Jun 9, 2024
459f8fd
Add actual algo that the updater generates, fix tests accordingly
MitchTurner Jun 10, 2024
b713739
Update gas price with l2 block data
MitchTurner Jun 10, 2024
91fe558
Use algo generation in simulation
MitchTurner Jun 10, 2024
5c3c277
Straighten out the profit chart to be aligned after every da_recording
MitchTurner Jun 10, 2024
da7ea98
Fix the noise
MitchTurner Jun 11, 2024
f05c594
Refactor to calculate exec gas price eagarly and calculate da gas pri…
MitchTurner Jun 11, 2024
644c2da
Refactor a bit to allow p and d values, rename some stuff
MitchTurner Jun 12, 2024
9c40f42
Add d value to tests
MitchTurner Jun 12, 2024
0783439
WIP
MitchTurner Jun 12, 2024
d7d7d55
Use real gas limit values stablize algo a bit.
MitchTurner Jun 12, 2024
106569d
Set params to somewhat steady state
MitchTurner Jun 12, 2024
6db37a6
Add average profit values
MitchTurner Jun 12, 2024
781424f
Cleanup, add naive optimisation
MitchTurner Jun 13, 2024
88793e9
Refactor
MitchTurner Jun 13, 2024
b7c10c6
Replace d value :), start adding max change
MitchTurner Jun 13, 2024
e245f98
Add change amount tests, remove unused params
MitchTurner Jun 13, 2024
95ed269
Remove avg window
MitchTurner Jun 13, 2024
95ab959
Refactor and cleanup
MitchTurner Jun 13, 2024
53eebfe
Merge remote-tracking branch 'origin' into feature/gas-price-algo
MitchTurner Jun 13, 2024
5d8d7bb
fix fields
MitchTurner Jun 13, 2024
8ecd034
Cleanup, refactor
MitchTurner Jun 13, 2024
72a4ff8
Appease Clippy-sama
MitchTurner Jun 13, 2024
2b29292
Update CHANGELOG
MitchTurner Jun 13, 2024
41ed222
Rename file
MitchTurner Jun 13, 2024
18019ba
Fix CHANGELOG
MitchTurner Jun 13, 2024
8625caa
Actually fix CHANGELOG
MitchTurner Jun 13, 2024
6677f03
Reorder test file
MitchTurner Jun 14, 2024
33fe1a3
Merge branch 'master' into feature/gas-price-algo
MitchTurner Jun 14, 2024
5ea4c26
Try to fix changelog again, minor adjustments
MitchTurner Jun 14, 2024
9d4cda7
Add consts for reused colors
MitchTurner Jun 14, 2024
20a8b11
Add more docs for algorithm
MitchTurner Jun 14, 2024
a28c653
Add more docs
MitchTurner Jun 14, 2024
37fa17d
Merge remote-tracking branch 'origin' into feature/gas-price-algo
MitchTurner Jun 14, 2024
220d5e4
Update lock file
MitchTurner Jun 14, 2024
19fe50b
Update version to match
MitchTurner Jun 14, 2024
507e12e
Merge branch 'master' into feature/gas-price-algo
MitchTurner Jun 15, 2024
a8bcab1
REmove all arithmetic side effects
MitchTurner Jun 16, 2024
54e48f4
Remove float, fix more clippy complaints
MitchTurner Jun 16, 2024
e228fa1
Add minimum gas price
MitchTurner Jun 16, 2024
cfc8538
Modulate percent rather than static amount for exec gas price
MitchTurner Jun 17, 2024
cc01db7
Move the analysis stuff into its own crate, fix insidious bug
MitchTurner Jun 18, 2024
a240657
Remove commented code
MitchTurner Jun 18, 2024
6e9dc0d
Merge remote-tracking branch 'origin' into feature/gas-price-algo
MitchTurner Jun 18, 2024
305ceaa
Update lock file
MitchTurner Jun 18, 2024
1f2be1c
Fix crate names, lint
MitchTurner Jun 18, 2024
ebae0f7
Update docs
MitchTurner Jun 18, 2024
8bfd2bc
Create basic updater struct
MitchTurner Jun 14, 2024
dd660b3
Implement for struct
MitchTurner Jun 14, 2024
c6b1e7b
WIP add tests
MitchTurner Jun 16, 2024
5d1bd21
Fix dep names and versino
MitchTurner Jun 18, 2024
b4d65b7
WIP flakey test
MitchTurner Jun 18, 2024
0cc38cb
Move min gas price to exec to avoid error
MitchTurner Jun 18, 2024
209e3b8
Add minimum da gas price
MitchTurner Jun 18, 2024
395a91b
Update crates/fuel-gas-price-algorithm/src/lib.rs
MitchTurner Jun 18, 2024
31450f9
Update crates/fuel-gas-price-algorithm/src/lib.rs
MitchTurner Jun 18, 2024
158b663
Fix unchanged name, get anaysis running again
MitchTurner Jun 18, 2024
6caa7f7
Update bytecode version
MitchTurner Jun 19, 2024
2e76450
Fix test
MitchTurner Jun 19, 2024
1088ff1
Merge branch 'feature/gas-price-algo' into feature/implement-gas-pric…
MitchTurner Jun 19, 2024
c28ceea
Merge remote-tracking branch 'origin' into feature/implement-gas-pric…
MitchTurner Jun 19, 2024
3ffe2cb
Fix CHANGELOG
MitchTurner Jun 19, 2024
392054a
Add init test
MitchTurner Jun 19, 2024
975db7d
Add other init test
MitchTurner Jun 19, 2024
0d741b3
Add test for updating metadata
MitchTurner Jun 19, 2024
336993c
Remove DA stuff because we do not need it yet
MitchTurner Jun 19, 2024
284d900
Sort Cargo.toml
MitchTurner Jun 19, 2024
5357520
Appease Clippy-sama
MitchTurner Jun 19, 2024
05d8323
WIP
MitchTurner Jun 20, 2024
8a6d266
Move adapter to fuel-core scope
MitchTurner Jun 20, 2024
b496406
Remove old code, fix deps
MitchTurner Jun 20, 2024
b48a6be
WIP add tests on fuel-core adapter side
MitchTurner Jun 21, 2024
f9e82c8
Implement l2block source for new adapter and pass basic test
MitchTurner Jun 22, 2024
0fa30af
Add test to show the l2 source waits for a new block to be added
MitchTurner Jun 22, 2024
ba3becc
Refactor, add new metadata type
MitchTurner Jun 22, 2024
a417616
WIP add gas price metadata to storage
MitchTurner Jun 23, 2024
9d424a1
Merge branch 'master' into feature/implement-gas-price-updater-for-se…
xgreenx Jun 24, 2024
7145cea
Add metadata to database
MitchTurner Jun 24, 2024
1b40ff5
Add not found test
MitchTurner Jun 24, 2024
f731a86
Add set test and impl
MitchTurner Jun 24, 2024
1cb11cb
Modify block lookup to include transactions not just tx_ids
MitchTurner Jun 24, 2024
4437a79
Merge branch 'feature/implement-gas-price-updater-for-service' into f…
MitchTurner Jun 24, 2024
0f824a9
Add consensus param lookup to l2 block info stuff
MitchTurner Jun 24, 2024
e3dbdbe
WIP add block info tests
MitchTurner Jun 25, 2024
76c2964
Update code to pass test for gas fullness in block info
MitchTurner Jun 25, 2024
be65d2c
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jun 25, 2024
f9add03
Finish merge, update CHANGELOG
MitchTurner Jun 25, 2024
dd1b3d0
Fix README typo
MitchTurner Jun 25, 2024
5f8a149
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jun 26, 2024
c5d3b07
Update historical view and atomic view trait bounds
MitchTurner Jun 27, 2024
02138df
WIP add new storage column
MitchTurner Jun 27, 2024
cfcc578
WIP new descriptor and use importer for l2 block
MitchTurner Jun 27, 2024
ac296d8
Use write import
xgreenx Jun 27, 2024
77fff14
Get tests compiling again
MitchTurner Jun 27, 2024
4ea636e
Fix failing tests and get block stream working
MitchTurner Jun 28, 2024
5805a23
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jun 28, 2024
2406993
Fix most of compilation errors
MitchTurner Jun 28, 2024
3129fe9
Get metadata tests passing
MitchTurner Jun 28, 2024
dd16cf3
Remove error swallowing
MitchTurner Jun 28, 2024
eeb5150
Remove unused constraint
MitchTurner Jun 28, 2024
ce8d34d
Update bytecode
MitchTurner Jun 28, 2024
144acfa
Constrain features
MitchTurner Jun 28, 2024
c4c649a
Uncomment lint
MitchTurner Jun 28, 2024
2528ac2
Merge branch 'master' into feature/l2-block-source-live-adapter
MitchTurner Jun 29, 2024
5a4ee34
Try to move adapter into service
MitchTurner Jun 29, 2024
d9dd3b4
Fixed compilation
xgreenx Jun 29, 2024
d4c5106
Remove old metadata stuff
MitchTurner Jun 30, 2024
ae9c425
Sort depss
MitchTurner Jun 30, 2024
cebfb13
Cleanup l2 block adapter
MitchTurner Jun 30, 2024
0cfad43
Merge branch 'master' into feature/l2-block-source-live-adapter
Dentosal Jul 1, 2024
78b0675
Make suggested changes from code review
MitchTurner Jul 1, 2024
0d42d5b
Move l2 block source to service, replace database dep with param port
MitchTurner Jul 1, 2024
ddaf65d
Implement settings provider for consensus param provider
MitchTurner Jul 1, 2024
b424c62
Move database stuff to fuel-core
MitchTurner Jul 1, 2024
f80e4c6
Remove metadata for recording blocks because we are not doing DA reco…
MitchTurner Jul 1, 2024
8e71718
Add simplified V1 algorithm without DA
MitchTurner Jul 2, 2024
06d66f3
Move updater to no DA, rename to V0
MitchTurner Jul 2, 2024
e4cb0bb
Include renames, fix simulation
MitchTurner Jul 2, 2024
52c6cb6
Add missed stuff I guess
MitchTurner Jul 2, 2024
322c790
Add test for gas price
MitchTurner Jul 2, 2024
a98885a
Add interface for serialization
MitchTurner Jul 2, 2024
1b1825f
Remove extra fields for block info
MitchTurner Jul 2, 2024
200e946
Remove commented code
MitchTurner Jul 2, 2024
1cd7da2
Make PR review changes
MitchTurner Jul 2, 2024
4249fb5
Make PR review changes
MitchTurner Jul 2, 2024
f117695
Make metadata methods sync
MitchTurner Jul 2, 2024
b280ad5
Fix test to save metadata before trying to get l2 block
MitchTurner Jul 2, 2024
737aa78
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jul 2, 2024
d6dde40
Appease Clippy-sama
MitchTurner Jul 2, 2024
149f666
Fix v0 algo file name
MitchTurner Jul 2, 2024
ccd2246
Fmt
MitchTurner Jul 2, 2024
31b7fcf
Remove unused lock
xgreenx Jul 3, 2024
e9c49e3
Remove unused async
xgreenx Jul 3, 2024
08a12cb
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jul 3, 2024
d2adec3
Update WASM
MitchTurner Jul 3, 2024
267ddde
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jul 5, 2024
6ad67d4
Update code to work with storage trait changes, build wasm bytecode
MitchTurner Jul 5, 2024
d6cc3e7
Merge remote-tracking branch 'origin' into feature/l2-block-source-li…
MitchTurner Jul 6, 2024
bc84ece
Update WASM
MitchTurner Jul 6, 2024
acfb2f3
Move changelog entry to unreleased
MitchTurner Jul 6, 2024
ceb9ab9
WIP
MitchTurner Jun 29, 2024
bd40645
Add real algo to services
MitchTurner Jul 5, 2024
42db5f3
Remove commented code, use better metadata values
MitchTurner Jul 6, 2024
91647e1
Update CHANGELOG
MitchTurner Jul 6, 2024
d929a7d
Made algorithm versioned
MitchTurner Jul 6, 2024
2601823
Simplify interfaces
MitchTurner Jul 6, 2024
a090362
Add worst case interface for V0 algo
MitchTurner Jul 6, 2024
6c2d971
Merge remote-tracking branch 'origin' into feature/add-fuel-algo-updater
MitchTurner Jul 8, 2024
4f6f27e
Update test txs to have enough max gas, remove orthoganal check in test
MitchTurner Jul 8, 2024
b34f318
Make gas price updater configurable
MitchTurner Jul 8, 2024
447f59b
Fix tx builder var name, add receipts to failing test response
MitchTurner Jul 8, 2024
34f56ec
Fix tests
MitchTurner Jul 9, 2024
9f906b5
Add args for client cli for setting gas price parameters
MitchTurner Jul 9, 2024
57dbe88
Add threshold param
MitchTurner Jul 9, 2024
75f5cce
Add integ test for latest gas price
MitchTurner Jul 9, 2024
4773a71
WIP add integ tests for system
MitchTurner Jul 9, 2024
0d79a8f
Add more integ tests for gas price algo updater
MitchTurner Jul 10, 2024
f003d12
Add test for restaring gas price service, but not for resyncing
MitchTurner Jul 10, 2024
cfc04cc
Fix some tests
MitchTurner Jul 10, 2024
fac77cb
Remove fees from a test
MitchTurner Jul 10, 2024
dbce725
Fix other tests with fees
MitchTurner Jul 10, 2024
05cfb2d
Change expected behavior to have threshold be >= instead of >
MitchTurner Jul 11, 2024
328419f
Fix all the divide by zero errors
MitchTurner Jul 11, 2024
b55f8d3
Remove tracing subscribers to clean up tests
MitchTurner Jul 11, 2024
c457cf0
Cleanup
MitchTurner Jul 11, 2024
d9f3a80
Scale gas price factor
MitchTurner Jul 15, 2024
5ddd673
Improve tests
MitchTurner Jul 15, 2024
f93a460
WIP submit txs for integ test gas use
MitchTurner Jul 16, 2024
98c5c12
Add test with actual txs filling the block
MitchTurner Jul 16, 2024
669a5e5
Appease Clippy-sama
MitchTurner Jul 16, 2024
c8a8e0a
Add PR change suggestions
MitchTurner Jul 17, 2024
a0f1aee
Add more PR change suggestions, add new test for when genesis block i…
MitchTurner Jul 18, 2024
ba4a947
Fix spelling
MitchTurner Jul 18, 2024
3334ba5
Appease Clippy-sama
MitchTurner Jul 18, 2024
a612351
Revert removal of raw tx in e2e
MitchTurner Jul 18, 2024
f254c91
Merge branch 'master' into feature/add-fuel-algo-updater
MitchTurner Jul 18, 2024
0c90101
Remove dbgs, consolodate test methods, change defaults
MitchTurner Jul 18, 2024
cb4262a
Improve worst_case function performance, add proptest for good coverage
MitchTurner Jul 18, 2024
349d283
Sort toml
MitchTurner Jul 18, 2024
1d99650
Deal with precision errors
MitchTurner Jul 18, 2024
d2d0e7a
Fix pub/private func access
MitchTurner Jul 18, 2024
0b3cdd0
Fix integ test to allow some over-estimation
MitchTurner Jul 18, 2024
c9e1fcc
Add full range of u64 for percentage in prop test
MitchTurner Jul 19, 2024
627e6cb
Add comment to explain strange code
MitchTurner Jul 19, 2024
fa060f8
Ensure no overflows with new proptest
MitchTurner Jul 19, 2024
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- [1983](https://github.com/FuelLabs/fuel-core/pull/1983): Add adapters for gas price service for accessing database values

### Breaking
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you document new CLI arguments please?

- [2025](https://github.com/FuelLabs/fuel-core/pull/2025): Add new V0 algorithm for gas price to services.
This change includes new flags for the CLI:
- "starting-gas-price" - the starting gas price for the gas price algorithm
- "gas-price-change-percent" - the percent change for each gas price update
- "gas-price-threshold-percent" - the threshold percent for determining if the gas price will be increase or decreased
And the following CLI flags are serving a new purpose
- "min-gas-price" - the minimum gas price that the gas price algorithm will return
## [Version 0.31.0]

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion benches/benches/block_target_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,12 @@ fn service_with_many_contracts(
}

let service = FuelService::new(
CombinedDatabase::new(database, Default::default(), Default::default()),
CombinedDatabase::new(
database,
Default::default(),
Default::default(),
Default::default(),
),
config.clone(),
)
.expect("Unable to start a FuelService");
Expand Down
25 changes: 15 additions & 10 deletions bin/e2e-test-client/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Wallet {
];

// build transaction
let mut tx = TransactionBuilder::script(
let mut tx_builder = TransactionBuilder::script(
script.into_iter().collect(),
asset_id
.to_bytes()
Expand All @@ -202,10 +202,11 @@ impl Wallet {
.chain(0u64.to_bytes().into_iter())
.collect(),
);
tx.max_fee_limit(BASE_AMOUNT);
tx.script_gas_limit(self.consensus_params.tx_params().max_gas_per_tx() / 10);
tx_builder.max_fee_limit(BASE_AMOUNT);
tx_builder
.script_gas_limit(self.consensus_params.tx_params().max_gas_per_tx() / 10);

tx.add_input(Input::contract(
tx_builder.add_input(Input::contract(
Default::default(),
Default::default(),
Default::default(),
Expand All @@ -214,7 +215,7 @@ impl Wallet {
));
for coin in coins {
if let CoinType::Coin(coin) = coin {
tx.add_unsigned_coin_input(
tx_builder.add_unsigned_coin_input(
self.secret,
coin.utxo_id,
coin.amount,
Expand All @@ -223,20 +224,24 @@ impl Wallet {
);
}
}
tx.add_output(Output::contract(0, Default::default(), Default::default()));
tx.add_output(Output::Change {
tx_builder.add_output(Output::contract(
0,
Default::default(),
Default::default(),
));
tx_builder.add_output(Output::Change {
to: self.address,
amount: 0,
asset_id,
});
tx.add_output(Output::Variable {
tx_builder.add_output(Output::Variable {
to: Default::default(),
amount: Default::default(),
asset_id: Default::default(),
});
tx.with_params(self.consensus_params.clone());
tx_builder.with_params(self.consensus_params.clone());

Ok(tx.finalize_as_transaction())
Ok(tx_builder.finalize_as_transaction())
}

/// Transfers coins from this wallet to another
Expand Down
3 changes: 2 additions & 1 deletion bin/e2e-test-client/src/tests/collect_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub async fn collect_fee(ctx: &TestContext) -> Result<(), Failed> {
.iter()
.any(|receipt| matches!(receipt, Receipt::TransferOut { .. }))
{
return Err("collect fee hasn't produced `TransferOut` receipt".into())
let msg = format!("TransferOut receipt not found in receipts: {:?}", receipts);
return Err(msg.into())
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions bin/e2e-test-client/src/tests/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ use fuel_core_types::{
UniqueIdentifier,
},
fuel_types::{
canonical::Deserialize,
canonical::{
Deserialize,
Serialize,
},
Salt,
},
services::executor::TransactionExecutionResult,
};

use fuel_core_types::fuel_types::canonical::Serialize;
use libtest_mimic::Failed;
use std::{
path::Path,
Expand Down Expand Up @@ -145,7 +146,6 @@ pub async fn run_contract_large_state(ctx: &TestContext) -> Result<(), Failed> {
pub async fn arbitrary_transaction(ctx: &TestContext) -> Result<(), Failed> {
const RAW_PATH: &str = "src/tests/test_data/arbitrary_tx.raw";
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this because I don't see what it has to do with test and it was blocking my update.

If we want to add some roundtrip conversion test somewhere between raw/json, that should be separate from this logic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

e2e binary is not a test. It is a binary that runs some tests on a real network. One of the tests is to run an arbitrary transaction where the transaction is hex-encoded from the canonical representation.

The source of the transaction should be raw file, not json file, because it is how the user sends transaction to the blockchain(in a raw representation). The idea of the tool is that you can take any transactions submitted to GraphQL and dry run it on a real network.

I agree that we need to document the use case of the e2e binary better and describe what it is responsible for. But we don't need to remove the logic that we need.

const JSON_PATH: &str = "src/tests/test_data/arbitrary_tx.json";

let dry_run_raw =
std::fs::read_to_string(RAW_PATH).expect("Should read the raw transaction");
let dry_run_json =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
0,
0,
0,
100000
30000000
]
},
"inputs": [
Expand Down
2 changes: 1 addition & 1 deletion bin/e2e-test-client/src/tests/test_data/arbitrary_tx.raw
Original file line number Diff line number Diff line change
@@ -1 +1 @@
000000000000000000000000000186a00000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000008000000000000000100000000000000020000000000000001240000000000000000000000000186a000000000000000008b5a47933cbb7ddbc0392a45a124a2a01f17c657d34d4951324003a2f9aff24a000000000000000157cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000001d34a76ef8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeb709945b9058c3d50f3922bd1b49f92ced2950a9ecaf810aa7829295550cd20000000000002710f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07000000000000000357cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000800000000000000010000000000000002000000000000000124000000000000000000000001c9c38000000000000000008b5a47933cbb7ddbc0392a45a124a2a01f17c657d34d4951324003a2f9aff24a000000000000000157cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000001d34a76ef8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeb709945b9058c3d50f3922bd1b49f92ced2950a9ecaf810aa7829295550cd20000000000002710f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07000000000000000357cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Original file line number Diff line number Diff line change
Expand Up @@ -4138,7 +4138,7 @@
0,
0,
0,
100000
12390831
]
},
"inputs": [
Expand Down
2 changes: 1 addition & 1 deletion bin/e2e-test-client/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn dev_config() -> Config {
let reader = reader.with_chain_config(chain_config);

let mut config = Config::local_node_with_reader(reader);
config.static_gas_price = 1;
config.starting_gas_price = 1;
config.block_producer.coinbase_recipient = Some(
ContractId::from_str(
"0x7777777777777777777777777777777777777777777777777777777777777777",
Expand Down
2 changes: 1 addition & 1 deletion bin/fuel-core/chainspec/local-testnet/chain_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"fee_params": {
"V1": {
"gas_price_factor": 92,
"gas_price_factor": 92000,
"gas_per_byte": 63
}
},
Expand Down
Binary file not shown.
20 changes: 19 additions & 1 deletion bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,22 @@ pub struct Command {
#[arg(long = "native-executor-version", env)]
pub native_executor_version: Option<StateTransitionBytecodeVersion>,

/// The starting gas price for the network
Copy link
Collaborator

Choose a reason for hiding this comment

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

Taking into account that we also need some configuration for DA as well, maybe it makes sense to move all price-related fields into their config. What do yu think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you thinking that we'd submit all the fields for the config in a single CLI argument? I'm not sure how that affects this specific piece of code.

#[arg(long = "starting-gas-price", default_value = "0", env)]
pub starting_gas_price: u64,

/// The percentage change in gas price per block
#[arg(long = "gas-price-change-percent", default_value = "0", env)]
pub gas_price_change_percent: u64,

/// The minimum allowed gas price
#[arg(long = "min-gas-price", default_value = "0", env)]
pub min_gas_price: u64,

/// The percentage threshold for gas price increase
#[arg(long = "gas-price-threshold-percent", default_value = "50", env)]
pub gas_price_threshold_percent: u64,

/// The signing key used when producing blocks.
/// Setting via the `CONSENSUS_KEY_SECRET` ENV var is preferred.
#[arg(long = "consensus-key", env)]
Expand Down Expand Up @@ -245,7 +257,10 @@ impl Command {
debug,
utxo_validation,
native_executor_version,
starting_gas_price,
gas_price_change_percent,
min_gas_price,
gas_price_threshold_percent,
consensus_key,
poa_trigger,
coinbase_recipient,
Expand Down Expand Up @@ -408,7 +423,10 @@ impl Command {
coinbase_recipient,
metrics,
},
static_gas_price: min_gas_price,
starting_gas_price,
gas_price_change_percent,
min_gas_price,
gas_price_threshold_percent,
block_importer,
#[cfg(feature = "relayer")]
relayer: relayer_cfg,
Expand Down
1 change: 1 addition & 0 deletions crates/client/src/client/types/gas_price.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::client::schema;
use fuel_core_types::fuel_types::BlockHeight;

#[derive(Debug, Copy, Clone)]
pub struct LatestGasPrice {
pub gas_price: u64,
pub block_height: BlockHeight,
Expand Down
22 changes: 19 additions & 3 deletions crates/fuel-core/src/combined_database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[cfg(feature = "rocksdb")]
use crate::state::historical_rocksdb::StateRewindPolicy;
use crate::{
database::{
database_description::{
gas_price::GasPriceDatabase,
off_chain::OffChain,
on_chain::OnChain,
relayer::Relayer,
Expand Down Expand Up @@ -28,9 +31,6 @@ use fuel_core_storage::tables::{
use fuel_core_storage::Result as StorageResult;
use std::path::PathBuf;

#[cfg(feature = "rocksdb")]
use crate::state::historical_rocksdb::StateRewindPolicy;

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CombinedDatabaseConfig {
pub database_path: PathBuf,
Expand All @@ -46,18 +46,21 @@ pub struct CombinedDatabase {
on_chain: Database<OnChain>,
off_chain: Database<OffChain>,
relayer: Database<Relayer>,
gas_price: Database<GasPriceDatabase>,
}

impl CombinedDatabase {
pub fn new(
on_chain: Database<OnChain>,
off_chain: Database<OffChain>,
relayer: Database<Relayer>,
gas_price: Database<GasPriceDatabase>,
) -> Self {
Self {
on_chain,
off_chain,
relayer,
gas_price,
}
}

Expand All @@ -66,6 +69,7 @@ impl CombinedDatabase {
crate::state::rocks_db::RocksDb::<OnChain>::prune(path)?;
crate::state::rocks_db::RocksDb::<OffChain>::prune(path)?;
crate::state::rocks_db::RocksDb::<Relayer>::prune(path)?;
crate::state::rocks_db::RocksDb::<GasPriceDatabase>::prune(path)?;
Ok(())
}

Expand All @@ -80,10 +84,12 @@ impl CombinedDatabase {
let off_chain = Database::open_rocksdb(path, capacity, state_rewind_policy)?;
let relayer =
Database::open_rocksdb(path, capacity, StateRewindPolicy::NoRewind)?;
let gas_price = Database::open_rocksdb(path, capacity, state_rewind_policy)?;
Ok(Self {
on_chain,
off_chain,
relayer,
gas_price,
})
}

Expand Down Expand Up @@ -124,6 +130,7 @@ impl CombinedDatabase {
Database::in_memory(),
Database::in_memory(),
Database::in_memory(),
Database::in_memory(),
)
}

Expand Down Expand Up @@ -161,6 +168,15 @@ impl CombinedDatabase {
&mut self.relayer
}

pub fn gas_price(&self) -> &Database<GasPriceDatabase> {
&self.gas_price
}

#[cfg(any(feature = "test-helpers", test))]
pub fn gas_price_mut(&mut self) -> &mut Database<GasPriceDatabase> {
&mut self.gas_price
}

#[cfg(feature = "test-helpers")]
pub fn read_state_config(&self) -> StorageResult<StateConfig> {
use fuel_core_chain_config::AddTable;
Expand Down
8 changes: 6 additions & 2 deletions crates/fuel-core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ impl FuelService {
database: Database,
config: Config,
) -> anyhow::Result<Self> {
let combined_database =
CombinedDatabase::new(database, Default::default(), Default::default());
let combined_database = CombinedDatabase::new(
database,
Default::default(),
Default::default(),
Default::default(),
);
Self::from_combined_database(combined_database, config).await
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fuel_core_gas_price_service::{
SharedGasPriceAlgo,
};
use fuel_core_producer::block_producer::gas_price::GasPriceProvider as ProducerGasPriceProvider;
use fuel_core_txpool::ports::GasPriceProvider as TxPoolGasPricProvider;
use fuel_core_txpool::ports::GasPriceProvider as TxPoolGasPriceProvider;
use fuel_core_types::{
fuel_types::BlockHeight,
services::txpool::Result as TxPoolResult,
Expand Down Expand Up @@ -53,12 +53,8 @@ impl<A> FuelGasPriceProvider<A>
where
A: GasPriceAlgorithm + Send + Sync,
{
async fn next_gas_price(&self, block_bytes: u64) -> u64 {
self.algorithm.next_gas_price(block_bytes).await
}

async fn last_gas_price(&self) -> u64 {
self.algorithm.last_gas_price().await
async fn next_gas_price(&self) -> u64 {
self.algorithm.next_gas_price().await
}
}

Expand All @@ -67,18 +63,18 @@ impl<A> ProducerGasPriceProvider for FuelGasPriceProvider<A>
where
A: GasPriceAlgorithm + Send + Sync,
{
async fn next_gas_price(&self, block_bytes: u64) -> anyhow::Result<u64> {
Ok(self.next_gas_price(block_bytes).await)
async fn next_gas_price(&self) -> anyhow::Result<u64> {
Ok(self.next_gas_price().await)
}
}

#[async_trait::async_trait]
impl<A> TxPoolGasPricProvider for FuelGasPriceProvider<A>
impl<A> TxPoolGasPriceProvider for FuelGasPriceProvider<A>
where
A: GasPriceAlgorithm + Send + Sync,
{
async fn last_gas_price(&self) -> TxPoolResult<u64> {
Ok(self.last_gas_price().await)
async fn next_gas_price(&self) -> TxPoolResult<u64> {
Ok(self.next_gas_price().await)
}
}

Expand Down
Loading