Skip to content

Commit 9515ec7

Browse files
committed
feat: add simple EOA to EOA
1 parent fd0adc5 commit 9515ec7

File tree

1 file changed

+58
-17
lines changed
  • tracer/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/callTests

1 file changed

+58
-17
lines changed

tracer/arithmetization/src/test/java/net/consensys/linea/zktracer/instructionprocessing/callTests/CallDelegation.java

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import net.consensys.linea.testing.ToyAccount;
55
import net.consensys.linea.testing.ToyExecutionEnvironmentV2;
66
import net.consensys.linea.testing.ToyTransaction;
7-
import net.consensys.linea.testing.TransactionProcessingResultValidator;
87
import org.apache.tuweni.bytes.Bytes;
98
import org.hyperledger.besu.crypto.KeyPair;
109
import org.hyperledger.besu.crypto.SECP256K1;
@@ -31,14 +30,19 @@
3130
CALL
3231
--------> - EOA1
3332
|---------------> EOA2
34-
(delegated to) |---------------> Smart Contract
35-
(delegated to)
33+
(delegated to)
3634
(3) TARGET is an EOA delegated to itself
3735
CALL
3836
--------> - EOA <---------|
3937
|-------------|
4038
(delegated to)
41-
(4) TARGET is a precompile
39+
(4) TARGET is an EOA delegated to another EOA delegated to a Smart Contract
40+
CALL
41+
--------> - EOA1
42+
|---------------> EOA2
43+
(delegated to) |---------------> Smart Contract
44+
(delegated to)
45+
(5) TARGET is a precompile
4246
CALL
4347
--------> - EOA
4448
|---------------> PRC, here P256_VERIFY
@@ -59,9 +63,8 @@ public class CallDelegation extends TracerTestBase {
5963
final String smcBytecode = "0x30473833345a";
6064
final ToyAccount smcAccount =
6165
ToyAccount.builder()
62-
.address(Address.fromHexString("aaaaa")) // identity caller
63-
.nonce(99)
64-
.balance(Wei.of(1_000_000L))
66+
.address(Address.fromHexString("1234"))
67+
.nonce(90)
6568
.code(
6669
Bytes.concatenate(Bytes.fromHexString(smcBytecode)))
6770
.build();
@@ -108,21 +111,18 @@ void EOADelegatedToSmc(TestInfo testInfo) {
108111
CALL
109112
--------> - EOA1
110113
|---------------> EOA2
111-
(delegated to) |---------------> Smart Contract
112-
(delegated to)
114+
(delegated to)
113115
*/
114116
@Test
115-
void EOA1DelegatedEOA2DelegatedToSmc(TestInfo testInfo) {
117+
void EOA1DelegatedEOA2(TestInfo testInfo) {
116118

117-
ToyAccount eoa2DelegatedToSmc =
119+
ToyAccount eoa2 =
118120
ToyAccount.builder()
119121
.address(Address.fromHexString("ca11ee2")) // identity caller
120-
.nonce(99)
121-
.code(
122-
Bytes.concatenate(Bytes.fromHexString(delegationCodeToSmc)))
122+
.nonce(80)
123123
.build();
124124

125-
String delegationCodeToEoa2 = "0xef0100" + eoa2DelegatedToSmc.getAddress().toHexString().substring(2);
125+
String delegationCodeToEoa2 = "0xef0100" + eoa2.getAddress().toHexString().substring(2);
126126

127127
ToyAccount eoa1DelegatedToEoa2 =
128128
ToyAccount.builder()
@@ -138,7 +138,7 @@ void EOA1DelegatedEOA2DelegatedToSmc(TestInfo testInfo) {
138138
.to(eoa1DelegatedToEoa2).build();
139139

140140
ToyExecutionEnvironmentV2.builder(chainConfig, testInfo)
141-
.accounts(List.of(senderAccount, smcAccount, eoa1DelegatedToEoa2, eoa2DelegatedToSmc))
141+
.accounts(List.of(senderAccount, smcAccount, eoa1DelegatedToEoa2, eoa2))
142142
.transaction(tx)
143143
.build()
144144
.run();
@@ -179,7 +179,48 @@ void EOADelegatedToItself(TestInfo testInfo) {
179179
}
180180

181181
/*
182-
(4) TARGET is a precompile
182+
(4) TARGET is an EOA delegated to another EOA
183+
CALL
184+
--------> - EOA1
185+
|---------------> EOA2
186+
(delegated to) |---------------> Smart Contract
187+
(delegated to)
188+
*/
189+
@Test
190+
void EOA1DelegatedEOA2DelegatedToSmc(TestInfo testInfo) {
191+
192+
ToyAccount eoa2DelegatedToSmc =
193+
ToyAccount.builder()
194+
.address(Address.fromHexString("ca11ee2")) // identity caller
195+
.nonce(80)
196+
.code(
197+
Bytes.concatenate(Bytes.fromHexString(delegationCodeToSmc)))
198+
.build();
199+
200+
String delegationCodeToEoa2 = "0xef0100" + eoa2DelegatedToSmc.getAddress().toHexString().substring(2);
201+
202+
ToyAccount eoa1DelegatedToEoa2 =
203+
ToyAccount.builder()
204+
.address(Address.fromHexString("ca11ee1")) // identity caller
205+
.nonce(99)
206+
.code(
207+
Bytes.concatenate(Bytes.fromHexString(delegationCodeToEoa2)))
208+
.build();
209+
210+
Transaction tx = ToyTransaction.builder()
211+
.sender(senderAccount)
212+
.keyPair(keyPair)
213+
.to(eoa1DelegatedToEoa2).build();
214+
215+
ToyExecutionEnvironmentV2.builder(chainConfig, testInfo)
216+
.accounts(List.of(senderAccount, smcAccount, eoa1DelegatedToEoa2, eoa2DelegatedToSmc))
217+
.transaction(tx)
218+
.build()
219+
.run();
220+
}
221+
222+
/*
223+
(5) TARGET is a precompile
183224
CALL
184225
--------> - EOA
185226
|---------------> PRC, here P256_VERIFY

0 commit comments

Comments
 (0)