mirror of https://github.com/hyperledger/besu
Access List State Test Support for evmtool (#1945)
Update reference test hash for access list tests. Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>pull/1965/head
parent
2e87576245
commit
f25d458345
@ -0,0 +1,55 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* 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 org.hyperledger.besu.ethereum.core.json; |
||||
|
||||
import static com.google.common.base.Preconditions.checkState; |
||||
|
||||
import org.hyperledger.besu.ethereum.core.AccessListEntry; |
||||
import org.hyperledger.besu.ethereum.core.Address; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
|
||||
import com.fasterxml.jackson.core.JsonParser; |
||||
import com.fasterxml.jackson.core.JsonToken; |
||||
import com.fasterxml.jackson.databind.DeserializationContext; |
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; |
||||
import org.apache.tuweni.bytes.Bytes32; |
||||
|
||||
public class AccessListEntryDeserializer extends StdDeserializer<AccessListEntry> { |
||||
private AccessListEntryDeserializer() { |
||||
this(null); |
||||
} |
||||
|
||||
protected AccessListEntryDeserializer(final Class<?> vc) { |
||||
super(vc); |
||||
} |
||||
|
||||
@Override |
||||
public AccessListEntry deserialize(final JsonParser p, final DeserializationContext ctxt) |
||||
throws IOException { |
||||
checkState(p.nextFieldName().equals("address")); |
||||
final Address address = Address.fromHexString(p.nextTextValue()); |
||||
checkState(p.nextFieldName().equals("storageKeys")); |
||||
checkState(p.nextToken().equals(JsonToken.START_ARRAY)); |
||||
final ArrayList<Bytes32> storageKeys = new ArrayList<>(); |
||||
while (!p.nextToken().equals(JsonToken.END_ARRAY)) { |
||||
storageKeys.add(Bytes32.fromHexString(p.getText())); |
||||
} |
||||
p.nextToken(); // consume end of object
|
||||
return new AccessListEntry(address, storageKeys); |
||||
} |
||||
} |
@ -0,0 +1,54 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* 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 org.hyperledger.besu.ethereum.core.json; |
||||
|
||||
import org.hyperledger.besu.ethereum.core.AccessListEntry; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator; |
||||
import com.fasterxml.jackson.databind.SerializerProvider; |
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; |
||||
import org.apache.tuweni.bytes.Bytes32; |
||||
|
||||
public class AccessListEntrySerializer extends StdSerializer<AccessListEntry> { |
||||
|
||||
AccessListEntrySerializer() { |
||||
this(null); |
||||
} |
||||
|
||||
protected AccessListEntrySerializer(final Class<AccessListEntry> t) { |
||||
super(t); |
||||
} |
||||
|
||||
@Override |
||||
public void serialize( |
||||
final AccessListEntry accessListEntry, |
||||
final JsonGenerator gen, |
||||
final SerializerProvider provider) |
||||
throws IOException { |
||||
gen.writeStartObject(); |
||||
gen.writeFieldName("address"); |
||||
gen.writeString(accessListEntry.getAddress().toHexString()); |
||||
gen.writeFieldName("storageKeys"); |
||||
final List<Bytes32> storageKeys = accessListEntry.getStorageKeys(); |
||||
gen.writeArray( |
||||
storageKeys.stream().map(Bytes32::toHexString).toArray(String[]::new), |
||||
0, |
||||
storageKeys.size()); |
||||
gen.writeEndObject(); |
||||
} |
||||
} |
@ -0,0 +1,90 @@ |
||||
{ |
||||
"accessList" : { |
||||
"_info" : { |
||||
"comment" : "Access list in tr example", |
||||
"filling-rpc-server" : "evm version 1.10.0-unstable-e09dc4eb-20210211", |
||||
"filling-tool-version" : "retesteth-0.1.0-accesslist+commit.37e87c45.Linux.g++", |
||||
"lllcversion" : "Version: 0.5.14-develop.2020.6.22+commit.9189ad7a.Linux.g++", |
||||
"source" : "src/GeneralStateTestsFiller/stExample/accessListFiller.json", |
||||
"sourceHash" : "0b91ae030423fd2d178aea8c362196b24e059c2525c64f5aca273e3e277c22ed", |
||||
"labels" : { |
||||
"0" : ":label somelabel", |
||||
"1" : ":label somelabel2" |
||||
} |
||||
}, |
||||
"env" : { |
||||
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", |
||||
"currentDifficulty" : "0x020000", |
||||
"currentGasLimit" : "0xff112233445566", |
||||
"currentNumber" : "0x01", |
||||
"currentTimestamp" : "0x03e8", |
||||
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" |
||||
}, |
||||
"post" : { |
||||
"Berlin" : [ |
||||
{ |
||||
"indexes" : { |
||||
"data" : 0, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"hash" : "0x6ef2bfc9fbc7f1ad04aefc6ca5d64ec882f81c60a14f5171f181a169a6db1a6b", |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" |
||||
}, |
||||
{ |
||||
"indexes" : { |
||||
"data" : 1, |
||||
"gas" : 0, |
||||
"value" : 0 |
||||
}, |
||||
"hash" : "0x0bdf3644f34b9678b88307ffe487c8215daa8689580eacf2e93ba809843f6898", |
||||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" |
||||
} |
||||
] |
||||
}, |
||||
"pre" : { |
||||
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { |
||||
"balance" : "0x0de0b6b3a7640000", |
||||
"code" : "0x600160010160005500", |
||||
"nonce" : "0x00", |
||||
"storage" : { |
||||
} |
||||
}, |
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { |
||||
"balance" : "0x0de0b6b3a7640000", |
||||
"code" : "0x", |
||||
"nonce" : "0x00", |
||||
"storage" : { |
||||
} |
||||
} |
||||
}, |
||||
"transaction" : { |
||||
"data" : [ |
||||
"0x1122", |
||||
"0x3344" |
||||
], |
||||
"accessLists" : [ |
||||
[ |
||||
{ |
||||
"address" : "0x0000000000000000000000000000000000001337", |
||||
"storageKeys" : [ |
||||
"0x0000000000000000000000000000000000000000000000000000000000000001", |
||||
"0x0000000000000000000000000000000000000000000000000000000000000002" |
||||
] |
||||
} |
||||
], |
||||
null |
||||
], |
||||
"gasLimit" : [ |
||||
"0x061a80" |
||||
], |
||||
"gasPrice" : "0x01", |
||||
"nonce" : "0x00", |
||||
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", |
||||
"to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", |
||||
"value" : [ |
||||
"0x0186a0" |
||||
] |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
/* |
||||
* Copyright ConsenSys AG. |
||||
* |
||||
* 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 org.hyperledger.besu.ethereum.referencetests; |
||||
|
||||
import org.hyperledger.besu.ethereum.core.AccessListEntry; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import com.fasterxml.jackson.core.JsonParser; |
||||
import com.fasterxml.jackson.core.JsonToken; |
||||
import com.fasterxml.jackson.databind.DeserializationContext; |
||||
import com.fasterxml.jackson.databind.JsonDeserializer; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
||||
public class StateTestAccessListDeserializer extends JsonDeserializer<List<List<AccessListEntry>>> { |
||||
@Override |
||||
public List<List<AccessListEntry>> deserialize( |
||||
final JsonParser p, final DeserializationContext ctxt) throws IOException { |
||||
final ObjectMapper objectMapper = new ObjectMapper(); |
||||
final List<List<AccessListEntry>> accessLists = new ArrayList<>(); |
||||
while (!p.nextToken().equals(JsonToken.END_ARRAY)) { |
||||
accessLists.add( |
||||
p.currentToken().equals(JsonToken.VALUE_NULL) |
||||
? null |
||||
: Arrays.asList(objectMapper.readValue(p, AccessListEntry[].class))); |
||||
} |
||||
return accessLists; |
||||
} |
||||
} |
@ -1 +1 @@ |
||||
Subproject commit 1508126ea04cd61495b60db2f036ac823de274b1 |
||||
Subproject commit 31d663076b6678df18983d6da912d7cad4ad3416 |
Loading…
Reference in new issue