Skip to content

Commit

Permalink
Always check for call success in ScillaConnector (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHinshelwood authored Dec 12, 2024
1 parent c8bdc59 commit dacfd39
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ library ScillaConnector {
);
uint256 argsLength = encodedArgs.length;

bool success;
assembly {
let alwaysSuccessForThisPrecompile := call(
success := call(
gas(),
SCILLA_CALL_PRECOMPILE_ADDRESS,
0,
Expand All @@ -36,6 +37,7 @@ library ScillaConnector {
0
)
}
require(success);
}


Expand All @@ -61,8 +63,9 @@ library ScillaConnector {
);
uint256 argsLength = encodedArgs.length;

bool success;
assembly {
let alwaysSuccessForThisPrecompile := call(
success := call(
gas(),
SCILLA_CALL_PRECOMPILE_ADDRESS,
0,
Expand All @@ -72,6 +75,7 @@ library ScillaConnector {
0
)
}
require(success);
}

/**
Expand Down Expand Up @@ -99,8 +103,9 @@ library ScillaConnector {
);
uint256 argsLength = encodedArgs.length;

bool success;
assembly {
let alwaysSuccessForThisPrecompile := call(
success := call(
gas(),
SCILLA_CALL_PRECOMPILE_ADDRESS,
0,
Expand All @@ -110,6 +115,7 @@ library ScillaConnector {
0
)
}
require(success);
}

/**
Expand All @@ -126,8 +132,9 @@ library ScillaConnector {
uint256 argsLength = encodedArgs.length;
bytes memory output = new bytes(36);

bool success;
assembly {
let alwaysSuccessForThisPrecompile := staticcall(
success := staticcall(
gas(),
SCILLA_STATE_READ_PRECOMPILE_ADDRESS,
add(encodedArgs, 0x20),
Expand All @@ -136,6 +143,7 @@ library ScillaConnector {
32
)
}
require(success);

return abi.decode(output, (uint128));
}
Expand All @@ -154,8 +162,9 @@ library ScillaConnector {
uint256 argsLength = encodedArgs.length;
bytes memory output = new bytes(36);

bool success;
assembly {
let alwaysSuccessForThisPrecompile := staticcall(
success := staticcall(
gas(),
SCILLA_STATE_READ_PRECOMPILE_ADDRESS,
add(encodedArgs, 0x20),
Expand All @@ -164,6 +173,7 @@ library ScillaConnector {
32
)
}
require(success);

return abi.decode(output, (uint32));
}
Expand All @@ -183,6 +193,8 @@ library ScillaConnector {
bool success;
bytes memory output = new bytes(128);
uint256 output_len = output.length - 4;

bool success;
assembly {
success := staticcall(
gas(),
Expand Down Expand Up @@ -218,8 +230,9 @@ library ScillaConnector {
uint256 argsLength = encodedArgs.length;
bytes memory output = new bytes(36);

bool success;
assembly {
let alwaysSuccessForThisPrecompile := staticcall(
success := staticcall(
gas(),
SCILLA_STATE_READ_PRECOMPILE_ADDRESS,
add(encodedArgs, 0x20),
Expand All @@ -228,6 +241,7 @@ library ScillaConnector {
32
)
}
require(success);

return abi.decode(output, (uint128));
}
Expand Down Expand Up @@ -255,8 +269,9 @@ library ScillaConnector {
uint256 argsLength = encodedArgs.length;
bytes memory output = new bytes(36);

bool success;
assembly {
let alwaysSuccessForThisPrecompile := staticcall(
success := staticcall(
gas(),
SCILLA_STATE_READ_PRECOMPILE_ADDRESS,
add(encodedArgs, 0x20),
Expand All @@ -265,6 +280,7 @@ library ScillaConnector {
32
)
}
require(success);

return abi.decode(output, (uint128));
}
Expand Down

0 comments on commit dacfd39

Please sign in to comment.