diff --git a/core/TrieStressTest.sol b/core/TrieStressTest.sol index 84dca42f97..942ae3c3af 100644 --- a/core/TrieStressTest.sol +++ b/core/TrieStressTest.sol @@ -2,21 +2,21 @@ pragma solidity ^0.8.0; contract TrieStressTest { - bytes32[] private data; + bytes32[] private data; - function writeValues(uint value) public { - bytes32 dataToPush = bytes32(uint256(uint160(msg.sender)) << 96); - for (uint i = 0; i < value; i++) { - data.push(dataToPush); + function writeValues(uint value) public { + bytes32 dataToPush = bytes32(uint256(uint160(msg.sender)) << 96); + for (uint i = 0; i < value; i++) { + data.push(dataToPush); + } } - } - function getLength() public view returns (uint) { - return data.length; - } + function getLength() public view returns (uint) { + return data.length; + } - function getData(uint index) public view returns (bytes32) { - require(index < data.length, "Index out of bound"); - return data[index]; - } + function getData(uint index) public view returns (bytes32) { + require(index < data.length, "Index out of bound"); + return data[index]; + } } diff --git a/plugin/evm/ExampleWarp.sol b/plugin/evm/ExampleWarp.sol index 1e7a44867d..b826adc3e1 100644 --- a/plugin/evm/ExampleWarp.sol +++ b/plugin/evm/ExampleWarp.sol @@ -5,54 +5,64 @@ pragma experimental ABIEncoderV2; import "precompile/contracts/warp/warpbindings/IWarpMessenger.sol"; contract ExampleWarp { - address constant WARP_ADDRESS = 0x0200000000000000000000000000000000000005; - IWarpMessenger warp = IWarpMessenger(WARP_ADDRESS); - - // sendWarpMessage sends a warp message containing the payload - function sendWarpMessage(bytes calldata payload) external { - warp.sendWarpMessage(payload); - } - - // validateWarpMessage retrieves the warp message attached to the transaction and verifies all of its attributes. - function validateWarpMessage( - uint32 index, - bytes32 sourceChainID, - address originSenderAddress, - bytes calldata payload - ) external view { - (WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index); - require(valid); - require(message.sourceChainID == sourceChainID); - require(message.originSenderAddress == originSenderAddress); - require(keccak256(message.payload) == keccak256(payload)); - } - - function validateInvalidWarpMessage(uint32 index) external view { - (WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index); - require(!valid); - require(message.sourceChainID == bytes32(0)); - require(message.originSenderAddress == address(0)); - require(keccak256(message.payload) == keccak256(bytes(""))); - } - - // validateWarpBlockHash retrieves the warp block hash attached to the transaction and verifies it matches the - // expected block hash. - function validateWarpBlockHash(uint32 index, bytes32 sourceChainID, bytes32 blockHash) external view { - (WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index); - require(valid); - require(warpBlockHash.sourceChainID == sourceChainID); - require(warpBlockHash.blockHash == blockHash); - } - - function validateInvalidWarpBlockHash(uint32 index) external view { - (WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index); - require(!valid); - require(warpBlockHash.sourceChainID == bytes32(0)); - require(warpBlockHash.blockHash == bytes32(0)); - } - - // validateGetBlockchainID checks that the blockchainID returned by warp matches the argument - function validateGetBlockchainID(bytes32 blockchainID) external view { - require(blockchainID == warp.getBlockchainID()); - } + address constant WARP_ADDRESS = 0x0200000000000000000000000000000000000005; + IWarpMessenger warp = IWarpMessenger(WARP_ADDRESS); + + // sendWarpMessage sends a warp message containing the payload + function sendWarpMessage(bytes calldata payload) external { + warp.sendWarpMessage(payload); + } + + // validateWarpMessage retrieves the warp message attached to the transaction and verifies all of its attributes. + function validateWarpMessage( + uint32 index, + bytes32 sourceChainID, + address originSenderAddress, + bytes calldata payload + ) external view { + (WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage( + index + ); + require(valid); + require(message.sourceChainID == sourceChainID); + require(message.originSenderAddress == originSenderAddress); + require(keccak256(message.payload) == keccak256(payload)); + } + + function validateInvalidWarpMessage(uint32 index) external view { + (WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage( + index + ); + require(!valid); + require(message.sourceChainID == bytes32(0)); + require(message.originSenderAddress == address(0)); + require(keccak256(message.payload) == keccak256(bytes(""))); + } + + // validateWarpBlockHash retrieves the warp block hash attached to the transaction and verifies it matches the + // expected block hash. + function validateWarpBlockHash( + uint32 index, + bytes32 sourceChainID, + bytes32 blockHash + ) external view { + (WarpBlockHash memory warpBlockHash, bool valid) = warp + .getVerifiedWarpBlockHash(index); + require(valid); + require(warpBlockHash.sourceChainID == sourceChainID); + require(warpBlockHash.blockHash == blockHash); + } + + function validateInvalidWarpBlockHash(uint32 index) external view { + (WarpBlockHash memory warpBlockHash, bool valid) = warp + .getVerifiedWarpBlockHash(index); + require(!valid); + require(warpBlockHash.sourceChainID == bytes32(0)); + require(warpBlockHash.blockHash == bytes32(0)); + } + + // validateGetBlockchainID checks that the blockchainID returned by warp matches the argument + function validateGetBlockchainID(bytes32 blockchainID) external view { + require(blockchainID == warp.getBlockchainID()); + } } diff --git a/precompile/allowlist/allowlist.abi b/precompile/allowlist/IAllowList.abi similarity index 100% rename from precompile/allowlist/allowlist.abi rename to precompile/allowlist/IAllowList.abi diff --git a/precompile/allowlist/IAllowList.sol b/precompile/allowlist/IAllowList.sol index 8b525b12e1..7be5273ba8 100644 --- a/precompile/allowlist/IAllowList.sol +++ b/precompile/allowlist/IAllowList.sol @@ -2,19 +2,24 @@ pragma solidity ^0.8.24; interface IAllowList { - event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole); + event RoleSet( + uint256 indexed role, + address indexed account, + address indexed sender, + uint256 oldRole + ); - // Set [addr] to have the admin role over the precompile contract. - function setAdmin(address addr) external; + // Set [addr] to have the admin role over the precompile contract. + function setAdmin(address addr) external; - // Set [addr] to be enabled on the precompile contract. - function setEnabled(address addr) external; + // Set [addr] to be enabled on the precompile contract. + function setEnabled(address addr) external; - // Set [addr] to have the manager role over the precompile contract. - function setManager(address addr) external; + // Set [addr] to have the manager role over the precompile contract. + function setManager(address addr) external; - // Set [addr] to have no role for the precompile contract. - function setNone(address addr) external; + // Set [addr] to have no role for the precompile contract. + function setNone(address addr) external; // Read the status of [addr]. function readAllowList(address addr) external view returns (uint256 role); diff --git a/precompile/allowlist/allowlist.go b/precompile/allowlist/allowlist.go index 0b20bc514e..75d65a1bd3 100644 --- a/precompile/allowlist/allowlist.go +++ b/precompile/allowlist/allowlist.go @@ -33,7 +33,7 @@ var ( ErrCannotModifyAllowList = errors.New("cannot modify allow list") // AllowListRawABI contains the raw ABI of AllowList library interface. - //go:embed allowlist.abi + //go:embed IAllowList.abi AllowListRawABI string AllowListABI = contract.ParseABI(AllowListRawABI) diff --git a/precompile/allowlist/allowlisttest/bindings/compile.go b/precompile/allowlist/allowlisttest/bindings/compile.go index 5789cd2750..0778bdb69c 100644 --- a/precompile/allowlist/allowlisttest/bindings/compile.go +++ b/precompile/allowlist/allowlisttest/bindings/compile.go @@ -4,11 +4,11 @@ package bindings // Step 1: Compile interface to generate ABI at top level -//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --pretty-json --evm-version cancun ../../IAllowList.sol && mv ../../IAllowList.abi ../../allowlist.abi" +//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --pretty-json --evm-version cancun ../../IAllowList.sol" // Step 2: Compile test contracts to generate ABI and bin files //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . --metadata-hash none precompile/=../../../ --evm-version cancun AllowListTest.sol // Step 3: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi ../../allowlist.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi ../../IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go //go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go // Step 4: Replace import paths in generated binding to use subnet-evm instead of libevm // This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing. diff --git a/precompile/allowlist/allowlisttest/test_allowlist.go b/precompile/allowlist/allowlisttest/test_allowlist.go index 241dc7ef68..cfc16132b5 100644 --- a/precompile/allowlist/allowlisttest/test_allowlist.go +++ b/precompile/allowlist/allowlisttest/test_allowlist.go @@ -427,7 +427,6 @@ func AllowListTests(_ testing.TB, module modules.Module) []precompiletest.Precom res := allowlist.GetAllowListStatus(state, contractAddress, TestNoRoleAddr) require.Equal(t, allowlist.NoRole, res) - // Check logs are stored in state logs := state.Logs() assertSetRoleEvent(t, logs, allowlist.NoRole, TestEnabledAddr, TestManagerAddr, allowlist.EnabledRole) }, @@ -637,7 +636,6 @@ func AllowListTests(_ testing.TB, module modules.Module) []precompiletest.Precom ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { - // Check no logs are stored in state logs := stateDB.Logs() require.Empty(t, logs) }, @@ -660,7 +658,6 @@ func AllowListTests(_ testing.TB, module modules.Module) []precompiletest.Precom ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { - // Check no logs are stored in state logs := stateDB.Logs() require.Empty(t, logs) }, @@ -683,7 +680,6 @@ func AllowListTests(_ testing.TB, module modules.Module) []precompiletest.Precom ReadOnly: false, ExpectedRes: []byte{}, AfterHook: func(t testing.TB, stateDB *extstate.StateDB) { - // Check no logs are stored in state logs := stateDB.Logs() require.Empty(t, logs) }, diff --git a/precompile/allowlist/allowlisttest/test_allowlist_events.go b/precompile/allowlist/allowlisttest/test_allowlist_events.go index a92fd75c7c..8f4785dddb 100644 --- a/precompile/allowlist/allowlisttest/test_allowlist_events.go +++ b/precompile/allowlist/allowlisttest/test_allowlist_events.go @@ -91,7 +91,6 @@ func RunAllowListEventTests( { name: "should emit event after set none", testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { - // First set the address to Enabled so we can test setting it to None tx, err := allowList.SetEnabled(auth, addr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) @@ -133,7 +132,6 @@ func RunAllowListEventTests( require.NoError(err) defer iter.Close() - // Verify event fields match expected values for _, expectedEvent := range tc.expectedEvents { require.True(iter.Next(), "expected to find RoleSet event") event := iter.Event @@ -143,7 +141,6 @@ func RunAllowListEventTests( require.Zero(expectedEvent.OldRole.Cmp(event.OldRole), "oldRole mismatch") } - // Verify there are no more events require.False(iter.Next(), "expected no more RoleSet events") require.NoError(iter.Error()) }) diff --git a/precompile/contracts/feemanager/contract.abi b/precompile/contracts/feemanager/IFeeManager.abi similarity index 100% rename from precompile/contracts/feemanager/contract.abi rename to precompile/contracts/feemanager/IFeeManager.abi diff --git a/precompile/contracts/feemanager/IFeeManager.sol b/precompile/contracts/feemanager/IFeeManager.sol index 809dc91df7..b8a587bd93 100644 --- a/precompile/contracts/feemanager/IFeeManager.sol +++ b/precompile/contracts/feemanager/IFeeManager.sol @@ -3,45 +3,52 @@ pragma solidity ^0.8.24; import "precompile/allowlist/IAllowList.sol"; interface IFeeManager is IAllowList { - struct FeeConfig { - uint256 gasLimit; - uint256 targetBlockRate; - uint256 minBaseFee; - uint256 targetGas; - uint256 baseFeeChangeDenominator; - uint256 minBlockGasCost; - uint256 maxBlockGasCost; - uint256 blockGasCostStep; - } - event FeeConfigChanged(address indexed sender, FeeConfig oldFeeConfig, FeeConfig newFeeConfig); + struct FeeConfig { + uint256 gasLimit; + uint256 targetBlockRate; + uint256 minBaseFee; + uint256 targetGas; + uint256 baseFeeChangeDenominator; + uint256 minBlockGasCost; + uint256 maxBlockGasCost; + uint256 blockGasCostStep; + } + event FeeConfigChanged( + address indexed sender, + FeeConfig oldFeeConfig, + FeeConfig newFeeConfig + ); - // Set fee config fields to contract storage - function setFeeConfig( - uint256 gasLimit, - uint256 targetBlockRate, - uint256 minBaseFee, - uint256 targetGas, - uint256 baseFeeChangeDenominator, - uint256 minBlockGasCost, - uint256 maxBlockGasCost, - uint256 blockGasCostStep - ) external; + // Set fee config fields to contract storage + function setFeeConfig( + uint256 gasLimit, + uint256 targetBlockRate, + uint256 minBaseFee, + uint256 targetGas, + uint256 baseFeeChangeDenominator, + uint256 minBlockGasCost, + uint256 maxBlockGasCost, + uint256 blockGasCostStep + ) external; - // Get fee config from the contract storage - function getFeeConfig() - external - view - returns ( - uint256 gasLimit, - uint256 targetBlockRate, - uint256 minBaseFee, - uint256 targetGas, - uint256 baseFeeChangeDenominator, - uint256 minBlockGasCost, - uint256 maxBlockGasCost, - uint256 blockGasCostStep - ); + // Get fee config from the contract storage + function getFeeConfig() + external + view + returns ( + uint256 gasLimit, + uint256 targetBlockRate, + uint256 minBaseFee, + uint256 targetGas, + uint256 baseFeeChangeDenominator, + uint256 minBlockGasCost, + uint256 maxBlockGasCost, + uint256 blockGasCostStep + ); - // Get the last block number changed the fee config from the contract storage - function getFeeConfigLastChangedAt() external view returns (uint256 blockNumber); + // Get the last block number changed the fee config from the contract storage + function getFeeConfigLastChangedAt() + external + view + returns (uint256 blockNumber); } diff --git a/precompile/contracts/feemanager/contract.go b/precompile/contracts/feemanager/contract.go index a7dbc8e726..c45c706a4f 100644 --- a/precompile/contracts/feemanager/contract.go +++ b/precompile/contracts/feemanager/contract.go @@ -56,7 +56,7 @@ var ( ErrUnpackOutput = errors.New("failed to unpack output") // IFeeManagerRawABI contains the raw ABI of FeeManager contract. - //go:embed contract.abi + //go:embed IFeeManager.abi FeeManagerRawABI string FeeManagerABI = contract.ParseABI(FeeManagerRawABI) diff --git a/precompile/contracts/feemanager/feemanagertest/bindings/FeeManagerTest.sol b/precompile/contracts/feemanager/feemanagertest/bindings/FeeManagerTest.sol index 31ec69bcb4..16e128f2f5 100644 --- a/precompile/contracts/feemanager/feemanagertest/bindings/FeeManagerTest.sol +++ b/precompile/contracts/feemanager/feemanagertest/bindings/FeeManagerTest.sol @@ -4,55 +4,55 @@ pragma solidity ^0.8.24; import "precompile/contracts/feemanager/IFeeManager.sol"; contract FeeManagerTest { - IFeeManager private feeManager; + IFeeManager private feeManager; - constructor(address feeManagerPrecompile) { - feeManager = IFeeManager(feeManagerPrecompile); - } + constructor(address feeManagerPrecompile) { + feeManager = IFeeManager(feeManagerPrecompile); + } - // Calls the setFeeConfig function on the precompile - function setFeeConfig( - uint256 gasLimit, - uint256 targetBlockRate, - uint256 minBaseFee, - uint256 targetGas, - uint256 baseFeeChangeDenominator, - uint256 minBlockGasCost, - uint256 maxBlockGasCost, - uint256 blockGasCostStep - ) external { - feeManager.setFeeConfig( - gasLimit, - targetBlockRate, - minBaseFee, - targetGas, - baseFeeChangeDenominator, - minBlockGasCost, - maxBlockGasCost, - blockGasCostStep - ); - } + // Calls the setFeeConfig function on the precompile + function setFeeConfig( + uint256 gasLimit, + uint256 targetBlockRate, + uint256 minBaseFee, + uint256 targetGas, + uint256 baseFeeChangeDenominator, + uint256 minBlockGasCost, + uint256 maxBlockGasCost, + uint256 blockGasCostStep + ) external { + feeManager.setFeeConfig( + gasLimit, + targetBlockRate, + minBaseFee, + targetGas, + baseFeeChangeDenominator, + minBlockGasCost, + maxBlockGasCost, + blockGasCostStep + ); + } - // Calls the getFeeConfig function on the precompile - function getFeeConfig() - external - view - returns ( - uint256 gasLimit, - uint256 targetBlockRate, - uint256 minBaseFee, - uint256 targetGas, - uint256 baseFeeChangeDenominator, - uint256 minBlockGasCost, - uint256 maxBlockGasCost, - uint256 blockGasCostStep - ) - { - return feeManager.getFeeConfig(); - } + // Calls the getFeeConfig function on the precompile + function getFeeConfig() + external + view + returns ( + uint256 gasLimit, + uint256 targetBlockRate, + uint256 minBaseFee, + uint256 targetGas, + uint256 baseFeeChangeDenominator, + uint256 minBlockGasCost, + uint256 maxBlockGasCost, + uint256 blockGasCostStep + ) + { + return feeManager.getFeeConfig(); + } - // Calls the getFeeConfigLastChangedAt function on the precompile - function getFeeConfigLastChangedAt() external view returns (uint256) { - return feeManager.getFeeConfigLastChangedAt(); - } + // Calls the getFeeConfigLastChangedAt function on the precompile + function getFeeConfigLastChangedAt() external view returns (uint256) { + return feeManager.getFeeConfigLastChangedAt(); + } } diff --git a/precompile/contracts/feemanager/feemanagertest/bindings/compile.go b/precompile/contracts/feemanager/feemanagertest/bindings/compile.go index 906afa44ea..a565493f93 100644 --- a/precompile/contracts/feemanager/feemanagertest/bindings/compile.go +++ b/precompile/contracts/feemanager/feemanagertest/bindings/compile.go @@ -4,11 +4,11 @@ package bindings // Step 1: Compile interface to generate ABI at top level -//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../IFeeManager.sol && mv ../../IFeeManager.abi ../../contract.abi" +//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../IFeeManager.sol" // Step 2: Compile test contracts to generate ABI and bin files //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../../.. --metadata-hash none --evm-version cancun FeeManagerTest.sol // Step 3: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IFeeManager --abi ../../contract.abi --bin artifacts/IFeeManager.bin --out gen_ifeemanager_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IFeeManager --abi ../../IFeeManager.abi --bin artifacts/IFeeManager.bin --out gen_ifeemanager_binding.go //go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type FeeManagerTest --abi artifacts/FeeManagerTest.abi --bin artifacts/FeeManagerTest.bin --out gen_feemanagertest_binding.go // Step 4: Replace import paths in generated binding to use subnet-evm instead of libevm // This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing. diff --git a/precompile/contracts/nativeminter/contract.abi b/precompile/contracts/nativeminter/INativeMinter.abi similarity index 100% rename from precompile/contracts/nativeminter/contract.abi rename to precompile/contracts/nativeminter/INativeMinter.abi diff --git a/precompile/contracts/nativeminter/INativeMinter.sol b/precompile/contracts/nativeminter/INativeMinter.sol index 0cea7e8d9d..58341a1829 100644 --- a/precompile/contracts/nativeminter/INativeMinter.sol +++ b/precompile/contracts/nativeminter/INativeMinter.sol @@ -3,7 +3,11 @@ pragma solidity ^0.8.24; import "precompile/allowlist/IAllowList.sol"; interface INativeMinter is IAllowList { - event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount); - // Mint [amount] number of native coins and send to [addr] - function mintNativeCoin(address addr, uint256 amount) external; + event NativeCoinMinted( + address indexed sender, + address indexed recipient, + uint256 amount + ); + // Mint [amount] number of native coins and send to [addr] + function mintNativeCoin(address addr, uint256 amount) external; } diff --git a/precompile/contracts/nativeminter/contract.go b/precompile/contracts/nativeminter/contract.go index 6613d37903..f417b238a0 100644 --- a/precompile/contracts/nativeminter/contract.go +++ b/precompile/contracts/nativeminter/contract.go @@ -39,7 +39,7 @@ var ( ErrUnpackInput = errors.New("failed to unpack input") // NativeMinterRawABI contains the raw ABI of NativeMinter contract. - //go:embed contract.abi + //go:embed INativeMinter.abi NativeMinterRawABI string NativeMinterABI = contract.ParseABI(NativeMinterRawABI) diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol b/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol index e44a7cdcdd..b695d8e2ba 100644 --- a/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol @@ -4,18 +4,17 @@ pragma solidity ^0.8.24; import "precompile/contracts/nativeminter/INativeMinter.sol"; contract NativeMinterTest { - INativeMinter private nativeMinter; + INativeMinter private nativeMinter; - constructor(address nativeMinterPrecompile) { - nativeMinter = INativeMinter(nativeMinterPrecompile); - } + constructor(address nativeMinterPrecompile) { + nativeMinter = INativeMinter(nativeMinterPrecompile); + } - // Calls the mintNativeCoin function on the precompile - function mintNativeCoin(address addr, uint256 amount) external { - nativeMinter.mintNativeCoin(addr, amount); - } + // Calls the mintNativeCoin function on the precompile + function mintNativeCoin(address addr, uint256 amount) external { + nativeMinter.mintNativeCoin(addr, amount); + } - // Allows this contract to receive native coins - receive() external payable {} + // Allows this contract to receive native coins + receive() external payable {} } - diff --git a/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go index 21c1110995..5b909e938b 100644 --- a/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go @@ -4,11 +4,11 @@ package bindings // Step 1: Compile interface to generate ABI at top level -//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../INativeMinter.sol && mv ../../INativeMinter.abi ../../contract.abi" +//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../INativeMinter.sol" // Step 2: Compile test contracts to generate ABI and bin files //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../../.. --metadata-hash none --evm-version cancun NativeMinterTest.sol // Step 3: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type INativeMinter --abi ../../contract.abi --bin artifacts/INativeMinter.bin --out gen_inativeminter_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type INativeMinter --abi ../../INativeMinter.abi --bin artifacts/INativeMinter.bin --out gen_inativeminter_binding.go //go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type NativeMinterTest --abi artifacts/NativeMinterTest.abi --bin artifacts/NativeMinterTest.bin --out gen_nativemintertest_binding.go // Step 4: Replace import paths in generated binding to use subnet-evm instead of libevm // This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing. diff --git a/precompile/contracts/rewardmanager/contract.abi b/precompile/contracts/rewardmanager/IRewardManager.abi similarity index 100% rename from precompile/contracts/rewardmanager/contract.abi rename to precompile/contracts/rewardmanager/IRewardManager.abi diff --git a/precompile/contracts/rewardmanager/contract.go b/precompile/contracts/rewardmanager/contract.go index fe5fe4419f..8393850a5a 100644 --- a/precompile/contracts/rewardmanager/contract.go +++ b/precompile/contracts/rewardmanager/contract.go @@ -41,7 +41,7 @@ var ( ErrEmptyRewardAddress = errors.New("reward address cannot be empty") // RewardManagerRawABI contains the raw ABI of RewardManager contract. - //go:embed contract.abi + //go:embed IRewardManager.abi RewardManagerRawABI string RewardManagerABI = contract.ParseABI(RewardManagerRawABI) diff --git a/precompile/contracts/rewardmanager/rewardmanagertest/bindings/compile.go b/precompile/contracts/rewardmanager/rewardmanagertest/bindings/compile.go index 249ff1f49d..5e5263f0ab 100644 --- a/precompile/contracts/rewardmanager/rewardmanagertest/bindings/compile.go +++ b/precompile/contracts/rewardmanager/rewardmanagertest/bindings/compile.go @@ -4,11 +4,11 @@ package bindings // Step 1: Compile interface to generate ABI at top level -//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../IRewardManager.sol && mv ../../IRewardManager.abi ../../contract.abi" +//go:generate sh -c "solc-v0.8.30 -o ../.. --overwrite --abi --base-path ../../../../.. --pretty-json --evm-version cancun ../../IRewardManager.sol" // Step 2: Compile test contracts to generate ABI and bin files //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../../.. --metadata-hash none --evm-version cancun RewardManagerTest.sol // Step 3: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IRewardManager --abi ../../contract.abi --bin artifacts/IRewardManager.bin --out gen_irewardmanager_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IRewardManager --abi ../../IRewardManager.abi --bin artifacts/IRewardManager.bin --out gen_irewardmanager_binding.go //go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type RewardManagerTest --abi artifacts/RewardManagerTest.abi --bin artifacts/RewardManagerTest.bin --out gen_rewardmanagertest_binding.go // Step 4: Replace import paths in generated binding to use subnet-evm instead of libevm // This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing. diff --git a/precompile/contracts/warp/contract.abi b/precompile/contracts/warp/IWarpMessenger.abi similarity index 100% rename from precompile/contracts/warp/contract.abi rename to precompile/contracts/warp/IWarpMessenger.abi diff --git a/precompile/contracts/warp/contract.go b/precompile/contracts/warp/contract.go index d57141a1fa..851317b5bd 100644 --- a/precompile/contracts/warp/contract.go +++ b/precompile/contracts/warp/contract.go @@ -86,7 +86,7 @@ var ( // Singleton StatefulPrecompiledContract and signatures. var ( // WarpRawABI contains the raw ABI of Warp contract. - //go:embed contract.abi + //go:embed IWarpMessenger.abi WarpRawABI string WarpABI = contract.ParseABI(WarpRawABI) diff --git a/precompile/contracts/warp/warpbindings/compile.go b/precompile/contracts/warp/warpbindings/compile.go index 63f326619b..a01c9d996d 100644 --- a/precompile/contracts/warp/warpbindings/compile.go +++ b/precompile/contracts/warp/warpbindings/compile.go @@ -4,11 +4,11 @@ package warpbindings // Step 1: Compile interface to generate ABI at top level -//go:generate sh -c "solc-v0.8.30 -o .. --overwrite --abi --pretty-json --evm-version cancun IWarpMessenger.sol && mv ../IWarpMessenger.abi ../contract.abi" +//go:generate sh -c "solc-v0.8.30 -o .. --overwrite --abi --pretty-json --evm-version cancun IWarpMessenger.sol" // Step 2: Compile to generate bin files in artifacts //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --evm-version cancun IWarpMessenger.sol // Step 3: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg warpbindings --type IWarpMessenger --abi ../contract.abi --bin artifacts/IWarpMessenger.bin --out gen_iwarpmessenger_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg warpbindings --type IWarpMessenger --abi ../IWarpMessenger.abi --bin artifacts/IWarpMessenger.bin --out gen_iwarpmessenger_binding.go // Step 4: Replace import paths in generated binding to use subnet-evm instead of libevm // This is necessary because the libevm bindings package is not compatible with the subnet-evm simulated backend, which is used for testing. //go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_iwarpmessenger_binding.go && rm -f gen_iwarpmessenger_binding.go.bak" diff --git a/tests/antithesis/gencomposeconfig/main.go b/tests/antithesis/gencomposeconfig/main.go index c12ec494b9..1b2446d50d 100644 --- a/tests/antithesis/gencomposeconfig/main.go +++ b/tests/antithesis/gencomposeconfig/main.go @@ -24,7 +24,7 @@ func main() { log.Fatalf("failed to get current working directory: %s", err) } - genesisPath := filepath.Join(cwd, "tests/load/genesis/genesis.json") + genesisPath := filepath.Join(cwd, "tests/load/genesis.json") // Create a network with a subnet-evm subnet network := tmpnet.LocalNetworkOrPanic() diff --git a/tests/antithesis/main.go b/tests/antithesis/main.go index 18e6419a14..1e8a8a5797 100644 --- a/tests/antithesis/main.go +++ b/tests/antithesis/main.go @@ -52,7 +52,7 @@ func main() { ), func(nodes ...*tmpnet.Node) []*tmpnet.Subnet { repoRootPath := tests.GetRepoRootPath("tests/antithesis") - genesisPath := filepath.Join(repoRootPath, "tests/load/genesis/genesis.json") + genesisPath := filepath.Join(repoRootPath, "tests/load/genesis.json") return []*tmpnet.Subnet{ utils.NewTmpnetSubnet("subnet-evm", genesisPath, utils.DefaultChainConfig, nodes...), } diff --git a/tests/load/genesis/genesis.json b/tests/load/genesis.json similarity index 99% rename from tests/load/genesis/genesis.json rename to tests/load/genesis.json index a6602d0a6a..5625a4a5bb 100644 --- a/tests/load/genesis/genesis.json +++ b/tests/load/genesis.json @@ -30,4 +30,4 @@ "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} +} \ No newline at end of file diff --git a/tests/load/load_test.go b/tests/load/load_test.go index bd947dd6c5..462ad07c6d 100644 --- a/tests/load/load_test.go +++ b/tests/load/load_test.go @@ -52,7 +52,7 @@ var _ = ginkgo.Describe("[Load Simulator]", ginkgo.Ordered, func() { ginkgo.BeforeAll(func() { tc := e2e.NewTestContext() - genesisPath := filepath.Join(repoRootPath, "tests/load/genesis/genesis.json") + genesisPath := filepath.Join(repoRootPath, "tests/load/genesis.json") nodes := utils.NewTmpnetNodes(nodeCount) env = e2e.NewTestEnvironment( diff --git a/tests/warp/genesis/genesis.json b/tests/warp/genesis.json similarity index 99% rename from tests/warp/genesis/genesis.json rename to tests/warp/genesis.json index e4c17d05f0..115bcb16f3 100644 --- a/tests/warp/genesis/genesis.json +++ b/tests/warp/genesis.json @@ -42,4 +42,4 @@ "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} +} \ No newline at end of file diff --git a/tests/warp/warp_test.go b/tests/warp/warp_test.go index a93909c6e1..e837b6e054 100644 --- a/tests/warp/warp_test.go +++ b/tests/warp/warp_test.go @@ -59,7 +59,7 @@ var ( repoRootPath = tests.GetRepoRootPath("tests/warp") - genesisPath = filepath.Join(repoRootPath, "tests/warp/genesis/genesis.json") + genesisPath = filepath.Join(repoRootPath, "tests/warp/genesis.json") subnetA, subnetB, cChainSubnetDetails *Subnet