Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/integration_tests/co…
Browse files Browse the repository at this point in the history
…ntracts/secp256k1-4.0.4
  • Loading branch information
mmsqe authored Oct 24, 2024
2 parents 3f38312 + 6276793 commit 97e1ce8
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 205 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

## UNRELEASED
*Oct 24, 2024*

## v1.4.0-rc2

### Bug Fixes

* (testground)[1649](https://github.com/crypto-org-chain/cronos/pull/1649) Fix running single validator benchmark locally.
* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal.
* (testground)[#1652](https://github.com/crypto-org-chain/cronos/pull/1652) Remove unexpected conflicts in benchmark transactions.
* [#1655](https://github.com/crypto-org-chain/cronos/pull/1655) Fix state overwrite in debug trace APIs.
* [#1663](https://github.com/crypto-org-chain/cronos/pull/1663) Align attributes for ibc timeout event.

### Improvements

Expand All @@ -15,6 +19,9 @@
* [#1648](https://github.com/crypto-org-chain/cronos/pull/1648) Add abort OE in PrepareProposal.
* (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc.
* (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode.
* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty.
* (testground)[#1659](https://github.com/crypto-org-chain/cronos/pull/1659) Support skip check-tx in benchmark.
* [#1662](https://github.com/crypto-org-chain/cronos/pull/1662) Emit more packet info for ibc relayer event.

*Oct 14, 2024*

Expand Down
25 changes: 25 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const (

FlagBlockedAddresses = "blocked-addresses"
FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure"
FlagUnsafeDummyCheckTx = "unsafe-dummy-check-tx"
)

var Forks = []Fork{}
Expand Down Expand Up @@ -289,6 +290,7 @@ type App struct {
// encoding
cdc *codec.LegacyAmino
txConfig client.TxConfig
txDecoder sdk.TxDecoder
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

Expand Down Expand Up @@ -352,6 +354,9 @@ type App struct {
qms storetypes.RootMultiStore

blockProposalHandler *ProposalHandler

// unsafe to set for validator, used for testing
dummyCheckTx bool
}

// New returns a reference to an initialized chain.
Expand Down Expand Up @@ -456,6 +461,7 @@ func New(
BaseApp: bApp,
cdc: cdc,
txConfig: txConfig,
txDecoder: txDecoder,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
Expand All @@ -464,6 +470,7 @@ func New(
okeys: okeys,
memKeys: memKeys,
blockProposalHandler: blockProposalHandler,
dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)),
}

app.SetDisableBlockGasMeter(true)
Expand Down Expand Up @@ -1466,3 +1473,21 @@ func (app *App) Close() error {
func maxParallelism() int {
return min(stdruntime.GOMAXPROCS(0), stdruntime.NumCPU())
}

func (app *App) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
if app.dummyCheckTx {
tx, err := app.txDecoder(req.Tx)
if err != nil {
return nil, err
}

feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "tx must be FeeTx")
}

return &abci.ResponseCheckTx{Code: abci.CodeTypeOK, GasWanted: int64(feeTx.GetGas())}, nil
}

return app.BaseApp.CheckTx(req)
}
10 changes: 10 additions & 0 deletions app/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func (h *ProposalHandler) SetBlockList(blob []byte) error {
}

func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error {
if len(h.blocklist) == 0 {
// fast path, accept all txs
return nil
}

sigTx, ok := tx.(signing.SigVerifiableTx)
if !ok {
return fmt.Errorf("tx of type %T does not implement SigVerifiableTx", tx)
Expand All @@ -147,6 +152,11 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error {

func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
if len(h.blocklist) == 0 {
// fast path, accept all txs
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil
}

for _, txBz := range req.Txs {
memTx, err := h.TxDecoder(txBz)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ replace (
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a
// develop
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241018012743-d78d66e74712
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241018012743-d78d66e74712/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241018012743-d78d66e74712 h1:vvN3FqhFTakKy4jgVC1GoEtHW52zQg49uNE/e16Scu8=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241018012743-d78d66e74712/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac h1:tSgcMmugbp5h5Xi2rRZBCwP37EfqxM6jmNv9qO/aNrI=
github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac/go.mod h1:LUv3b8+dRjqAI9UTml5XzjExT2ANyvjtkFssi7lIRb0=
github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727 h1:vMY/xLOa4kBZahv6JgIeJPLeaiNfKsgRirKRFzd+oeg=
github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727/go.mod h1:LUv3b8+dRjqAI9UTml5XzjExT2ANyvjtkFssi7lIRb0=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716 h1:OvD5Rm0B6LHUJk6z858UgwdP72jU2DuUdXeclRyKpDI=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a h1:IUPD+dg1YQl8cLocxQ/Mbx/ObTgAgcrZlcBhFjsLO40=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ schema = 3
hash = "sha256-ozwVS2BhAoz+OOisAyMhgg+lq8FdQjf90xoOq9cxtGw="
replaced = "github.com/crypto-org-chain/go-ethereum"
[mod."github.com/evmos/ethermint"]
version = "v0.6.1-0.20241017130935-816389c76eac"
hash = "sha256-DD2uiTxQKEwKP5tCETMZNX8it7G7e+MBFFMG3YpW6RA="
version = "v0.6.1-0.20241022025636-430068294727"
hash = "sha256-BLzVdTWu6We25O2DRCAyB5ShbBEnw4aKzWY9vDVSRok="
replaced = "github.com/crypto-org-chain/ethermint"
[mod."github.com/fatih/color"]
version = "v1.16.0"
Expand Down
6 changes: 5 additions & 1 deletion integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,19 @@ def fn(cmd):
cronos.base_dir / "tasks.ini",
lambda cmd: fn(cmd),
)
cli = cronos.cosmos_cli()
# update right after a new block start
wait_for_new_blocks(cli, 1, sleep=0.1)
cronos.supervisorctl("update")
# ensure nodes stop and start at the same time
time.sleep(2)
wait_for_port(ports.evmrpc_port(cronos.base_port(0)))

# reset to origin_cmd only
if max_gas_wanted is None:
return

w3 = cronos.w3
cli = cronos.cosmos_cli()
block_gas_limit = 81500000
tx_gas_limit = 80000000
max_tx_in_block = block_gas_limit // min(max_gas_wanted, tx_gas_limit)
Expand Down
22 changes: 14 additions & 8 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ def coin_spent(spender, amt, denom):
def distribute_fee(receiver, fee):
return {
"receiver": receiver,
"fee": keccak(text=fee),
"fee": fee,
}


def fungible(dst, src, amt, denom):
return {
"receiver": dst,
"sender": src,
"denom": keccak(text=denom),
"denom": denom,
"amount": amt,
}

Expand All @@ -123,9 +123,11 @@ def burn(burner, amt, denom):

def recv_packet(seq, src, dst, amt, denom):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand All @@ -141,9 +143,11 @@ def recv_packet(seq, src, dst, amt, denom):

def acknowledge_packet(seq):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand All @@ -152,15 +156,17 @@ def acknowledge_packet(seq):

def denom_trace(denom):
return {
"denom": keccak(text=denom),
"denom": denom,
}


def write_ack(seq, src, dst, amt, denom):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand Down Expand Up @@ -209,7 +215,7 @@ def get_send_packet_seq(
events = parse_events_rpc(res["events"])
target = events.get("send_packet")
if target and target["packet_sequence"]:
return target["packet_sequence"]
return int(target["packet_sequence"])
return None


Expand All @@ -220,7 +226,7 @@ def filter_logs_since(w3, start, name, seq):
{
"fromBlock": start,
"address": [CONTRACT],
"topics": [topic, "0x" + keccak(text=f"{seq}").hex()],
"topics": [topic, "0x{:064x}".format(seq)],
}
)

Expand Down
5 changes: 4 additions & 1 deletion integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ def wait_for_block(cli, height, timeout=240):
raise TimeoutError(f"wait for block {height} timeout")


def wait_for_new_blocks(cli, n, sleep=0.5):
def wait_for_new_blocks(cli, n, sleep=0.5, timeout=240):
cur_height = begin_height = int(get_sync_info(cli.status())["latest_block_height"])
start_time = time.time()
while cur_height - begin_height < n:
time.sleep(sleep)
cur_height = int(get_sync_info(cli.status())["latest_block_height"])
if time.time() - start_time > timeout:
raise TimeoutError(f"wait for block {begin_height + n} timeout")
return cur_height


Expand Down
2 changes: 1 addition & 1 deletion x/cronos/events/bindings/cosmos/lib/cosmos_types.abigen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions x/cronos/events/bindings/src/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,71 @@ interface IRelayerModule {
Cosmos.Coin[] amount;
}
event RecvPacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId,
PacketData packetDataHex
);
event WriteAcknowledgement(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId,
PacketData packetDataHex
);
event AcknowledgePacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId
);
event TimeoutPacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId
);
// IBC transfer
event Timeout(
address indexed refundReceiver,
string indexed refundDenom,
uint256 amount
string refundDenom,
string refundAmount
);
event FungibleTokenPacket(
address indexed receiver,
address indexed sender,
string indexed denom,
string denom,
uint256 amount
);
event IbcTransfer(
address indexed sender,
address indexed receiver,
string indexed denom,
string denom,
uint256 amount
);
event ChannelClosed();
event DenominationTrace(string indexed denom);
event DenominationTrace(string denom);
// 29-fee
event DistributeFee(
address indexed receiver,
string indexed fee
string fee
);
// Bank
event Transfer(
Expand Down
5 changes: 4 additions & 1 deletion x/cronos/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ func makeFilter(
func (desc *EventDescriptor) ConvertEvent(
event []abci.EventAttribute,
valueDecoders ValueDecoders,
replaceAttrs map[string]string,
) (*ethtypes.Log, error) {
attrs := make(map[string]string, len(event))
for _, attr := range event {
attrs[toUnderScore(attr.Key)] = attr.Value
}

for k, v := range replaceAttrs {
attrs[k] = attrs[v]
}
filterQuery, err := makeFilter(valueDecoders, attrs, desc.indexed, true)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 97e1ce8

Please sign in to comment.