Conversation
The explicit gas fields test was failing due to having too low a gas price. This was likely because the test was using the base fee from the last block as the base fee, and the tip was small enough that when converted to fee currency it was 0. To prevent this happening again the max fee cap is set to the last block baseFee * 10 and a constant tip of 1 is set. The overlapping nonce tx test was also failing due to replacement transactions being underpriced. I suspect this could be due to some loss of precision when during price bump adjustment and currency conversion. Modifying the price bump to be 1.11 instead of 1.1 seems to have solved this.
e2e_test/js-tests/test_viem_tx.mjs
Outdated
| maxFeePerGas: maxFeePerGas, | ||
| maxPriorityFeePerGas: tip, | ||
| maxFeePerGas: baseFeeForFeeCurrency*10n, | ||
| maxPriorityFeePerGas: 1n, |
There was a problem hiding this comment.
You're still getting a failure here in CI.
This is because the node has a min-tip of 1 configured - however since this is denominated in fee-currency
you also have to convert the min-tip into the fee-currency.
In this case this is 2 - the log message is misleading because the unconverted value is logged as the expected value. I pushed a fix for this to this branch.
There was a problem hiding this comment.
Thanks, so I need to set a tip here of 2 or more?
There was a problem hiding this comment.
Yes, I didn't look up the rate, but the next CI run will reveal this. I got 2 locally so I assume the rate is 1 : 2
There was a problem hiding this comment.
Ok instead I'll just convert to the fee currency, it's safer.
The tip needs to be convered to fee currency to meet the min tip requirements.
ezdac
left a comment
There was a problem hiding this comment.
I'm not sure if we should be more loose with the testing conditions for bumping just to make it work better on Alfajores. To me it seems like the precision loss is on the JS side, and the Alfajores specific failure is more influenced by Alfajores exchange rates being different than on the local devnet.
Also, we should update the test to be compatible with the new version of viem.
When I run this locally with the 2.22.21 version, I get a failure:
viem send tx
✔ send basic tx and check receipt (39ms)
✔ send basic tx using viem gas estimation and check receipt
✔ send fee currency tx with explicit gas fields and check receipt
1) test gas price difference for fee currency
✔ send fee currency with gas estimation tx and check receipt
✔ send overlapping nonce tx in different currencies (40ms)
✔ send tx with unregistered fee currency
✔ send fee currency tx with just high enough gas price
7 passing (133ms)
1 failing
1) viem send tx
test gas price difference for fee currency:
AssertionError: expected 1174566684n to equal 1409480020n
+ expected - actual
-1174566684n
+1409480020n
at Context.<anonymous> (file:///Users/maximilian/code/op-geth-develop/e2e_test/js-tests/test_viem_tx.mjs:171:12)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The reason for this is explained in the test-comment, since the new version of viem includes the required fix:
// TODO fix this when viem is fixed - https://github.com/celo-org/viem/pull/20 // The expected value for the max fee should be the (baseFeePerGas * multiplier) + maxPriorityFeePerGas // Instead what is currently returned is (maxFeePerGas * multiplier) + maxPriorityFeePerGas
| // Returns the base fee per gas for the current block multiplied by 2 to account for any increase in the subsequent block. | ||
| async function getGasFees(publicClient, tip, feeCurrency) { | ||
| // Returns the base fee per gas for the current block in the given fee currency. | ||
| async function getGasFees(publicClient, feeCurrency, tip) { |
There was a problem hiding this comment.
The changes in the function are not really necessary anymore :)
| it("send overlapping nonce tx in different currencies", async () => { | ||
| // Note the threshold for a price bump to be accepted is 10%, i.e >= oldPrice * 1.1 | ||
| const priceBump = 1.1; // minimum bump percentage to replace a transaction | ||
| const priceBump = 1.11; // minimum bump percentage to replace a transaction |
There was a problem hiding this comment.
It's also likely that the precision loss comes from the test's rate.toFeeCurrency code not using BigInt exclusively as well as the prior usage of 64bit floating point double multiplication for the bumping.
I'd rather try to make the tests calculation more accurate before tweaking the values.
When converting the tip to fee currency the result can be zero, sending a transaction with a zero tip even if that is the result of converting the required 1 wei to a fee currency results in a transaction that is not processed.
The e2e tests were consistently failing during their cron CI workflow to run them against Alfajores.
The explicit gas fields test was failing due to having too low a gas price. This was likely because the test was using the base fee from the last block as the base fee, and the tip was small enough that when converted to fee currency it was 0. To prevent this happening again the max fee cap is set to the last block baseFee * 10 and a constant tip of 1 is set.
The overlapping nonce tx test was also failing due to replacement transactions being underpriced. I suspect this could be due to some loss of precision when during price bump adjustment and currency conversion. Modifying the price bump to be 1.11 instead of 1.1 seems to have solved this.