Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Consensys Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.zktracer.instructionprocessing.createTests.advanced;

import java.util.Arrays;
import java.util.Collections;

import net.consensys.linea.testing.generated.MultiSendCallOnly;
import org.apache.tuweni.bytes.Bytes;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.datatypes.Function;

public class MultisendPayload {

public static Bytes multiSend(String payload) {
final Function function =
new Function(
MultiSendCallOnly.FUNC_MULTISEND,
Arrays.asList(
new org.web3j.abi.datatypes.DynamicBytes(Bytes.fromHexString(payload).toArray())),
Collections.emptyList());
return Bytes.fromHexStringLenient(FunctionEncoder.encode(function));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Consensys Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.zktracer.instructionprocessing.createTests.advanced;

import static net.consensys.linea.zktracer.instructionprocessing.createTests.advanced.ScenarioUtils.*;
import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.keyPair;
import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.userAccount;

import java.util.List;

import net.consensys.linea.reporting.TracerTestBase;
import net.consensys.linea.testing.*;
import net.consensys.linea.testing.generated.MultiSendCallOnly;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

public class MultisendTest extends TracerTestBase {

@Test
void test(TestInfo testInfo) {

// Account where smart contrat lies
ToyAccount customAccountSmartContract =
ToyAccount.builder()
.address(Address.fromHexString("0x" + buildCustomCreate2Address))
.balance(defaultBalance)
.nonce(1)
.code(SmartContractUtils.getSolidityContractRuntimeByteCode(MultiSendCallOnly.class))
.build();

// create payload to call multisend with data taken from linea scan
String payload =
"0x8d80ff0a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000010fd002d8879046f1559e53eb052e949e9544bcb72f4140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039783bd37f90001176211869ca2b568f2a7d4ee941e073a821ee1ff0001efd81eec32b9a8222d1842ec3d99c7532c31e3480504121f29cc0a1305ee44f48c1f0000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed48000000001908051b011e9c192403010001010201640106adba920a010003020101018cb0aa0a02000402010102efcb400a02000502010100d35b190a02000602010100ba15a80a020007020101013579f60a02000802010100663ed010020001090201fdb2093a090200020a0125b05d350a03000b020101346123ee0a03000c020101500ffbda0a03000d0201015f0818120a03000e0201017decc2f80a03000f0201000703000110020105a9bf9bc000000504617de60a0412120a00040a0412130a0007d60b1d2b00020608000014150200030003010101160a0196080301010011170196060a0101181901040a01011a1501ff00000000000000000000000000000000eacd56565ab642fb0dc2820b51547fe416ee8697176211869ca2b568f2a7d4ee941e073a821ee1ffb0091b7e234a67182712925ee4ef48c11bce61593cb104f044db23d6513f2a6100a1997fa5e3f587ad98eafc5c6e2e377615a5e78cb3f8738359d5237077f0cff76077d0ebb335b607db574400510557c48622190a6b91d64ee7459c62fade9abe61b48a586733678b9ac9da43dd7cb83bbb41d23677dfc3dded227d71a096c6b5d87807c1b5c456771aaa94e5d7c2a44ffddf6b295a15c148167daaaf5cf34f6e9ad0b8a41e2c148e7b0385d3ecbfdb8a216a9b6a72f4f191720c411cd1ff6a5ea8dedec3a6477135521ec62d91375ac9510d1feefe254b4b582ea05856edf9212bdcec74301ec78afc573b62d6a28392912a1dfbabd89219f79b961b34053260add7c28418e91cf8cbf7dd37b6492e23bec75d0f4d81d897a51baef69335b6248afefebd95e90399d37b0a0180912f869065c7a44617cd4c288be6bce5d1920ed01d983d65a1d624d1942ec268656987750acc8aebffb3964ec5cea0915080ddc1aca079583a4da219439258ca9da29e9cc4ce5596924745e12b935c1bf4b7563c460282617a0304e3cde133200f70b5bedd42000b71fdde22d3ee8a79bd49a568fc8fd732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c44466ad59cc374162659ba3fd410b1a5092ef48c9000000000000000000000000000000000000000000000000002d8879046f1559e53eb052e949e9544bcb72f4140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051783bd37f90001aca92e438df0b2401ff60da7e4337b687a2435da0001efd81eec32b9a8222d1842ec3d99c7532c31e3480504dcea04150a16b0cc36c374fb0000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed4800000000250c06290109c73dd00a0100010201010140a0110a01000302010155d9c30a0a0200040200000a03000502000500aac6210000055ad965da030400010607016405147575be080500080705c996c6b10a0500090701050657fe570a05000a07010517b86adb0a05000b070105a72fe2840a05000c070105405c2dae0a05000d0701051604556e0a05000e070105ac6fc97a0a05000f0701055658faa00a05001007010410050001110707006d1ae2000207105b5d890a05001213010700637c570a0500141301070b1f9cb30a00001513000703977d310a0000161300060700000117130003f1a9af850a0300181900020a03001a19000800010408041c1c1301099679470a01001d0701010080475b0a02001e07010100b7f0150a02001f070101014b92250a020020070101008e4b11070200012107010009041c0719060a01002223010a0a032525190008030501001b190196060305010024230196020a0501262701040a0501281301ff0000000000000000000000000000000000000000006667f117b936f17aa62d0fd3228ad0db046985e6aca92e438df0b2401ff60da7e4337b687a2435da52640a261068b18c1398e469979f50bc11cf7eab09666eaf650dc52cece84b1bcd2dd78997d239c75dc74003c0a9d08eb750b10ed5b02fa7d58d4d1eeacd56565ab642fb0dc2820b51547fe416ee8697176211869ca2b568f2a7d4ee941e073a821ee1ff5ec5b1e9b1bd5198343abb6e55fb695d2f7bb3083cb104f044db23d6513f2a6100a1997fa5e3f587a99cd4e87b9acac403540f90db07c9507540f9657077f0cff76077d0ebb335b607db574400510557d5539d0360438a66661148c633a9f0965e482845c48622190a6b91d64ee7459c62fade9abe61b48a17383d80043eb46472306c1bf603e305fbc4cb0f586733678b9ac9da43dd7cb83bbb41d23677dfc35f46260c486b1c1f769966c468d080d250319f80dded227d71a096c6b5d87807c1b5c456771aaa948611456f845293edd3f5788277f00f7c05ccc291a219439258ca9da29e9cc4ce5596924745e12b93c014414696f332c96c471634620344143325d2c06e9ad0b8a41e2c148e7b0385d3ecbfdb8a216a9befd5ec2cc043e3bd3c840f7998cc42ee712700ba8418e91cf8cbf7dd37b6492e23bec75d0f4d81d80180912f869065c7a44617cd4c288be6bce5d192e5d7c2a44ffddf6b295a15c148167daaaf5cf34f90375306810c6e8b2efa8294835c78b499d7c6915c1bf4b7563c460282617a0304e3cde133200f708aebffb3964ec5cea0915080ddc1aca079583a4db0091b7e234a67182712925ee4ef48c11bce61592848973568af7c89dac4321cb3c270a49ed242cc652c86ae02c9d01959c2b0da6867cfc542e98a105856edf9212bdcec74301ec78afc573b62d6a283a4477d98e519d4c1d66aef4efdf7cbeb84f4f778562bae2040b319b2a72384431d679531b9d53f01b5bedd42000b71fdde22d3ee8a79bd49a568fc8f97a51baef69335b6248afefebd95e90399d37b0a0ed01d983d65a1d624d1942ec268656987750accd732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c44466ad59cc374162659ba3fd410b1a5092ef48c9002d8879046f1559e53eb052e949e9544bcb72f414000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002f783bd37f90001a219439258ca9da29e9cc4ce5596924745e12b930001efd81eec32b9a8222d1842ec3d99c7532c31e34805033e6f01a50a0f2d67b1c53c6d8000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed480000000014060617010177c188080100010201198851e50a010003020101008586280a01000402010115fb8cb40a010005020101074dc99d0a020006020001036d72850a020007020001f539a45307020001080200013071e05a0a030109020100090400020a0524bfffb3030000010b0c016405082e4d550a00000d0c010409050f0c0f020a0211110f000912f594170a050f120a01080a0211130a010a030301000e0f0196040303010010140196000a0301151601ff00000000000000000000000000008aebffb3964ec5cea0915080ddc1aca079583a4da219439258ca9da29e9cc4ce5596924745e12b938611456f845293edd3f5788277f00f7c05ccc291c014414696f332c96c471634620344143325d2c0d5e04ba35908d7bf5bd2ead7e3e14d21df07dc016e9ad0b8a41e2c148e7b0385d3ecbfdb8a216a9befd5ec2cc043e3bd3c840f7998cc42ee712700ba8418e91cf8cbf7dd37b6492e23bec75d0f4d81d84466ad59cc374162659ba3fd410b1a5092ef48c93aab2285ddcddad8edf438c1bab47e1a9d05a9b4eacd56565ab642fb0dc2820b51547fe416ee8697176211869ca2b568f2a7d4ee941e073a821ee1ffb0091b7e234a67182712925ee4ef48c11bce61595c1bf4b7563c460282617a0304e3cde133200f70e5d7c2a44ffddf6b295a15c148167daaaf5cf34f97a51baef69335b6248afefebd95e90399d37b0a0ed01d983d65a1d624d1942ec268656987750acca22206521a460aa6b21a089c3b48ffd0c79d5fd547639488ee1de90bb4c0abba97d32f840727ebedb5bedd42000b71fdde22d3ee8a79bd49a568fc8fd732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c40000000000000000002d8879046f1559e53eb052e949e9544bcb72f414000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b583bd37f900013aab2285ddcddad8edf438c1bab47e1a9d05a9b40001efd81eec32b9a8222d1842ec3d99c7532c31e3480330217c0a03f48da478cd534000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed48000000000a03040c010810c5e20a010001020101f80f58a50901000203000a020004020103b49152ba0000020a0306060300040a0100070801000302010109030196060302010005080196020a02010a0b01ff000000000000000000000000000000000000a22206521a460aa6b21a089c3b48ffd0c79d5fd53aab2285ddcddad8edf438c1bab47e1a9d05a9b4e5d7c2a44ffddf6b295a15c148167daaaf5cf34f47639488ee1de90bb4c0abba97d32f840727ebed97a51baef69335b6248afefebd95e90399d37b0a0ed01d983d65a1d624d1942ec268656987750acc562bae2040b319b2a72384431d679531b9d53f01b5bedd42000b71fdde22d3ee8a79bd49a568fc8f5c1bf4b7563c460282617a0304e3cde133200f70d732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c400000000002d8879046f1559e53eb052e949e9544bcb72f414000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fa83bd37f900011bf74c010e6320bab11e2e5a532b5ac15e0b8aa60001efd81eec32b9a8222d1842ec3d99c7532c31e348080653f9c06bc7c9430a023be39322faf7e000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed48000000000c03050e000a01000102010391083cef0000033ad3d4600a0200030400020a030005040000000107a4e132ed0000060a0400060701040a010008090102030201010a04019600030201010b070196080a02010c0d01ff0000000000000000000000e24b4a292ba102a9b7b7f9de20718d7ba45ddb291bf74c010e6320bab11e2e5a532b5ac15e0b8aa6fde733b5de5b5a06c68353e01e4c1d3415c89560e5d7c2a44ffddf6b295a15c148167daaaf5cf34f0ed01d983d65a1d624d1942ec268656987750acc562bae2040b319b2a72384431d679531b9d53f01b5bedd42000b71fdde22d3ee8a79bd49a568fc8f057819bbc15121c923620c27303b2ed58b87cf862416092f143378750bb29b79ed961ab195cceea55c1bf4b7563c460282617a0304e3cde133200f7097a51baef69335b6248afefebd95e90399d37b0ad732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c400000000000000000000000000000000000000000000000000000000000000";
final Bytes multiSendPayload = MultisendPayload.multiSend(payload);

Transaction transaction =
ToyTransaction.builder()
.to(customAccountSmartContract)
.payload(multiSendPayload)
.sender(userAccount)
.keyPair(keyPair)
.gasLimit(gasLimit)
.build();

final ToyExecutionEnvironmentV2 toyExecutionEnvironmentV2 =
ToyExecutionEnvironmentV2.builder(chainConfig, testInfo)
.accounts(List.of(userAccount, customAccountSmartContract))
.transactions(List.of(transaction))
.build();
toyExecutionEnvironmentV2.run();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Consensys Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.zktracer.instructionprocessing.createTests.advanced;

import java.util.Arrays;
import java.util.Collections;

import net.consensys.linea.testing.generated.OdosRouterV2;
import org.apache.tuweni.bytes.Bytes;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.datatypes.Function;

public class OdosRouterV2Payload {

public static Bytes swapCompact() {
final Function function =
new Function(OdosRouterV2.FUNC_SWAPCOMPACT, Arrays.asList(), Collections.emptyList());
return Bytes.fromHexStringLenient(FunctionEncoder.encode(function));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright Consensys Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package net.consensys.linea.zktracer.instructionprocessing.createTests.advanced;

import static net.consensys.linea.zktracer.instructionprocessing.createTests.advanced.ScenarioUtils.*;
import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.keyPair;
import static net.consensys.linea.zktracer.instructionprocessing.utilities.MonoOpCodeSmcs.userAccount;

import java.util.List;

import net.consensys.linea.reporting.TracerTestBase;
import net.consensys.linea.testing.SmartContractUtils;
import net.consensys.linea.testing.ToyAccount;
import net.consensys.linea.testing.ToyExecutionEnvironmentV2;
import net.consensys.linea.testing.ToyTransaction;
import net.consensys.linea.testing.generated.OdosRouterV2;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

public class OdosRouterV2Test extends TracerTestBase {

@Test
void test(TestInfo testInfo) {

// Account where smart contrat lies
ToyAccount customAccountSmartContract =
ToyAccount.builder()
.address(Address.fromHexString("0x" + buildCustomCreate2Address))
.balance(defaultBalance)
.nonce(1)
.code(SmartContractUtils.getSolidityContractRuntimeByteCode(OdosRouterV2.class))
.build();

// create payload to call swapCompact with data extracted by Jeff
String call1 =
"0x83bd37f90001176211869ca2b568f2a7d4ee941e073a821ee1ff0001efd81eec32b9a8222d1842ec3d99c7532c31e3480504121f29cc0a1305ee44f48c1f0000001999990001fb66e944021bf915cfb4dac2b20653930bf7d35a000000013f6177ca0b041b1a469f11261f8a8b007633ed48000000001908051b011e9c192403010001010201640106adba920a010003020101018cb0aa0a02000402010102efcb400a02000502010100d35b190a02000602010100ba15a80a020007020101013579f60a02000802010100663ed010020001090201fdb2093a090200020a0125b05d350a03000b020101346123ee0a03000c020101500ffbda0a03000d0201015f0818120a03000e0201017decc2f80a03000f0201000703000110020105a9bf9bc000000504617de60a0412120a00040a0412130a0007d60b1d2b00020608000014150200030003010101160a0196080301010011170196060a0101181901040a01011a1501ff00000000000000000000000000000000eacd56565ab642fb0dc2820b51547fe416ee8697176211869ca2b568f2a7d4ee941e073a821ee1ffb0091b7e234a67182712925ee4ef48c11bce61593cb104f044db23d6513f2a6100a1997fa5e3f587ad98eafc5c6e2e377615a5e78cb3f8738359d5237077f0cff76077d0ebb335b607db574400510557c48622190a6b91d64ee7459c62fade9abe61b48a586733678b9ac9da43dd7cb83bbb41d23677dfc3dded227d71a096c6b5d87807c1b5c456771aaa94e5d7c2a44ffddf6b295a15c148167daaaf5cf34f6e9ad0b8a41e2c148e7b0385d3ecbfdb8a216a9b6a72f4f191720c411cd1ff6a5ea8dedec3a6477135521ec62d91375ac9510d1feefe254b4b582ea05856edf9212bdcec74301ec78afc573b62d6a28392912a1dfbabd89219f79b961b34053260add7c28418e91cf8cbf7dd37b6492e23bec75d0f4d81d897a51baef69335b6248afefebd95e90399d37b0a0180912f869065c7a44617cd4c288be6bce5d1920ed01d983d65a1d624d1942ec268656987750acc8aebffb3964ec5cea0915080ddc1aca079583a4da219439258ca9da29e9cc4ce5596924745e12b935c1bf4b7563c460282617a0304e3cde133200f70b5bedd42000b71fdde22d3ee8a79bd49a568fc8fd732d4a9fe4431fa1b5aab3a0feaae47de186849e4eeb461ad1e4ef8b8ef71a33694ccd84af051c44466ad59cc374162659ba3fd410b1a5092ef48c9000000000000000000000000000000000000000000000000";
final Bytes swapCompactPayload = OdosRouterV2Payload.swapCompact();

Transaction transaction =
ToyTransaction.builder()
.to(customAccountSmartContract)
.payload(swapCompactPayload)
.sender(userAccount)
.keyPair(keyPair)
.gasLimit(gasLimit)
.build();

final ToyExecutionEnvironmentV2 toyExecutionEnvironmentV2 =
ToyExecutionEnvironmentV2.builder(chainConfig, testInfo)
.accounts(List.of(userAccount, customAccountSmartContract))
.transactions(List.of(transaction))
.build();
toyExecutionEnvironmentV2.run();
}
}
Loading