-
Notifications
You must be signed in to change notification settings - Fork 391
Fix: Batcher User Balance Checks #1404
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
Conversation
|
Code looks good, may need some extra testing |
batcher/aligned-batcher/src/lib.rs
Outdated
| let mut min_fee = user_min_fee; | ||
| if user_min_fee == U256::max_value() { | ||
| min_fee = user_max_fee | ||
| } | ||
| let min_balance: U256 = U256::from(user_proofs_in_batch) * min_fee; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am wrong here but why don't we move the min_balance check after the msg_max_fee check? This way, in the min_balance check we'll verify against the msg_max_fee directly (as it will become the new min_fee if everything goes ok), we'll save ourselves this if:
if user_min_fee == U256::max_value() {
min_fee = user_max_fee
}It is hard to understand that U256::max_value() is the default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts are to leave this check in as it handles an explicit case that a user's proof has been submitted for the first time not the replacement max_fee invariant. I we move this check behind the msg_max_fee check we still need to have logic to check and specify that if a proof is submitted for the first time we use it's submitted max_fee instead of the user_max_fee. I think it's worth considering verifying that these checks are not redundant, but lets address that in another issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on macos, everything went fine.
cee3b0c to
e242905
Compare
uri-99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the removed var, MIN_FEE_PER_PROOF, is no longer used in the codebase.
We should remove it from the constants file as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Its working now but I can't approve it because i made this pr |
MarcosNicolau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on macos, everything worked fine. Code looks good, I leave some comments that you can address if you want.
|
1 sec testing something |

Fix: Batcher User Balance Checker
Description
Replaces the hardcoded constant in https://github.com/yetanotherco/aligned_layer/blob/testnet/batcher/aligned-batcher/src/lib.rs#L607 with the user's
min_fee. Addresses the first point of #1383 .This fix is done by adding
total_fees_in_queuevariable in the UserState struct, and comparing if user has enough balance to pay for the needed amount.This PR also refactors the infamous
min_feevariable, to be calledmax_fee_limit/last_max_fee_limitThis PR also adds some metrics of this. dont forget to visualize them in the following tests running
To Test:
test 1
1.) Start a local testnet with an no balance:
2.) Create a wallet with no funds
3.)
ensure the proof submission errors within the batcher with
InsufficientBalance.test 2
1.) Fund the wallet by sending eth from a prefunded anvil account:
cast send <WALLET_ADDRESS --rpc-url http://localhost:8545 --private-key 2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 --value 1ether2.) Fund the batcher with an insufficient balance for multiple proofs.
3.) Send one proof, see it succeeds.
cargo run --release -- submit \ --proving_system SP1 \ --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \ --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \ --repetitions 1 \ --proof_generator_addr <WALLET_ADDRESS \ --keystore_path <KEYSTORE_PATH> \ --rpc_url http://localhost:8545 \ --network devnet4.) Send a burst of 10 or more proofs, observe it submission fails due to insufficient balance.
cargo run --release -- submit \ --proving_system SP1 \ --proof ../../scripts/test_files/sp1/sp1_fibonacci.proof \ --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \ --repetitions 10 \ --proof_generator_addr <WALLET_ADDRESS \ --keystore_path <KEYSTORE_PATH> \ --rpc_url http://localhost:8545 \ --network devnetType of change
Please delete options that are not relevant.
Checklist