Skip to content

Commit b5716d5

Browse files
Merge branch 'master' into p2p-dump
2 parents 1f0bce0 + 847bb34 commit b5716d5

39 files changed

+215
-176
lines changed

Diff for: eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_generic/containers/SszUInt16.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1717

18-
public class SszUInt16 extends AbstractSszPrimitive<Integer, SszUInt16> {
18+
public class SszUInt16 extends AbstractSszPrimitive<Integer> {
1919

2020
public static SszUInt16 of(Integer val) {
2121
return new SszUInt16(val);

Diff for: ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public <T extends SszData> SszList<T> randomSszList(
324324
.collect(schema.collector());
325325
}
326326

327-
public <ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
327+
public <ElementT, SszElementT extends SszPrimitive<ElementT>>
328328
SszPrimitiveList<ElementT, SszElementT> randomSszPrimitiveList(
329329
final SszPrimitiveListSchema<ElementT, SszElementT, ?> schema,
330330
final long numItems,
@@ -356,7 +356,7 @@ public SszBytes32Vector randomSszBytes32Vector(
356356
.collect(schema.collectorUnboxed());
357357
}
358358

359-
public <ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
359+
public <ElementT, SszElementT extends SszPrimitive<ElementT>>
360360
SszPrimitiveVector<ElementT, SszElementT> randomSszPrimitiveVector(
361361
final SszPrimitiveVectorSchema<ElementT, SszElementT, ?> schema,
362362
final Supplier<ElementT> valueGenerator) {

Diff for: ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/OperationPoolEntryTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.junit.jupiter.api.Test;
2222
import tech.pegasys.teku.infrastructure.bytes.Bytes4;
2323
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
24-
import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes4;
2524
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
2625
import tech.pegasys.teku.infrastructure.time.StubTimeProvider;
2726
import tech.pegasys.teku.infrastructure.time.TimeProvider;
@@ -47,7 +46,7 @@ void shouldSortLocalFirst() {
4746
.containsExactly(b2, b1, b0);
4847
}
4948

50-
private static class TestClass extends AbstractSszPrimitive<Bytes4, SszBytes4>
49+
private static class TestClass extends AbstractSszPrimitive<Bytes4>
5150
implements MessageWithValidatorId {
5251

5352
TestClass(final Bytes4 b) {

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/SszPrimitive.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
/**
1919
* A wrapper class for SSZ primitive values. {@link SszPrimitive} classes has no mutable versions
2020
*/
21-
public interface SszPrimitive<ValueType, SszType extends SszPrimitive<ValueType, SszType>>
22-
extends SszData {
21+
public interface SszPrimitive<ValueType> extends SszData {
2322

2423
/** Returns wrapped primitive value */
2524
ValueType get();
@@ -36,5 +35,5 @@ default boolean isWritableSupported() {
3635
}
3736

3837
@Override
39-
SszPrimitiveSchema<ValueType, SszType> getSchema();
38+
SszPrimitiveSchema<ValueType, ?> getSchema();
4039
}

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszMutablePrimitiveCollection.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1818
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchema;
1919

20-
public interface SszMutablePrimitiveCollection<
21-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
20+
public interface SszMutablePrimitiveCollection<ElementT, SszElementT extends SszPrimitive<ElementT>>
2221
extends SszPrimitiveCollection<ElementT, SszElementT>, SszMutableComposite<SszElementT> {
2322

2423
@SuppressWarnings("unchecked")

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszMutablePrimitiveList.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.SszMutableList;
1717
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1818

19-
public interface SszMutablePrimitiveList<
20-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
19+
public interface SszMutablePrimitiveList<ElementT, SszElementT extends SszPrimitive<ElementT>>
2120
extends SszMutablePrimitiveCollection<ElementT, SszElementT>,
2221
SszMutableList<SszElementT>,
2322
SszPrimitiveList<ElementT, SszElementT> {

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszMutablePrimitiveVector.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.SszMutableVector;
1717
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1818

19-
public interface SszMutablePrimitiveVector<
20-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
19+
public interface SszMutablePrimitiveVector<ElementT, SszElementT extends SszPrimitive<ElementT>>
2120
extends SszMutablePrimitiveCollection<ElementT, SszElementT>,
2221
SszMutableVector<SszElementT>,
2322
SszPrimitiveVector<ElementT, SszElementT> {

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszPrimitiveCollection.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
2121
import tech.pegasys.teku.infrastructure.ssz.schema.SszCollectionSchema;
2222

23-
public interface SszPrimitiveCollection<
24-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
23+
public interface SszPrimitiveCollection<ElementT, SszElementT extends SszPrimitive<ElementT>>
2524
extends SszCollection<SszElementT> {
2625

2726
default ElementT getElement(int index) {

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszPrimitiveList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.SszList;
1717
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1818

19-
public interface SszPrimitiveList<ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
19+
public interface SszPrimitiveList<ElementT, SszElementT extends SszPrimitive<ElementT>>
2020
extends SszPrimitiveCollection<ElementT, SszElementT>, SszList<SszElementT> {
2121

2222
@Override

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/SszPrimitiveVector.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1717
import tech.pegasys.teku.infrastructure.ssz.SszVector;
1818

19-
public interface SszPrimitiveVector<
20-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
19+
public interface SszPrimitiveVector<ElementT, SszElementT extends SszPrimitive<ElementT>>
2120
extends SszPrimitiveCollection<ElementT, SszElementT>, SszVector<SszElementT> {
2221

2322
@Override

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/impl/AbstractSszMutablePrimitiveCollection.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import tech.pegasys.teku.infrastructure.ssz.tree.TreeUpdates;
3535

3636
public abstract class AbstractSszMutablePrimitiveCollection<
37-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
37+
ElementT, SszElementT extends SszPrimitive<ElementT>>
3838
extends AbstractSszMutableCollection<SszElementT, SszElementT>
3939
implements SszMutablePrimitiveCollection<ElementT, SszElementT> {
4040

@@ -116,8 +116,7 @@ public SszMutablePrimitiveCollection<ElementT, SszElementT> createWritableCopy()
116116
throw new UnsupportedOperationException();
117117
}
118118

119-
private static class NodeUpdate<
120-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>> {
119+
private static class NodeUpdate<ElementT, SszElementT extends SszPrimitive<ElementT>> {
121120
private final List<PackedNodeUpdate<ElementT, SszElementT>> updates;
122121
private final long nodeGIndex;
123122

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/impl/SszMutablePrimitiveListImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
2525
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
2626

27-
public class SszMutablePrimitiveListImpl<
28-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
27+
public class SszMutablePrimitiveListImpl<ElementT, SszElementT extends SszPrimitive<ElementT>>
2928
extends AbstractSszMutablePrimitiveCollection<ElementT, SszElementT>
3029
implements SszMutablePrimitiveList<ElementT, SszElementT> {
3130

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/impl/SszMutablePrimitiveVectorImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszPrimitiveVectorSchema;
2222
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
2323

24-
public class SszMutablePrimitiveVectorImpl<
25-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
24+
public class SszMutablePrimitiveVectorImpl<ElementT, SszElementT extends SszPrimitive<ElementT>>
2625
extends AbstractSszMutablePrimitiveCollection<ElementT, SszElementT>
2726
implements SszMutablePrimitiveVector<ElementT, SszElementT> {
2827

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/impl/SszPrimitiveListImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import tech.pegasys.teku.infrastructure.ssz.tree.CachingTreeAccessor;
2424
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
2525

26-
public class SszPrimitiveListImpl<ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
26+
public class SszPrimitiveListImpl<ElementT, SszElementT extends SszPrimitive<ElementT>>
2727
extends SszListImpl<SszElementT> implements SszPrimitiveList<ElementT, SszElementT> {
2828

2929
protected final int elementsPerChunk;

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/collections/impl/SszPrimitiveVectorImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
import tech.pegasys.teku.infrastructure.ssz.schema.SszCompositeSchema;
2323
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
2424

25-
public class SszPrimitiveVectorImpl<
26-
ElementT, SszElementT extends SszPrimitive<ElementT, SszElementT>>
25+
public class SszPrimitiveVectorImpl<ElementT, SszElementT extends SszPrimitive<ElementT>>
2726
extends SszVectorImpl<SszElementT> implements SszPrimitiveVector<ElementT, SszElementT> {
2827

2928
SszPrimitiveVectorImpl(SszCompositeSchema<?> schema, Supplier<TreeNode> lazyBackingNode) {

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/AbstractSszPrimitive.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
import tech.pegasys.teku.infrastructure.ssz.schema.impl.AbstractSszPrimitiveSchema;
1919
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
2020

21-
public abstract class AbstractSszPrimitive<C, V extends AbstractSszPrimitive<C, V>>
22-
implements SszPrimitive<C, V> {
23-
private final AbstractSszPrimitiveSchema<C, V> schema;
21+
public abstract class AbstractSszPrimitive<C> implements SszPrimitive<C> {
22+
private final AbstractSszPrimitiveSchema<C, ?> schema;
2423
private final C value;
2524

26-
protected AbstractSszPrimitive(C value, AbstractSszPrimitiveSchema<C, V> schema) {
25+
protected AbstractSszPrimitive(C value, AbstractSszPrimitiveSchema<C, ?> schema) {
2726
this.schema = schema;
2827
this.value = value;
2928
}
@@ -34,18 +33,13 @@ public C get() {
3433
}
3534

3635
@Override
37-
public AbstractSszPrimitiveSchema<C, V> getSchema() {
36+
public AbstractSszPrimitiveSchema<C, ?> getSchema() {
3837
return schema;
3938
}
4039

4140
@Override
4241
public TreeNode getBackingNode() {
43-
return getSchema().createBackingNode(getThis());
44-
}
45-
46-
@SuppressWarnings("unchecked")
47-
protected V getThis() {
48-
return (V) this;
42+
return getSchema().createBackingNode(this);
4943
}
5044

5145
@Override
@@ -56,7 +50,7 @@ public boolean equals(Object o) {
5650
if (o == null || getClass() != o.getClass()) {
5751
return false;
5852
}
59-
AbstractSszPrimitive<?, ?> that = (AbstractSszPrimitive<?, ?>) o;
53+
AbstractSszPrimitive<?> that = (AbstractSszPrimitive<?>) o;
6054
return Objects.equals(get(), that.get());
6155
}
6256

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszBit.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1717
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1818

19-
public class SszBit extends AbstractSszPrimitive<Boolean, SszBit> {
19+
public class SszBit extends AbstractSszPrimitive<Boolean> {
2020

2121
private static final SszBit TRUE_VIEW = new SszBit(true);
2222
private static final SszBit FALSE_VIEW = new SszBit(false);

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszByte.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1717
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1818

19-
public class SszByte extends AbstractSszPrimitive<Byte, SszByte> {
19+
public class SszByte extends AbstractSszPrimitive<Byte> {
2020

2121
public static final SszByte ZERO = SszByte.of(0);
2222

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszBytes32.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1818
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1919

20-
public class SszBytes32 extends AbstractSszPrimitive<Bytes32, SszBytes32> {
20+
public class SszBytes32 extends AbstractSszPrimitive<Bytes32> {
2121

2222
public static SszBytes32 of(Bytes32 val) {
2323
return new SszBytes32(val);

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszBytes4.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1818
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1919

20-
public class SszBytes4 extends AbstractSszPrimitive<Bytes4, SszBytes4> {
20+
public class SszBytes4 extends AbstractSszPrimitive<Bytes4> {
2121

2222
public static SszBytes4 of(Bytes4 val) {
2323
return new SszBytes4(val);

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszNone.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1717
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1818

19-
public class SszNone extends AbstractSszPrimitive<Void, SszNone> {
19+
public class SszNone extends AbstractSszPrimitive<Void> {
2020

2121
public static final SszNone INSTANCE = new SszNone();
2222

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszUInt256.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1818
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
1919

20-
public class SszUInt256 extends AbstractSszPrimitive<UInt256, SszUInt256> {
20+
public class SszUInt256 extends AbstractSszPrimitive<UInt256> {
2121

2222
public static final SszUInt256 ZERO = SszUInt256.of(UInt256.ZERO);
2323

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/primitive/SszUInt64.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
import tech.pegasys.teku.infrastructure.ssz.impl.AbstractSszPrimitive;
1717
import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas;
18+
import tech.pegasys.teku.infrastructure.ssz.schema.impl.AbstractSszUInt64Schema;
1819
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
1920

20-
public class SszUInt64 extends AbstractSszPrimitive<UInt64, SszUInt64> {
21+
public class SszUInt64 extends AbstractSszPrimitive<UInt64> {
2122

2223
public static final SszUInt64 ZERO = new SszUInt64(UInt64.ZERO);
2324
public static final SszUInt64 THIRTY_TWO_ETH = new SszUInt64(UInt64.THIRTY_TWO_ETH);
@@ -40,6 +41,10 @@ private SszUInt64(final UInt64 val) {
4041
super(val, SszPrimitiveSchemas.UINT64_SCHEMA);
4142
}
4243

44+
protected SszUInt64(final UInt64 val, final AbstractSszUInt64Schema<? extends SszUInt64> schema) {
45+
super(val, schema);
46+
}
47+
4348
public long longValue() {
4449
return get().longValue();
4550
}

Diff for: infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/SszPrimitiveSchema.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import tech.pegasys.teku.infrastructure.ssz.SszPrimitive;
1818
import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode;
1919

20-
public interface SszPrimitiveSchema<DataT, SszDataT extends SszPrimitive<DataT, SszDataT>>
20+
public interface SszPrimitiveSchema<DataT, SszDataT extends SszPrimitive<DataT>>
2121
extends SszSchema<SszDataT> {
2222

2323
int getBitsSize();
@@ -47,7 +47,7 @@ default SszDataT createFromPackedNode(TreeNode node, int internalIndex) {
4747
*/
4848
TreeNode updatePackedNode(TreeNode srcNode, List<PackedNodeUpdate<DataT, SszDataT>> updates);
4949

50-
final class PackedNodeUpdate<DataT, SszDataT extends SszPrimitive<DataT, SszDataT>> {
50+
final class PackedNodeUpdate<DataT, SszDataT extends SszPrimitive<DataT>> {
5151

5252
private final int internalIndex;
5353
private final SszDataT newValue;

0 commit comments

Comments
 (0)