Skip to content

Commit a2b84c0

Browse files
feat(orc-458): set-limits tw command added
1 parent 4ee7697 commit a2b84c0

File tree

2 files changed

+86
-4
lines changed

2 files changed

+86
-4
lines changed

programs/exit-bus-oracle.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,58 @@ oracle
536536
logger.error('Failed to trigger validator exits:', error);
537537
}
538538
});
539+
540+
oracle
541+
.command('set-limits')
542+
.description('Set exit request limits on VEB contract')
543+
.option('--max-exit-requests-limit <limit>', 'Maximum exit requests limit')
544+
.option('--exits-per-frame <exits>', 'Number of exits per frame')
545+
.option('--frame-duration <duration>', 'Frame duration in seconds')
546+
.action(async (options) => {
547+
const { maxExitRequestsLimit, exitsPerFrame, frameDuration } = options;
548+
549+
if (!maxExitRequestsLimit || !exitsPerFrame || !frameDuration) {
550+
logger.error('All parameters are required: --max-exit-requests-limit, --exits-per-frame, --frame-duration');
551+
logger.log('Example usage:');
552+
logger.log(' ./run.sh vebo set-limits --max-exit-requests-limit 11200 --exits-per-frame 1 --frame-duration 48');
553+
return;
554+
}
555+
556+
try {
557+
const maxLimit = parseInt(maxExitRequestsLimit, 10);
558+
const exitsCount = parseInt(exitsPerFrame, 10);
559+
const durationSec = parseInt(frameDuration, 10);
560+
561+
if (isNaN(maxLimit) || isNaN(exitsCount) || isNaN(durationSec)) {
562+
logger.error('All parameters must be valid numbers');
563+
return;
564+
}
565+
566+
if (maxLimit <= 0 || exitsCount <= 0 || durationSec <= 0) {
567+
logger.error('All parameters must be positive numbers');
568+
return;
569+
}
570+
571+
logger.log('Setting exit request limits on VEB contract...');
572+
logger.log('Parameters:');
573+
logger.log(` Max Exit Requests Limit: ${maxLimit}`);
574+
logger.log(` Exits Per Frame: ${exitsCount}`);
575+
logger.log(` Frame Duration: ${durationSec} seconds`);
576+
logger.log('Contract address:', exitBusOracleContract.target);
577+
578+
const tx = await exitBusOracleContract.setExitRequestLimit(maxLimit, exitsCount, durationSec);
579+
logger.log('Transaction hash:', tx.hash);
580+
581+
logger.log('Waiting for transaction confirmation...');
582+
const receipt = await tx.wait();
583+
584+
if (receipt.status === 1) {
585+
logger.log('Exit request limits set successfully!');
586+
logger.log('Transaction confirmed in block:', receipt.blockNumber);
587+
} else {
588+
logger.error('Transaction failed');
589+
}
590+
} catch (error) {
591+
logger.error('Failed to set exit request limits:', error);
592+
}
593+
});

tests/test-tw-commands.sh

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ setup_test_permissions() {
139139
local TEST_ACCOUNT="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
140140
local ADMIN_ACCOUNT="0x0534aA41907c9631fae990960bCC72d75fA7cfeD"
141141
local SUBMITTER_ROLE="0x22ebb4dbafb72948800c1e1afa1688772a1a4cfc54d5ebfcec8163b1139c082e"
142+
local EXIT_REQUEST_LIMIT_MANAGER_ROLE="0x9c616dd118785b2e2fccf45a4ff151a335ff7b6a84cd1c4d7fd9f97f39ea9342"
142143

143144
print_status "Impersonating Aragon Agent and granting role..."
144145

@@ -147,19 +148,32 @@ setup_test_permissions() {
147148
-d "{\"jsonrpc\":\"2.0\",\"method\":\"anvil_impersonateAccount\",\"params\":[\"$ADMIN_ACCOUNT\"],\"id\":1}" \
148149
http://localhost:$ANVIL_PORT >/dev/null
149150

150-
# Give it ETH
151+
# Give ETH to admin account (100 ETH)
151152
curl -s -X POST -H "Content-Type: application/json" \
152-
-d "{\"jsonrpc\":\"2.0\",\"method\":\"anvil_setBalance\",\"params\":[\"$ADMIN_ACCOUNT\",\"0x21E19E0C9BAB2400000\"],\"id\":1}" \
153+
-d "{\"jsonrpc\":\"2.0\",\"method\":\"anvil_setBalance\",\"params\":[\"$ADMIN_ACCOUNT\",\"0x56BC75E2D630E0000\"],\"id\":1}" \
153154
http://localhost:$ANVIL_PORT >/dev/null
154155

155-
# Grant role using cast
156+
# Give ETH to test account (1000 ETH to ensure enough for all tests)
157+
curl -s -X POST -H "Content-Type: application/json" \
158+
-d "{\"jsonrpc\":\"2.0\",\"method\":\"anvil_setBalance\",\"params\":[\"$TEST_ACCOUNT\",\"0x3635C9ADC5DEA00000\"],\"id\":1}" \
159+
http://localhost:$ANVIL_PORT >/dev/null
160+
161+
# Grant submitter role using cast
156162
print_status "Granting submitter role to test account..."
157163
ETH_FROM=$ADMIN_ACCOUNT cast send $VEBO_CONTRACT "grantRole(bytes32,address)" \
158164
$SUBMITTER_ROLE $TEST_ACCOUNT \
159165
--rpc-url http://localhost:$ANVIL_PORT \
160166
--unlocked \
161167
--gas-limit 200000 >/dev/null 2>&1
162168

169+
# Grant limit manager role using cast
170+
print_status "Granting exit request limit manager role to test account..."
171+
ETH_FROM=$ADMIN_ACCOUNT cast send $VEBO_CONTRACT "grantRole(bytes32,address)" \
172+
$EXIT_REQUEST_LIMIT_MANAGER_ROLE $TEST_ACCOUNT \
173+
--rpc-url http://localhost:$ANVIL_PORT \
174+
--unlocked \
175+
--gas-limit 200000 >/dev/null 2>&1
176+
163177
print_success "Test permissions setup completed"
164178
sleep 1
165179
}
@@ -195,7 +209,7 @@ run_test_command() {
195209
local has_errors=false
196210
if [ $exit_code -ne 0 ]; then
197211
has_errors=true
198-
elif grep -q "RPC request failed\|execution reverted\|Transaction failed\|Failed to submit\|Error:" "$temp_output"; then
212+
elif grep -q "RPC request failed\|execution reverted\|Transaction failed\|Failed to submit\|Error:\|Insufficient funds\|insufficient funds" "$temp_output"; then
199213
has_errors=true
200214
fi
201215

@@ -238,6 +252,19 @@ run_tests() {
238252
run_test_command "Trigger exit with submitted data" \
239253
"../run.sh vebo trigger-exit --calldata 0x000001000000000f00000000000030391234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef --format 1 --value 0.001"
240254

255+
# Test 4: Test set-limits command with valid parameters
256+
print_status "Testing set-limits with valid parameters..."
257+
print_status "Note: This test sets new exit request limits on the VEB contract"
258+
259+
# Ensure test account has enough ETH for this expensive transaction
260+
print_status "Ensuring sufficient ETH balance for set-limits test..."
261+
curl -s -X POST -H "Content-Type: application/json" \
262+
-d "{\"jsonrpc\":\"2.0\",\"method\":\"anvil_setBalance\",\"params\":[\"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\",\"0x3635C9ADC5DEA00000\"],\"id\":1}" \
263+
http://localhost:$ANVIL_PORT >/dev/null
264+
265+
run_test_command "Set exit request limits" \
266+
"../run.sh vebo set-limits --max-exit-requests-limit 11200 --exits-per-frame 1 --frame-duration 48"
267+
241268
print_status "Test suite completed"
242269
}
243270

0 commit comments

Comments
 (0)