Skip to content

Commit 61271ea

Browse files
authored
Merge branch 'release/v1.6.x' into fix/staking-optimization
2 parents 00e49d6 + 1a22353 commit 61271ea

32 files changed

+6400
-2557
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ lint-py:
148148
lint-nix:
149149
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixfmt -c
150150

151-
.PHONY: lint lint-fix lint-py
151+
lint-nix-fix:
152+
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixfmt
153+
154+
.PHONY: lint-install lint lint-fix lint-py lint-nix lint-nix-fix
152155

153156
###############################################################################
154157
### Releasing ###

app/proposal.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"filippo.io/age"
1111
abci "github.com/cometbft/cometbft/abci/types"
12+
evmtypes "github.com/evmos/ethermint/x/evm/types"
1213

1314
"cosmossdk.io/core/address"
1415

@@ -173,6 +174,25 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx, txBz []byte) error {
173174
return fmt.Errorf("signer is blocked: %s", encoded)
174175
}
175176
}
177+
178+
// check EIP-7702 authorisation list
179+
for _, msg := range tx.GetMsgs() {
180+
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
181+
if ok {
182+
ethTx := msgEthTx.AsTransaction()
183+
if ethTx.SetCodeAuthorizations() != nil {
184+
for _, auth := range ethTx.SetCodeAuthorizations() {
185+
addr, err := auth.Authority()
186+
if err == nil {
187+
if _, ok := h.blocklist[sdk.AccAddress(addr.Bytes()).String()]; ok {
188+
return fmt.Errorf("signer is blocked: %s", addr.String())
189+
}
190+
}
191+
}
192+
}
193+
}
194+
}
195+
176196
return nil
177197
}
178198

app/upgrades.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package app
22

33
import (
44
"context"
5-
"fmt"
65

7-
storetypes "cosmossdk.io/store/types"
86
upgradetypes "cosmossdk.io/x/upgrade/types"
97

108
"github.com/cosmos/cosmos-sdk/codec"
@@ -13,24 +11,9 @@ import (
1311

1412
// RegisterUpgradeHandlers returns if store loader is overridden
1513
func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, maxVersion int64) bool {
16-
planName := "v1.5" // TBD
14+
planName := "v1.6" // TBD
1715
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
1816
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
1917
})
20-
21-
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
22-
if err != nil {
23-
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
24-
}
25-
26-
if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
27-
if upgradeInfo.Name == planName {
28-
app.SetStoreLoader(MaxVersionUpgradeStoreLoader(maxVersion, upgradeInfo.Height, &storetypes.StoreUpgrades{
29-
Deleted: []string{"capability", "feeibc"},
30-
}))
31-
return true
32-
}
33-
}
34-
3518
return false
3619
}

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
nativeByteOrder ? true, # nativeByteOrder mode will panic on big endian machines
1212
}:
1313
let
14-
version = "v1.5.4";
14+
version = "v1.6.0";
1515
pname = "cronosd";
1616
tags = [
1717
"ledger"

integration_tests/configs/upgrade-test-package.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ let
2424
# release/v1.4.8
2525
released1_4 =
2626
(fetchFlake "crypto-org-chain/cronos" "513fda768eb6d0602df1abe48abd4d2cda7a2a11").default;
27+
# release/v1.5.4
28+
released1_5 =
29+
(fetchFlake "crypto-org-chain/cronos" "5ccd423a14f100f4e485d0fb6aa8fa4b96d11b60").default;
2730
current = pkgs.callPackage ../../. { };
2831
in
2932
pkgs.linkFarm "upgrade-test-package" [
@@ -49,6 +52,10 @@ pkgs.linkFarm "upgrade-test-package" [
4952
}
5053
{
5154
name = "v1.5";
55+
path = released1_5;
56+
}
57+
{
58+
name = "v1.6";
5259
path = current;
5360
}
5461
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
contract Counter {
5+
uint public count;
6+
7+
function increase() public {
8+
count++;
9+
}
10+
11+
function decrease() public {
12+
count--;
13+
}
14+
}

integration_tests/contracts/contracts/Gravity.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import "@openzeppelin/contracts/access/Ownable.sol";
55
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
66
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
77
import "@openzeppelin/contracts/utils/Address.sol";
8-
import "@openzeppelin/contracts/security/Pausable.sol";
9-
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
8+
import "@openzeppelin/contracts/utils/Pausable.sol";
9+
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1010
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
1111
import "./CosmosToken.sol";
1212

@@ -787,7 +787,7 @@ contract Gravity is ReentrancyGuard, AccessControl, Pausable, Ownable {
787787
address[] memory _validators,
788788
uint256[] memory _powers,
789789
address relayerAdmin
790-
) {
790+
) Ownable(relayerAdmin) {
791791
// CHECKS
792792

793793
// Check that validators, powers, and signatures (v,r,s) set is well-formed
@@ -825,7 +825,7 @@ contract Gravity is ReentrancyGuard, AccessControl, Pausable, Ownable {
825825

826826
// ACL
827827

828-
_setupRole(RELAYER_ADMIN, relayerAdmin);
828+
_grantRole(RELAYER_ADMIN, relayerAdmin);
829829
_setRoleAdmin(RELAYER, RELAYER_ADMIN);
830830
_setRoleAdmin(RELAYER_ADMIN, RELAYER_ADMIN);
831831

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5+
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
6+
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
7+
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
8+
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
9+
import "account-abstraction/contracts/core/Helpers.sol";
10+
import "account-abstraction/contracts/core/BaseAccount.sol";
11+
12+
/**
13+
* Simple7702Account.sol
14+
* A minimal account to be used with EIP-7702 (for batching) and ERC-4337 (for gas sponsoring)
15+
*/
16+
contract Simple7702Account is BaseAccount, IERC165, IERC1271, ERC1155Holder, ERC721Holder {
17+
18+
// address of entryPoint v0.8
19+
function entryPoint() public pure override returns (IEntryPoint) {
20+
return IEntryPoint(0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108);
21+
}
22+
23+
/**
24+
* Make this account callable through ERC-4337 EntryPoint.
25+
* The UserOperation should be signed by this account's private key.
26+
*/
27+
function _validateSignature(
28+
PackedUserOperation calldata userOp,
29+
bytes32 userOpHash
30+
) internal virtual override returns (uint256 validationData) {
31+
32+
return _checkSignature(userOpHash, userOp.signature) ? SIG_VALIDATION_SUCCESS : SIG_VALIDATION_FAILED;
33+
}
34+
35+
function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magicValue) {
36+
return _checkSignature(hash, signature) ? this.isValidSignature.selector : bytes4(0xffffffff);
37+
}
38+
39+
function _checkSignature(bytes32 hash, bytes memory signature) internal view returns (bool) {
40+
return ECDSA.recover(hash, signature) == address(this);
41+
}
42+
43+
function _requireForExecute() internal view virtual override {
44+
require(
45+
msg.sender == address(this) ||
46+
msg.sender == address(entryPoint()),
47+
"not from self or EntryPoint"
48+
);
49+
}
50+
51+
function supportsInterface(bytes4 id) public override(ERC1155Holder, IERC165) pure returns (bool) {
52+
return
53+
id == type(IERC165).interfaceId ||
54+
id == type(IAccount).interfaceId ||
55+
id == type(IERC1271).interfaceId ||
56+
id == type(IERC1155Receiver).interfaceId ||
57+
id == type(IERC721Receiver).interfaceId;
58+
}
59+
60+
// accept incoming calls (with or without value), to mimic an EOA.
61+
fallback() external payable {
62+
}
63+
64+
receive() external payable {
65+
}
66+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
contract Simple7702Counter {
5+
uint public count;
6+
7+
function increase() public {
8+
count++;
9+
}
10+
11+
function decrease() public {
12+
count--;
13+
}
14+
15+
receive() external payable { }
16+
fallback() external payable { }
17+
}

integration_tests/contracts/contracts/TestERC20A.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.8.10;
1+
pragma solidity ^0.8.20;
22
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
33

44
contract TestERC20A is ERC20 {

0 commit comments

Comments
 (0)