Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into keep_e2e_current
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Sep 13, 2023
2 parents fd1a0b7 + d3664b5 commit 8e54c38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
22 changes: 9 additions & 13 deletions cmd/soroban-rpc/internal/network/requestdurationlimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,20 @@ func (w *bufferedResponseWriter) WriteOut(ctx context.Context, rw http.ResponseW
for k, v := range w.header {
headers[k] = v
}
complete := make(chan interface{})
go func() {
if len(w.buffer) == 0 {
if w.statusCode != 0 {
rw.WriteHeader(w.statusCode)
}
return
}

if len(w.buffer) == 0 {
if w.statusCode != 0 {
rw.WriteHeader(w.statusCode)
}
return
}
if w.statusCode != 0 {
rw.WriteHeader(w.statusCode)
}

if ctx.Err() == nil {
// the following return size/error won't help us much at this point. The request is already finalized.
rw.Write(w.buffer) //nolint:errcheck
close(complete)
}()
select {
case <-complete:
case <-ctx.Done():
}
}

Expand Down
12 changes: 4 additions & 8 deletions cmd/soroban-rpc/lib/preflight/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee(
calculate_host_function_soroban_resources(&ledger_changes, &post_storage.footprint, budget)
.context("cannot compute host function resources")?;

let read_write_entries = u32::try_from(soroban_resources.footprint.read_write.as_vec().len())?;

let contract_events_size =
calculate_contract_events_size_bytes(events).context("cannot calculate events size")?;
let invocation_return_size = u32::try_from(invocation_result.to_xdr()?.len())?;
Expand All @@ -53,9 +51,8 @@ pub(crate) fn compute_host_function_transaction_data_and_min_fee(

let transaction_resources = TransactionResources {
instructions: soroban_resources.instructions,
read_entries: u32::try_from(soroban_resources.footprint.read_only.as_vec().len())?
+ read_write_entries,
write_entries: read_write_entries,
read_entries: u32::try_from(soroban_resources.footprint.read_only.as_vec().len())?,
write_entries: u32::try_from(soroban_resources.footprint.read_write.as_vec().len())?,
read_bytes: soroban_resources.read_bytes,
write_bytes: soroban_resources.write_bytes,
// Note: we could get a better transaction size if the full transaction was passed down to libpreflight
Expand Down Expand Up @@ -440,7 +437,6 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee(
read_bytes: write_bytes + expiration_bytes,
write_bytes,
};
let entry_count = u32::try_from(soroban_resources.footprint.read_write.as_vec().len())?;
let transaction_size_bytes = estimate_max_transaction_size_for_operation(
&OperationBody::RestoreFootprint(RestoreFootprintOp {
ext: ExtensionPoint::V0,
Expand All @@ -450,8 +446,8 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee(
.context("cannot estimate maximum transaction size")?;
let transaction_resources = TransactionResources {
instructions: 0,
read_entries: entry_count,
write_entries: entry_count,
read_entries: 0,
write_entries: u32::try_from(soroban_resources.footprint.read_write.as_vec().len())?,
read_bytes: soroban_resources.read_bytes,
write_bytes: soroban_resources.write_bytes,
transaction_size_bytes,
Expand Down

0 comments on commit 8e54c38

Please sign in to comment.