Skip to content

Commit

Permalink
resolve all build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Jul 18, 2024
1 parent 17db5e0 commit e4b54df
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract SuaveEnabled is Test {
inputs[0] = "suave-geth";
inputs[1] = "version";

try vm.ffi(inputs) returns (bytes memory response) {
try vm.ffi(inputs) returns (bytes memory) {
// TODO: validate versions
} catch (bytes memory reason) {
revert(detectErrorMessage(reason));
Expand Down
6 changes: 4 additions & 2 deletions src/protocols/Builder/Session.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ contract Session is Test {
callImpl("buildBlock", input);
}

function bid(string memory blsPubKey) public returns (JSONParserLib.Item memory) {
function bid(string memory blsPubKey) public returns (JSONParserLib.Item memory output) {
bytes memory input = abi.encodePacked(session, ',"0x', blsPubKey, '"');
JSONParserLib.Item memory output = callImpl("bid", input);
output = callImpl("bid", input);

console.log("-- bid output --");
console.log(output.value());

// retrieve the root to sign
bytes memory root = HexStrings.fromHexString(HexStrings.stripQuotesAndPrefix(output.at('"root"').value()));
// TODO: do something with this root
root; // suppress warning
}

function doCall(address target, bytes memory data) public returns (bytes memory) {
Expand Down
10 changes: 6 additions & 4 deletions src/protocols/Builder/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ library Types {
}

// encodeBuildBlockArgs encodes BuildBlockArgs to json
function encodeBuildBlockArgs(BuildBlockArgs memory args) internal returns (bytes memory) {
function encodeBuildBlockArgs(BuildBlockArgs memory args) internal pure returns (bytes memory) {
bytes memory body = abi.encodePacked(
'{"slot":"',
LibString.toMinimalHexString(args.slot),
Expand Down Expand Up @@ -88,7 +88,7 @@ library Types {
}

// encodeWithdrawals encodes Withdrawal array to json
function encodeWithdrawals(Withdrawal[] memory withdrawals) internal returns (bytes memory) {
function encodeWithdrawals(Withdrawal[] memory withdrawals) internal pure returns (bytes memory) {
bytes memory result = abi.encodePacked("[");
for (uint64 i = 0; i < withdrawals.length; i++) {
result = abi.encodePacked(result, i > 0 ? "," : "", encodeWithdrawal(withdrawals[i]));
Expand All @@ -97,7 +97,7 @@ library Types {
}

// encodeWithdrawal encodes Withdrawal to json
function encodeWithdrawal(Withdrawal memory withdrawal) internal returns (bytes memory) {
function encodeWithdrawal(Withdrawal memory withdrawal) internal pure returns (bytes memory) {
return abi.encodePacked(
'{"index":',
LibString.toHexString(withdrawal.index),
Expand All @@ -114,13 +114,14 @@ library Types {

function decodeSimulateTransactionResult(string memory input)
internal
pure
returns (SimulateTransactionResult memory result)
{
JSONParserLib.Item memory item = input.parse();
return decodeSimulateTransactionResult(item);
}

function decodeSimulatedLog(JSONParserLib.Item memory item) internal returns (SimulatedLog memory log) {
function decodeSimulatedLog(JSONParserLib.Item memory item) internal pure returns (SimulatedLog memory log) {
log.data = fromHexString(_stripQuotesAndPrefix(item.at('"data"').value()));
log.addr = bytesToAddress(fromHexString(_stripQuotesAndPrefix(item.at('"addr"').value())));

Expand All @@ -133,6 +134,7 @@ library Types {

function decodeSimulateTransactionResult(JSONParserLib.Item memory item)
internal
pure
returns (SimulateTransactionResult memory result)
{
if (compareStrings(item.at('"success"').value(), "true")) {
Expand Down
1 change: 1 addition & 0 deletions test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contract TestGateway is Test, SuaveEnabled {
} catch {
vm.skip(true);
}
revert("this code path should never be reached in normal circumstances");
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/Transactions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./Fixtures.sol";
contract TestTransactions is Test, SuaveEnabled {
using Transactions for *;

function testEIP155TransactionRLPEncoding() public {
function testEIP155TransactionRLPEncoding() public view {
Transactions.EIP155 memory txnWithToAddress = Transactions.EIP155({
to: address(0x095E7BAea6a6c7c4c2DfeB977eFac326aF552d87),
gas: 50000,
Expand Down Expand Up @@ -53,7 +53,7 @@ contract TestTransactions is Test, SuaveEnabled {
Fixtures.validate("txn_155_contract_creation.json", string(txnJSON));
}

function testEIP1559TransactionRLPEncoding() public {
function testEIP1559TransactionRLPEncoding() public pure {
Transactions.EIP1559 memory txnWithToAddress = Transactions.EIP1559({
to: address(0xaea46A60368A7bD060eec7DF8CBa43b7EF41Ad85),
gas: 64744,
Expand Down Expand Up @@ -101,7 +101,7 @@ contract TestTransactions is Test, SuaveEnabled {
_testEIP1559Transaction(txnWithoutToAddress, expected);
}

function _testEIP155Transaction(Transactions.EIP155 memory legacyTxn, bytes memory expectedRlp) public {
function _testEIP155Transaction(Transactions.EIP155 memory legacyTxn, bytes memory expectedRlp) public pure {
bytes memory rlp = Transactions.encodeRLP(legacyTxn);
assertEq0(rlp, expectedRlp);

Expand All @@ -112,7 +112,7 @@ contract TestTransactions is Test, SuaveEnabled {
assertEq0(rlp1, expectedRlp);
}

function _testEIP1559Transaction(Transactions.EIP1559 memory eip1559Txn, bytes memory expectedRlp) public {
function _testEIP1559Transaction(Transactions.EIP1559 memory eip1559Txn, bytes memory expectedRlp) public pure {
bytes memory rlp = Transactions.encodeRLP(eip1559Txn);
assertEq0(rlp, expectedRlp);

Expand Down
2 changes: 1 addition & 1 deletion test/crypto/Secp256k1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "src/Context.sol";
import "src/crypto/Secp256k1.sol";

contract TestSecp256K1 is Test, SuaveEnabled {
function testRecoverAddress() public {
function testRecoverAddress() public pure {
string memory signingKey = "b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291";

address expected = 0x71562b71999873DB5b286dF957af199Ec94617F7;
Expand Down
14 changes: 8 additions & 6 deletions test/protocols/Builder/Session.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ contract Example {
contract SuaveBuilderSessionTest is Test, SuaveEnabled {
string constant signingKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
string constant execNodeEndpoint = "http://localhost:8545";
// pair of bls private and public keys
string constant blsPrivKey = "68a84428e388a5de81fa54f6f91a34d28f09692262c0ee4da81935a4e832ae19";
string constant blsPubKey =
"b6b973370f9684a2bc0b89f873b772b01269277196e84b69fe8ebad8908e777c09cdfad9d4a2f849e12ecd12ba9dce20";

function getBlockBuildArgs() public returns (Types.BuildBlockArgs memory) {
function getBlockBuildArgs() public pure returns (Types.BuildBlockArgs memory) {
Types.BuildBlockArgs memory args;
args.slot = 1;
args.proposerPubkey = hex"1234";
Expand Down Expand Up @@ -87,17 +91,13 @@ contract SuaveBuilderSessionTest is Test, SuaveEnabled {
// send a valid transaction
Transactions.EIP155 memory response = getValidTxn();
Types.SimulateTransactionResult memory result = session.addTransaction(response);
assertEq(result.success, true);

// build the block
session.buildBlock();
}

function testBuilderAPI_BidBuiltBlock() public {
// pair of bls private and public keys
string memory blsPrivKey = "68a84428e388a5de81fa54f6f91a34d28f09692262c0ee4da81935a4e832ae19";
string memory blsPubKey =
"b6b973370f9684a2bc0b89f873b772b01269277196e84b69fe8ebad8908e777c09cdfad9d4a2f849e12ecd12ba9dce20";

Types.BuildBlockArgs memory args = getBlockBuildArgs();

Session session = new Session(getBuilderSessionURL());
Expand All @@ -106,6 +106,7 @@ contract SuaveBuilderSessionTest is Test, SuaveEnabled {
// send a valid transaction
Transactions.EIP155 memory response = getValidTxn();
Types.SimulateTransactionResult memory result = session.addTransaction(response);
assertEq(result.success, true);

// build the block
session.buildBlock();
Expand All @@ -121,5 +122,6 @@ contract SuaveBuilderSessionTest is Test, SuaveEnabled {
} catch {
vm.skip(true);
}
revert("this code path should never be reached in normal circumstances");
}
}
4 changes: 2 additions & 2 deletions test/protocols/Builder/Types.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "src/suavelib/Suave.sol";
import "../../Fixtures.sol";

contract SuaveBuilderTypesTest is Test {
function testSuaveBuilderTypes_Encode_BuildblockArgs() public {
function testSuaveBuilderTypes_Encode_BuildblockArgs() public view {
Types.BuildBlockArgs memory args;
args.slot = 1;
args.proposerPubkey = hex"1234";
Expand All @@ -23,7 +23,7 @@ contract SuaveBuilderTypesTest is Test {
Fixtures.validate("suave_builder_builderArgs.json", string(encode));
}

function testSuaveBuilderTypes_Decode_SimulateTransactionResult() public {
function testSuaveBuilderTypes_Decode_SimulateTransactionResult() public view {
string memory test = Fixtures.readFixture("suave_builder_simulateTransactionResult_failed.json");
Types.SimulateTransactionResult memory result = Types.decodeSimulateTransactionResult(test);
assertEq(result.success, false);
Expand Down
4 changes: 2 additions & 2 deletions test/protocols/Bundle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "solady/src/utils/LibString.sol";
contract EthSendBundle is Test {
using LibString for *;

function testEthSendBundleEncode() public {
function testEthSendBundleEncode() public pure {
Bundle.BundleObj memory bundle;
bundle.blockNumber = 1;
bundle.txns = new bytes[](1);
Expand Down Expand Up @@ -41,7 +41,7 @@ contract EthSendBundle is Test {
);
}

function testBundleDecode() public {
function testBundleDecode() public pure {
string memory json = "{" '"blockNumber": "0xdead",' '"minTimestamp": 1625072400,'
'"maxTimestamp": 1625076000,' '"txs": [' '"0xdeadbeef",' '"0xc0ffee",' '"0x00aabb"' "]" "}";

Expand Down
2 changes: 1 addition & 1 deletion test/protocols/MevShare.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "src/protocols/MevShare.sol";
import "src/suavelib/Suave.sol";

contract MevShareTest is Test {
function testEncodeMevShare() public {
function testEncodeMevShare() public pure {
MevShare.Bundle memory bundle;
bundle.inclusionBlock = 1;

Expand Down

0 comments on commit e4b54df

Please sign in to comment.