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

hot fix v20.0.2, increased preflight instruction fee padding to 3 million #1127

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
7 changes: 3 additions & 4 deletions cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,17 @@ func TestSimulateTransactionSucceeds(t *testing.T) {
ReadBytes: 0,
WriteBytes: 7048,
},
ResourceFee: 113910,
}

// First, decode and compare the transaction data so we get a decent diff if it fails.
var transactionData xdr.SorobanTransactionData
err := xdr.SafeUnmarshalBase64(result.TransactionData, &transactionData)
assert.NoError(t, err)
assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint)
assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 200000)
assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 3200000)
assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10)
assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 300)
assert.InDelta(t, int64(expectedTransactionData.ResourceFee), int64(transactionData.ResourceFee), 3000)
assert.Greater(t, int64(transactionData.ResourceFee), int64(0))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tamir, how did you obtain the fee 113910 for this example? after the increase on instr budget to 3M in this pr, the resulting fee here is outside this delta, is the resulting fee deterministic based on other factors, I took a defensive approach on test stability and just assert on minimal aspect of the fee must be > 0, same on line 1124.


// Then decode and check the result xdr, separately so we get a decent diff if it fails.
assert.Len(t, result.Results, 1)
Expand Down Expand Up @@ -1122,7 +1121,7 @@ func TestSimulateSystemEvent(t *testing.T) {
require.NoError(t, err)

assert.InDelta(t, 7464, uint32(transactionData.Resources.ReadBytes), 200)
assert.InDelta(t, 80980, int64(transactionData.ResourceFee), 5000)
assert.Greater(t, int64(transactionData.ResourceFee), int64(0))
assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15)
require.GreaterOrEqual(t, len(response.Events), 3)
}
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/lib/preflight/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ fn calculate_host_function_soroban_resources(
.map(|c| c.encoded_new_value.as_ref().map_or(0, Vec::len) as u32)
.sum();

// Add a 20% leeway with a minimum of 1 million instructions
// Add a 20% leeway with a minimum of 3 million instructions
let budget_instructions = budget
.get_cpu_insns_consumed()
.context("cannot get instructions consumed")?;
let instructions = max(
budget_instructions + 1000000,
budget_instructions + 3000000,
budget_instructions * 120 / 100,
);
Ok(SorobanResources {
Expand Down
Loading