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

[evm] enable cancun at Vanuatu #4369

Merged
merged 14 commits into from
Sep 26, 2024
Prev Previous commit
Next Next commit
add evm test
  • Loading branch information
envestcc committed Sep 25, 2024
commit ccbba20f027cedf43782ea22e1f262faf742ebff
12 changes: 11 additions & 1 deletion action/protocol/execution/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (sct *SmartContractTest) run(r *require.Assertions) {

if sct.InitGenesis.IsBering {
// if it is post bering, it compares the status with expected status
r.Equal(exec.ExpectedStatus, receipt.Status)
r.Equal(exec.ExpectedStatus, receipt.Status, receipt.ExecutionRevertMsg())
} else {
if exec.Failed {
r.Equal(uint64(iotextypes.ReceiptStatus_Failure), receipt.Status)
Expand Down Expand Up @@ -1314,6 +1314,16 @@ func TestCancunEVM(t *testing.T) {
t.Run("eip5656-mcopy", func(t *testing.T) {
NewSmartContractTest(t, "testdata-cancun/mcopy.json")
})
t.Run("eip4844-point_evaluation_precompile", func(t *testing.T) {
t.Skip("TODO: fix the test")
NewSmartContractTest(t, "testdata-cancun/point_evaluation.json")
})
t.Run("eip4844-blobhash", func(t *testing.T) {
NewSmartContractTest(t, "testdata-cancun/blobhash.json")
})
t.Run("eip7516-blobbasefee", func(t *testing.T) {
NewSmartContractTest(t, "testdata-cancun/blobbasefee.json")
})
}

func benchmarkHotContractWithFactory(b *testing.B, async bool) {
Expand Down
37 changes: 37 additions & 0 deletions action/protocol/execution/testdata-cancun/blobbasefee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"initGenesis": {
"isBering" : true,
"isIceland" : true,
"isLondon" : true,
"isShanghai" : true,
"isCancun": true
},
"initBalances": [{
"account": "io1mflp9m6hcgm2qcghchsdqj3z3eccrnekx9p0ms",
"rawBalance": "1000000000000000000000000000"
}],
"deployments": [{
"rawByteCode": "6080604052348015600e575f80fd5b5060b380601a5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c80631f6d6ef714602a575b5f80fd5b60306044565b604051603b91906066565b60405180910390f35b5f804a90508091505090565b5f819050919050565b6060816050565b82525050565b5f60208201905060775f8301846059565b9291505056fea264697066735822122079dd036ad97e2152acf9763c0d02695bcda866427a06241bc2440730d30a058c64736f6c634300081a0033",
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawAmount": "0",
"rawGasLimit": 5000000,
"rawGasPrice": "2000000000000",
"rawExpectedGasConsumed": 66385,
"expectedStatus": 1,
"expectedBalances": [],
"comment": "deploy blobbasefee contract"
}],
"executions": [{
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawByteCode": "1f6d6ef7",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 10722,
"expectedStatus": 1,
"readOnly": true,
"rawReturnValue": "0000000000000000000000000000000000000000000000000000000000000001",
"comment": "call getBlobBaseFee"
}]
}
12 changes: 12 additions & 0 deletions action/protocol/execution/testdata-cancun/blobbasefee.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract BlobBaseFeeTest {
function getBlobBaseFee() public view returns (uint256) {
uint256 blobBaseFee;
assembly {
blobBaseFee := blobbasefee()
}
return blobBaseFee;
}
}
37 changes: 37 additions & 0 deletions action/protocol/execution/testdata-cancun/blobhash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"initGenesis": {
"isBering" : true,
"isIceland" : true,
"isLondon" : true,
"isShanghai" : true,
"isCancun": true
},
"initBalances": [{
"account": "io1mflp9m6hcgm2qcghchsdqj3z3eccrnekx9p0ms",
"rawBalance": "1000000000000000000000000000"
}],
"deployments": [{
"rawByteCode": "6080604052348015600e575f80fd5b5060b480601a5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c806361d76d9714602a575b5f80fd5b60306044565b604051603b91906067565b60405180910390f35b5f805f4990508091505090565b5f819050919050565b6061816051565b82525050565b5f60208201905060785f830184605a565b9291505056fea2646970667358221220eaf046fb891b69fc7cdacb0eccc78223b665af6db2f5303c72524a98e0b1ae0d64736f6c634300081a0033",
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawAmount": "0",
"rawGasLimit": 5000000,
"rawGasPrice": "2000000000000",
"rawExpectedGasConsumed": 66685,
"expectedStatus": 1,
"expectedBalances": [],
"comment": "deploy blobhash contract"
}],
"executions": [{
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawByteCode": "61d76d97",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 10725,
"expectedStatus": 1,
"readOnly": true,
"rawReturnValue": "0000000000000000000000000000000000000000000000000000000000000000",
"comment": "call getBlobHash"
}]
}
12 changes: 12 additions & 0 deletions action/protocol/execution/testdata-cancun/blobhash.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract BlobHashTest {
function getBlobHash() public view returns (bytes32) {
bytes32 hash;
assembly {
hash := blobhash(0)
}
return hash;
}
}
8 changes: 4 additions & 4 deletions action/protocol/execution/testdata-cancun/mcopy.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawAmount": "0",
"rawGasLimit": 5000000,
"rawGasPrice": "0",
"rawGasPrice": "2000000000000",
"rawExpectedGasConsumed": 283024,
"expectedStatus": 1,
"expectedBalances": [],
Expand All @@ -26,12 +26,12 @@
"rawByteCode": "2f703e08",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "0",
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 11743,
"expectedStatus": 1,
"readOnly": false,
"rawReturnValue": "4142434445",
"readOnly": true,
"rawReturnValue": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054142434445000000000000000000000000000000000000000000000000000000",
"comment": "call copyData"
}]
}
37 changes: 37 additions & 0 deletions action/protocol/execution/testdata-cancun/point_evaluation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"initGenesis": {
"isBering" : true,
"isIceland" : true,
"isLondon" : true,
"isShanghai" : true,
"isCancun": true
},
"initBalances": [{
"account": "io1mflp9m6hcgm2qcghchsdqj3z3eccrnekx9p0ms",
"rawBalance": "1000000000000000000000000000"
}],
"deployments": [{
"rawByteCode": "6080604052348015600e575f80fd5b5061025d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c80637daa9efc1461002d575b5f80fd5b61003561004b565b604051610042919061018a565b60405180910390f35b60605f60c067ffffffffffffffff811115610069576100686101aa565b5b6040519080825280601f01601f19166020018201604052801561009b5781602001600182028036833780820191505090505b5090505f80600a73ffffffffffffffffffffffffffffffffffffffff16836040516100c69190610211565b5f60405180830381855afa9150503d805f81146100fe576040519150601f19603f3d011682016040523d82523d5f602084013e610103565b606091505b509150915081610111575f80fd5b80935050505090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61015c8261011a565b6101668185610124565b9350610176818560208601610134565b61017f81610142565b840191505092915050565b5f6020820190508181035f8301526101a28184610152565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f81905092915050565b5f6101eb8261011a565b6101f581856101d7565b9350610205818560208601610134565b80840191505092915050565b5f61021c82846101e1565b91508190509291505056fea2646970667358221220bae9f6bf5b74a7f8794c9df3afe21869f835a733e55871696d2c44bb2d9c357164736f6c634300081a0033",
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawAmount": "0",
"rawGasLimit": 5000000,
"rawGasPrice": "2000000000000",
"rawExpectedGasConsumed": 194463,
"expectedStatus": 1,
"expectedBalances": [],
"comment": "deploy point_evaluation contract"
}],
"executions": [{
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawByteCode": "7daa9efc",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 11743,
"expectedStatus": 1,
"readOnly": false,
"rawReturnValue": "",
"comment": "call evaluate"
}]
}
13 changes: 13 additions & 0 deletions action/protocol/execution/testdata-cancun/point_evaluation.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

contract PointEvaluationTest {

function evaluate() public view returns (bytes memory) {
bytes memory input = new bytes(192);
// call precompile contract
(bool ok, bytes memory out) = address(0x0a).staticcall(abi.encode(input));
require(ok);
return out;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1",
"rawAmount": "0",
"rawGasLimit": 5000000,
"rawGasPrice": "0",
"rawGasPrice": "2000000000000",
"rawExpectedGasConsumed": 207775,
"expectedStatus": 1,
"expectedBalances": [],
Expand All @@ -26,7 +26,7 @@
"rawByteCode": "f2c9ecd8",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "0",
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 11056,
"expectedStatus": 1,
Expand All @@ -38,7 +38,7 @@
"rawByteCode": "38cc4831",
"rawAmount": "0",
"rawGasLimit": 1000000,
"rawGasPrice": "0",
"rawGasPrice": "2000000000000",
"rawAccessList": [],
"rawExpectedGasConsumed": 11068,
"expectedStatus": 1,
Expand Down