Skip to content
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

feat(eth-sender): gateway support for eth tx manager #2593

Merged
merged 53 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a2c3a89
wip
StanislavBreadless Jul 30, 2024
830a952
some additional changes
StanislavBreadless Jul 31, 2024
2894721
a few small changes
StanislavBreadless Jul 31, 2024
338eade
fix lint
StanislavBreadless Jul 31, 2024
d1d3beb
remove inconsistency
StanislavBreadless Jul 31, 2024
e9e8b9e
upd pr
StanislavBreadless Jul 31, 2024
d827bbc
hopefully fix lint
StanislavBreadless Jul 31, 2024
fa77803
Merge branch 'main' into sb-rename-sl-chain-id
StanislavBreadless Jul 31, 2024
709b06d
return none on tests
StanislavBreadless Jul 31, 2024
2cfffc6
hopefully fix lint
StanislavBreadless Jul 31, 2024
ba395ec
Merge remote-tracking branch 'origin/sb-rename-sl-chain-id' into sb-r…
StanislavBreadless Jul 31, 2024
8a9d0b4
sync with main
StanislavBreadless Aug 1, 2024
f3d13a2
apply diff for a new gas adjuster
StanislavBreadless Aug 1, 2024
2e2e368
compiles
StanislavBreadless Aug 1, 2024
2961346
use the same zk as in main
StanislavBreadless Aug 1, 2024
b63b26c
prettify code
StanislavBreadless Aug 1, 2024
982b2a0
a bit more polishing
StanislavBreadless Aug 1, 2024
86628e3
resolve more issues
StanislavBreadless Aug 1, 2024
5502eca
hopefully resolve compilation this time
StanislavBreadless Aug 1, 2024
d050125
sync with main
StanislavBreadless Aug 1, 2024
a85eac2
cargo fix
StanislavBreadless Aug 2, 2024
5e22a87
fix lint
StanislavBreadless Aug 2, 2024
6fd3ad4
first round of change
StanislavBreadless Aug 2, 2024
26a2eee
more changes
StanislavBreadless Aug 2, 2024
8ffaf5f
nit
StanislavBreadless Aug 2, 2024
c4091e9
return back old naming for smaller diff
StanislavBreadless Aug 2, 2024
31ad4cc
Merge branch 'main' into sb-track-l2-fees-for-gateway
StanislavBreadless Aug 2, 2024
91b38a3
impl review
StanislavBreadless Aug 5, 2024
31edada
remove most of copypaste
StanislavBreadless Aug 5, 2024
19054b0
almost finalize
StanislavBreadless Aug 5, 2024
1fac151
some final fixes
StanislavBreadless Aug 5, 2024
789f271
some more fixing
StanislavBreadless Aug 5, 2024
1a9b42e
remove more unneeded things
StanislavBreadless Aug 5, 2024
690a0ae
same contracts as main
StanislavBreadless Aug 5, 2024
9a0ecce
Merge branch 'main' into sb-track-l2-fees-for-gateway
StanislavBreadless Aug 5, 2024
09031d9
first version
tomg10 Aug 5, 2024
91d93d0
fix compilation issue
tomg10 Aug 5, 2024
0d9f8cf
fix compilation issue, PR feedback
tomg10 Aug 5, 2024
7ac6f9b
missing sqlx file
tomg10 Aug 5, 2024
97e14eb
missing bound l2 resource
tomg10 Aug 5, 2024
5aa7d07
missing bound l2 resource
tomg10 Aug 5, 2024
b9c5fbf
merge
tomg10 Aug 12, 2024
7d4dd57
merge fix
tomg10 Aug 12, 2024
072e495
merge fix
tomg10 Aug 12, 2024
3c1019b
fix
tomg10 Aug 12, 2024
5ca14a8
fix
tomg10 Aug 12, 2024
c7849fa
fix
tomg10 Aug 12, 2024
78f32f6
lint fixes
tomg10 Aug 12, 2024
4fd3c08
fmt
tomg10 Aug 12, 2024
50f26be
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 12, 2024
be87c01
fix
tomg10 Aug 13, 2024
5088b51
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 19, 2024
dc38a46
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 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
2 changes: 1 addition & 1 deletion core/lib/config/src/configs/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl EthConfig {
Self {
sender: Some(SenderConfig {
aggregated_proof_sizes: vec![1],
wait_confirmations: Some(1),
wait_confirmations: Some(10),
tx_poll_period: 1,
aggregate_tx_poll_period: 1,
max_txs_in_flight: 30,
Expand Down

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

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

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

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE eth_txs DROP COLUMN is_gateway;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE eth_txs ADD COLUMN is_gateway BOOLEAN NOT NULL DEFAULT FALSE;
11 changes: 10 additions & 1 deletion core/lib/dal/src/blocks_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,16 @@ mod tests {

async fn save_mock_eth_tx(action_type: AggregatedActionType, conn: &mut Connection<'_, Core>) {
conn.eth_sender_dal()
.save_eth_tx(1, vec![], action_type, Address::default(), 1, None, None)
.save_eth_tx(
1,
vec![],
action_type,
Address::default(),
1,
None,
None,
false,
)
.await
.unwrap();
}
Expand Down
1 change: 1 addition & 0 deletions core/lib/dal/src/blocks_web3_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ mod tests {
0,
None,
None,
false,
)
.await
.unwrap();
Expand Down
36 changes: 34 additions & 2 deletions core/lib/dal/src/eth_sender_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl EthSenderDal<'_, '_> {
pub async fn get_inflight_txs(
&mut self,
operator_address: Option<Address>,
is_gateway: bool,
) -> sqlx::Result<Vec<EthTx>> {
let txs = sqlx::query_as!(
StorageEthTx,
Expand All @@ -36,6 +37,7 @@ impl EthSenderDal<'_, '_> {
WHERE
from_addr IS NOT DISTINCT FROM $1 -- can't just use equality as NULL != NULL
AND confirmed_eth_tx_history_id IS NULL
AND is_gateway = $2
AND id <= (
SELECT
COALESCE(MAX(eth_tx_id), 0)
Expand All @@ -45,17 +47,40 @@ impl EthSenderDal<'_, '_> {
WHERE
eth_txs_history.sent_at_block IS NOT NULL
AND eth_txs.from_addr IS NOT DISTINCT FROM $1
AND is_gateway = $2
)
ORDER BY
id
"#,
operator_address.as_ref().map(|h160| h160.as_bytes()),
is_gateway
)
.fetch_all(self.storage.conn())
.await?;
Ok(txs.into_iter().map(|tx| tx.into()).collect())
}

pub async fn get_non_gateway_inflight_txs_count_for_gateway_migration(
&mut self,
) -> sqlx::Result<usize> {
let count = sqlx::query!(
r#"
SELECT
COUNT(*)
FROM
eth_txs
WHERE
confirmed_eth_tx_history_id IS NULL
AND is_gateway = FALSE
"#
)
.fetch_one(self.storage.conn())
.await?
.count
.unwrap();
Ok(count.try_into().unwrap())
}

pub async fn get_eth_l1_batches(&mut self) -> sqlx::Result<L1BatchEthSenderStats> {
struct EthTxRow {
number: i64,
Expand Down Expand Up @@ -132,6 +157,7 @@ impl EthSenderDal<'_, '_> {
&mut self,
limit: u64,
operator_address: &Option<Address>,
is_gateway: bool,
) -> sqlx::Result<Vec<EthTx>> {
let txs = sqlx::query_as!(
StorageEthTx,
Expand All @@ -142,6 +168,7 @@ impl EthSenderDal<'_, '_> {
eth_txs
WHERE
from_addr IS NOT DISTINCT FROM $2 -- can't just use equality as NULL != NULL
AND is_gateway = $3
AND id > (
SELECT
COALESCE(MAX(eth_tx_id), 0)
Expand All @@ -151,6 +178,7 @@ impl EthSenderDal<'_, '_> {
WHERE
eth_txs_history.sent_at_block IS NOT NULL
AND eth_txs.from_addr IS NOT DISTINCT FROM $2
AND is_gateway = $3
)
ORDER BY
id
Expand All @@ -159,6 +187,7 @@ impl EthSenderDal<'_, '_> {
"#,
limit as i64,
operator_address.as_ref().map(|h160| h160.as_bytes()),
is_gateway
)
.fetch_all(self.storage.conn())
.await?;
Expand Down Expand Up @@ -202,6 +231,7 @@ impl EthSenderDal<'_, '_> {
predicted_gas_cost: u32,
from_address: Option<Address>,
blob_sidecar: Option<EthTxBlobSidecar>,
is_gateway: bool,
) -> sqlx::Result<EthTx> {
let address = format!("{:#x}", contract_address);
let eth_tx = sqlx::query_as!(
Expand All @@ -217,10 +247,11 @@ impl EthSenderDal<'_, '_> {
created_at,
updated_at,
from_addr,
blob_sidecar
blob_sidecar,
is_gateway
)
VALUES
($1, $2, $3, $4, $5, NOW(), NOW(), $6, $7)
($1, $2, $3, $4, $5, NOW(), NOW(), $6, $7, $8)
RETURNING
*
"#,
Expand All @@ -232,6 +263,7 @@ impl EthSenderDal<'_, '_> {
from_address.as_ref().map(Address::as_bytes),
blob_sidecar.map(|sidecar| bincode::serialize(&sidecar)
.expect("can always bincode serialize EthTxBlobSidecar; qed")),
is_gateway,
)
.fetch_one(self.storage.conn())
.await?;
Expand Down
2 changes: 2 additions & 0 deletions core/lib/dal/src/models/storage_eth_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct StorageEthTx {
//
// Format a `bincode`-encoded `EthTxBlobSidecar` enum.
pub blob_sidecar: Option<Vec<u8>>,
pub is_gateway: bool,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -83,6 +84,7 @@ impl From<StorageEthTx> for EthTx {
blob_sidecar: tx.blob_sidecar.map(|b| {
bincode::deserialize(&b).expect("EthTxBlobSidecar is encoded correctly; qed")
}),
is_gateway: tx.is_gateway,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/eth_client/src/clients/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl MockSettlementLayerInner {
self.block_number += confirmations;
let nonce = self.current_nonce;
self.current_nonce += 1;
tracing::info!("Executing tx with hash {tx_hash:?}, success: {success}, current nonce: {}, confirmations: {confirmations}", self.current_nonce);
tracing::info!("Executing tx with hash {tx_hash:?} at block {}, success: {success}, current nonce: {}, confirmations: {confirmations}", self.block_number - confirmations, self.current_nonce);
let tx_nonce = self.sent_txs[&tx_hash].nonce;

if non_ordering_confirmations {
Expand Down
1 change: 1 addition & 0 deletions core/lib/types/src/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct EthTx {
/// this transaction. If it is set to `None` this transaction was sent by the main operator.
pub from_addr: Option<Address>,
pub blob_sidecar: Option<EthTxBlobSidecar>,
pub is_gateway: bool,
}

impl std::fmt::Debug for EthTx {
Expand Down
Loading
Loading