Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-6110: Add deposit validation and apis #5295

Merged
merged 47 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dcd958b
Initial commit
ensi321 Apr 3, 2023
ee3e2ae
Spotless Apply
ensi321 Apr 3, 2023
e62b6f5
Update test
ensi321 Apr 3, 2023
d25ad53
Added rpc tests. Update block creator rule for deposits
ensi321 Apr 3, 2023
ca121d3
Update test
ensi321 Apr 3, 2023
faf5a83
Update test
ensi321 Apr 4, 2023
53b2ac3
Spotless Apply
ensi321 Apr 4, 2023
941f602
Get deposit validator by block header
ensi321 Apr 4, 2023
0c26667
Fix up unit tests
ensi321 Apr 4, 2023
c15fa47
Recover deleted files
ensi321 Apr 5, 2023
2c80293
Fix test
ensi321 Apr 5, 2023
bb805c1
Rename according to feedback
ensi321 Apr 11, 2023
e6adf32
Introduce depositContractAddress to genesis file
ensi321 Apr 11, 2023
da4e180
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 Apr 11, 2023
d3d18a8
Update test to accommodate changes
ensi321 Apr 11, 2023
162f60c
Fix test
ensi321 Apr 11, 2023
6d567cc
Address comments
ensi321 Apr 30, 2023
1dbad08
Address pr comments
ensi321 May 2, 2023
00a9edd
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 May 2, 2023
695e6a0
Updated DepositsValidatorProvider
ensi321 May 2, 2023
fd8739b
Spotless Apply
ensi321 May 2, 2023
0bf4be1
Extract correct logs from receipts
ensi321 May 2, 2023
7f55dd9
Merge branch 'main' into eip-6110
ensi321 May 3, 2023
17d264b
Add changelog
ensi321 May 3, 2023
f79d203
Address PR comments
ensi321 May 8, 2023
807940f
Address PR comments
ensi321 May 8, 2023
d5ec15f
Address PR comments
ensi321 May 8, 2023
d712c0d
Merge branch 'main' into eip-6110
ensi321 May 8, 2023
f962e62
Spotless Apply
ensi321 May 8, 2023
1caf791
Detail log on failing deposit validation
ensi321 May 10, 2023
c3cbf98
Pass depositContractAddress to block creator and coordinator
ensi321 May 11, 2023
dd44ed4
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 May 12, 2023
201c44e
Update javadoc
ensi321 May 14, 2023
52e422b
Address comments
ensi321 May 16, 2023
713cc5d
Address comments
ensi321 May 16, 2023
eced987
Fix spotless
siladu May 26, 2023
74cda7f
Merge branch 'main' into eip-6110
siladu May 26, 2023
a9f80de
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 Jun 4, 2023
0b849ca
Merge branch 'hyperledger:main' into eip-6110
ensi321 Jun 11, 2023
e4efdff
Fix acceptance tests
ensi321 Jun 13, 2023
c99fe13
Merge branch 'main' into eip-6110
ensi321 Jun 13, 2023
fa69181
Fix unit tests by setting genesis file in the setup code
siladu Jun 16, 2023
346415c
Merge remote-tracking branch 'upstream/main' into eip-6110
siladu Jun 16, 2023
2380e32
Fix mock in another test, unintended consequence of last commit
siladu Jun 16, 2023
8804b98
Add units for AbstractBlockCreator
siladu Jun 16, 2023
b790ff1
Inline variables and tidy up
siladu Jun 16, 2023
8b270bb
Merge branch 'main' into eip-6110
siladu Jun 21, 2023
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
3 changes: 2 additions & 1 deletion config/src/main/resources/experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
}
}
},
"depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa"
ensi321 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,6 @@ public void shouldReturnExecutionPayloadWithoutWithdrawals_PreShanghaiBlock() {
assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV2.class);
final EngineGetPayloadResultV2 res = (EngineGetPayloadResultV2) r.getResult();
assertThat(res.getExecutionPayload().getWithdrawals()).isNull();
});
verify(engineCallListener, times(1)).executionEngineCalled();
}

@Test
public void shouldReturnExecutionPayloadWithoutDeposits_PreShanghaiBlock() {
final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V2.getMethodName(), mockPid);
assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class);
Optional.of(resp)
.map(JsonRpcSuccessResponse.class::cast)
.ifPresent(
r -> {
assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV2.class);
final EngineGetPayloadResultV2 res = (EngineGetPayloadResultV2) r.getResult();
assertThat(res.getExecutionPayload().getDeposits()).isNull();
});
verify(engineCallListener, times(1)).executionEngineCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ protected BlockCreationResult createBlock(
final List<Deposit> depositsFromReceipts =
transactionResults.getReceipts().stream()
.flatMap(receipt -> receipt.getLogsList().stream())
.filter(log -> true) // TODO: Figure out how to get the deposit contract address
.map(DepositDecoder::decodeFromLog)
.toList();
maybeDeposits = Optional.of(depositsFromReceipts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DepositContract extends Contract {
new TypeReference<DynamicBytes>() {},
new TypeReference<DynamicBytes>() {}));

protected DepositContract(
private DepositContract(
final String contractBinary,
final String contractAddress,
final Web3j web3j,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.tuweni.units.bigints.UInt64;
import org.web3j.tx.Contract;

import java.nio.ByteOrder;

public class DepositDecoder {

public static Deposit decode(final RLPInput rlpInput) {
Expand All @@ -53,12 +55,13 @@ public static Deposit decodeFromLog(final Log log) {
return new Deposit(
BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)),
Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)),
GWei.of(Bytes.wrap(rawAmount).reverse().toLong()),
GWei.of(Bytes.wrap(rawAmount).toLong(ByteOrder.LITTLE_ENDIAN)), // Amount is little endian as per Deposit Contract
BLSSignature.wrap(Bytes.wrap(rawSignature)),
UInt64.valueOf(Bytes.wrap(rawIndex).reverse().toLong()));
}

public static Deposit decodeOpaqueBytes(final Bytes input) {
return decode(RLP.input(input));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,29 @@ void shouldDecodeDeposit() {

@Test
void shouldDecodeDepositFromLog() {
Address address = Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa");
List<LogTopic> topics =
final Address address = Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa");
final List<LogTopic> topics =
List.of(
LogTopic.fromHexString(
"0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"));
Bytes data =
final Bytes data =
Bytes.fromHexString(
"0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000");

Log log = new Log(address, data, topics);
Deposit deposit = DepositDecoder.decodeFromLog(log);
final Log log = new Log(address, data, topics);
final Deposit deposit = DepositDecoder.decodeFromLog(log);

System.out.println(deposit);
final Deposit expectedDeposit =
new Deposit(
BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString(
"0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"),
GWei.of(32000000000L),
BLSSignature.fromHexString(
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.ONE);

assertThat(deposit).isEqualTo(expectedDeposit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class DepositsValidatorTest {

@BeforeAll
public static void setup() {
System.out.println("setting");
DEPOSIT_1 =
new Deposit(
BLSPublicKey.fromHexString(
Expand Down