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

update some deprecated references #8314

Merged
merged 3 commits into from
Feb 18, 2025
Merged
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
Expand Up @@ -48,7 +48,7 @@ protected static void extract(final Path path, final String destDirectory) throw
new TarArchiveInputStream(
new GzipCompressorInputStream(new FileInputStream(path.toAbsolutePath().toString())))) {
TarArchiveEntry entry;
while ((entry = fin.getNextTarEntry()) != null) {
while ((entry = fin.getNextEntry()) != null) {
if (entry.isDirectory()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Stream<GenesisAccount> streamAllocations() {
try {
parser.nextToken();
while (parser.nextToken() != JsonToken.END_OBJECT) {
if (ALLOCATION_FIELD.equals(parser.getCurrentName())) {
if (ALLOCATION_FIELD.equals(parser.currentName())) {
parser.nextToken();
parser.nextToken();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public void readGenesisFromObjectNode() {
final var configNode = mapper.createObjectNode();
configNode.put("londonBlock", 1);
final var allocNode = mapper.createObjectNode();
allocNode.put(Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
allocNode.putIfAbsent(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change from put to putIfAbsent? I guess either should be fine since the object node is being created in the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put with those args (String, JsonNode) is deprecated. putIfAbsent was an easy fix and yeah - it's a test, and the test still passes, and I didn't think any further about it

Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
final var rootNode = mapper.createObjectNode();
rootNode.put("chainId", 12);
rootNode.put(CONFIG_FIELD, configNode);
rootNode.put(ALLOCATION_FIELD, allocNode);
rootNode.putIfAbsent(CONFIG_FIELD, configNode);
rootNode.putIfAbsent(ALLOCATION_FIELD, allocNode);
final var genesisReader = new GenesisReader.FromObjectNode(rootNode);

assertThat(genesisReader.getRoot().get("chainid").asInt()).isEqualTo(12);
Expand All @@ -61,11 +62,12 @@ public void readGenesisFromObjectDoesNotModifyObjectNodeArg() {
final var configNode = mapper.createObjectNode();
configNode.put("londonBlock", 1);
final var allocNode = mapper.createObjectNode();
allocNode.put(Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
allocNode.putIfAbsent(
Address.BLS12_G2MULTIEXP.toUnprefixedHexString(), generateAllocation(Wei.ONE));
final var rootNode = mapper.createObjectNode();
rootNode.put("chainId", 12);
rootNode.put(CONFIG_FIELD, configNode);
rootNode.put(ALLOCATION_FIELD, allocNode);
rootNode.putIfAbsent(CONFIG_FIELD, configNode);
rootNode.putIfAbsent(ALLOCATION_FIELD, allocNode);
var rootNodeCopy = rootNode.deepCopy();
new GenesisReader.FromObjectNode(rootNode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static GenesisConfigOptions getGenesisConfigOptions(final String genesisC
new JsonFactory().createParser(GenesisConfig.class.getResource(genesisConfig))) {

while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
if ("config".equals(jsonParser.getCurrentName())) {
if ("config".equals(jsonParser.currentName())) {
jsonParser.nextToken();
return JsonGenesisConfigOptions.fromJsonObject(
normalizeKeys(new ObjectMapper().readTree(jsonParser)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.List;
import java.util.NavigableMap;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
Expand All @@ -63,7 +64,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** See https://github.com/ethereum/devp2p/blob/master/caps/snap.md */
/** See <a href="https://github.com/ethereum/devp2p/blob/master/caps/snap.md">snap</a> */
class SnapServer implements BesuEvents.InitialSyncCompletionListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SnapServer.class);
private static final int PRIME_STATE_ROOT_CACHE_LIMIT = 128;
Expand Down Expand Up @@ -524,7 +525,7 @@ MessageData constructGetTrieNodesResponse(final MessageData message) {
var trieNode = optStorage.orElse(Bytes.EMPTY);
if (!trieNodes.isEmpty()
&& (sumListBytes(trieNodes) + trieNode.size() > maxResponseBytes
|| stopWatch.getTime()
|| stopWatch.getTime(TimeUnit.MILLISECONDS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time units passed to method. I think milliseconds is right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah milliseconds is the right unit

> ResponseSizePredicate.MAX_MILLIS_PER_REQUEST)) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;

/** The Return data copy operation. */
/** The Return data load operation. */
public class ReturnDataLoadOperation extends AbstractOperation {

/**
* Instantiates a new Return data copy operation.
* Instantiates a new Return data load operation.
*
* @param gasCalculator the gas calculator
*/
Expand All @@ -45,10 +45,10 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {

final int offset = clampedToInt(frame.popStackItem());
Bytes returnData = frame.getReturnData();
int retunDataSize = returnData.size();
int returnDataSize = returnData.size();

Bytes value;
if (offset > retunDataSize) {
if (offset > returnDataSize) {
value = Bytes.EMPTY;
} else if (offset + 32 >= returnData.size()) {
value = Bytes32.rightPad(returnData.slice(offset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Optional<byte[]> get(final SegmentIdentifier segmentId, final byte[] key)
throwIfClosed();

try (final OperationTimer.TimingContext ignored = metrics.getReadLatency().startTimer()) {
return Optional.ofNullable(snapTx.get(columnFamilyMapper.apply(segmentId), readOptions, key));
return Optional.ofNullable(snapTx.get(readOptions, columnFamilyMapper.apply(segmentId), key));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter 1 and 2 swapped

} catch (final RocksDBException e) {
throw new StorageException(e);
}
Expand Down