Skip to content

Commit

Permalink
Merge branch 'main' into feat/json-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jun 27, 2024
2 parents 8bfbd52 + 44ba6a4 commit b6a073a
Show file tree
Hide file tree
Showing 9 changed files with 1,913 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ dependency-graph.png
*.aux
*.out
*.synctex.gz

# Go Workspace
go.work.sum
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
mockModule.EXPECT().ConsensusVersion().Times(1).Return(uint64(0))

app.ModuleManager.Modules["mock"] = mockModule
app.ModuleManager.OrderMigrations = append(app.ModuleManager.OrderMigrations, "mock")
app.ModuleManager.OrderMigrations = []string{"mock"}

// Run migrations only for "mock" module. We exclude it from
// the VersionMap to simulate upgrading with a new module.
Expand Down
49 changes: 49 additions & 0 deletions app/ibc-hooks/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
nfttransfertypes "github.com/initia-labs/initia/x/ibc/nft-transfer/types"

ibchooks "github.com/initia-labs/initia/x/ibc-hooks"
"github.com/initia-labs/initia/x/ibc-hooks/types"
evmtypes "github.com/initia-labs/minievm/x/evm/types"
)

Expand All @@ -28,6 +29,12 @@ func (h EVMHooks) onAckIcs20Packet(
return nil
} else if err != nil {
h.evmKeeper.Logger(ctx).Error("failed to parse memo", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to parse memo"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -38,9 +45,21 @@ func (h EVMHooks) onAckIcs20Packet(
callback := hookData.AsyncCallback
if allowed, err := h.checkACL(im, cacheCtx, callback.ContractAddress); err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
} else if !allowed {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "not allowed")
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, "not allowed"),
))

return nil
}

Expand All @@ -57,6 +76,12 @@ func (h EVMHooks) onAckIcs20Packet(
})
if err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to execute callback", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to execute callback"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -83,6 +108,12 @@ func (h EVMHooks) onAckIcs721Packet(
return nil
} else if err != nil {
h.evmKeeper.Logger(ctx).Error("failed to parse memo", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to parse memo"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -93,9 +124,21 @@ func (h EVMHooks) onAckIcs721Packet(
callback := hookData.AsyncCallback
if allowed, err := h.checkACL(im, cacheCtx, callback.ContractAddress); err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
} else if !allowed {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "not allowed")
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, "not allowed"),
))

return nil
}

Expand All @@ -112,6 +155,12 @@ func (h EVMHooks) onAckIcs721Packet(
})
if err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to execute callback", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to execute callback"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand Down
49 changes: 49 additions & 0 deletions app/ibc-hooks/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"

ibchooks "github.com/initia-labs/initia/x/ibc-hooks"
"github.com/initia-labs/initia/x/ibc-hooks/types"
nfttransfertypes "github.com/initia-labs/initia/x/ibc/nft-transfer/types"

evmtypes "github.com/initia-labs/minievm/x/evm/types"
Expand All @@ -28,6 +29,12 @@ func (h EVMHooks) onTimeoutIcs20Packet(
return nil
} else if err != nil {
h.evmKeeper.Logger(ctx).Error("failed to parse memo", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to parse memo"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -38,9 +45,21 @@ func (h EVMHooks) onTimeoutIcs20Packet(
callback := hookData.AsyncCallback
if allowed, err := h.checkACL(im, cacheCtx, callback.ContractAddress); err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
} else if !allowed {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "not allowed")
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, "not allowed"),
))

return nil
}

Expand All @@ -57,6 +76,12 @@ func (h EVMHooks) onTimeoutIcs20Packet(
})
if err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to execute callback", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to execute callback"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -82,6 +107,12 @@ func (h EVMHooks) onTimeoutIcs721Packet(
return nil
} else if err != nil {
h.evmKeeper.Logger(ctx).Error("failed to parse memo", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to parse memo"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand All @@ -92,9 +123,21 @@ func (h EVMHooks) onTimeoutIcs721Packet(
callback := hookData.AsyncCallback
if allowed, err := h.checkACL(im, cacheCtx, callback.ContractAddress); err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
} else if !allowed {
h.evmKeeper.Logger(cacheCtx).Error("failed to check ACL", "not allowed")
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to check ACL"),
sdk.NewAttribute(types.AttributeKeyError, "not allowed"),
))

return nil
}

Expand All @@ -111,6 +154,12 @@ func (h EVMHooks) onTimeoutIcs721Packet(
})
if err != nil {
h.evmKeeper.Logger(cacheCtx).Error("failed to execute callback", "error", err)
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeHookFailed,
sdk.NewAttribute(types.AttributeKeyReason, "failed to execute callback"),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
))

return nil
}

Expand Down
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/cometbft/cometbft v0.38.7
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.7-0.20240517114248-b99ca2c1fded
github.com/cosmos/cosmos-sdk v0.50.7
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2
Expand All @@ -33,8 +33,8 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.3
github.com/holiman/uint256 v1.2.4
github.com/initia-labs/OPinit v0.3.1
github.com/initia-labs/initia v0.3.2
github.com/initia-labs/OPinit v0.3.2
github.com/initia-labs/initia v0.3.3
github.com/initia-labs/kvindexer v0.1.3
github.com/initia-labs/kvindexer/submodules/block v0.1.0
github.com/initia-labs/kvindexer/submodules/pair v0.1.1
Expand Down Expand Up @@ -162,6 +162,7 @@ require (
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
Expand Down Expand Up @@ -259,6 +260,10 @@ replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

// Use latest iavl version to fix following issue:
// https://github.com/cosmos/iavl/pull/943
github.com/cosmos/iavl => github.com/cosmos/iavl v1.1.4

// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
Expand All @@ -275,10 +280,8 @@ replace (

// initia custom
replace (
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240503082631-d98d5e638a38
github.com/cosmos/cosmos-sdk => github.com/initia-labs/cosmos-sdk v0.0.0-20240617110109-8f40e8e336e1
github.com/cosmos/iavl => github.com/initia-labs/iavl v0.0.0-20240415085037-7e81233cdd9e
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240621094738-408dc5262680
github.com/cosmos/cosmos-sdk => github.com/initia-labs/cosmos-sdk v0.0.0-20240627065534-d2180fcfd501
github.com/cosmos/ibc-go/v8 => github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c
github.com/ethereum/go-ethereum => github.com/initia-labs/evm v0.0.0-20240620024053-f13ebda716b7
github.com/initia-labs/initia => github.com/initia-labs/initia v0.3.3-0.20240626040639-e2a089177806
)
22 changes: 12 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE=
github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
github.com/cosmos/iavl v1.1.4 h1:Z0cVVjeQqOUp78/nWt/uhQy83vYluWlAMGQ4zbH9G34=
github.com/cosmos/iavl v1.1.4/go.mod h1:vCYmRQUJU1wwj0oRD3wMEtOM9sJNDP+GFMaXmIxZ/rU=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 h1:dyLNlDElY6+5zW/BT/dO/3Ad9FpQblfh+9dQpYQodbA=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2/go.mod h1:82hPO/tRawbuFad2gPwChvpZ0JEIoNi91LwVneAYCeM=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
Expand Down Expand Up @@ -768,6 +770,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
Expand Down Expand Up @@ -804,22 +808,20 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/initia-labs/OPinit v0.3.1 h1:uffngNx8a7hQl3ENhVbdSAJ8j5MYksiaiCLVI6xunjA=
github.com/initia-labs/OPinit v0.3.1/go.mod h1:pHU2472uQZpiKXBOa/D7/aDYn0gtTiddKvhloyliOQU=
github.com/initia-labs/OPinit v0.3.2 h1:TeELD5GeSJJ9meY5b5YIXDdmCZt9kZOA2Chz+IwxUHc=
github.com/initia-labs/OPinit v0.3.2/go.mod h1:XlYsBFAKOFS6/wRIHB1vVbfonqX8QrC8cWK2GJvmX20=
github.com/initia-labs/OPinit/api v0.3.0 h1:OY8ijwmgZLoYwtw9LI1mSY3VC8PY+gtxJFitB6ZNFl4=
github.com/initia-labs/OPinit/api v0.3.0/go.mod h1:Xy/Nt3ubXLQ4zKn0m7RuQOM1sj8TVdlNNyek21TGYR0=
github.com/initia-labs/cometbft v0.0.0-20240503082631-d98d5e638a38 h1:yNlY5QpMazwZ7C7S4vKWrNYvWoSWf2bdEuG7jOAPU/0=
github.com/initia-labs/cometbft v0.0.0-20240503082631-d98d5e638a38/go.mod h1:+W1nh53IVhT5VG86zofNq2I2Tw0RQIoYSmpTHJ9Lex8=
github.com/initia-labs/cosmos-sdk v0.0.0-20240617110109-8f40e8e336e1 h1:d8nw7Ey/ECDhL5fcUdaKAcuH3KabCLX6Y5paRvXEbXo=
github.com/initia-labs/cosmos-sdk v0.0.0-20240617110109-8f40e8e336e1/go.mod h1:lVkRY6cdMJ0fG3gp8y4hFrsKZqF4z7y0M2UXFb9Yt40=
github.com/initia-labs/cometbft v0.0.0-20240621094738-408dc5262680 h1:4tcP5F26DdqiV1Y/XOllL4LUhyUV6HITfjVJnzR/Krs=
github.com/initia-labs/cometbft v0.0.0-20240621094738-408dc5262680/go.mod h1:qGaJePRWAc2OL3OGNd//8fqgypCaFjmwZcy/cNner84=
github.com/initia-labs/cosmos-sdk v0.0.0-20240627065534-d2180fcfd501 h1:OcLFeu3V9T156H4n6WzPNfKWjIUKdkC0P0EBA8zEWFE=
github.com/initia-labs/cosmos-sdk v0.0.0-20240627065534-d2180fcfd501/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s=
github.com/initia-labs/evm v0.0.0-20240620024053-f13ebda716b7 h1:V7K8wvE5FVVv6WTeITI+nqWfo4b9WlZyXQH0Olz5UVI=
github.com/initia-labs/evm v0.0.0-20240620024053-f13ebda716b7/go.mod h1:x2gtBG0WHLgY08FE97lfhjtpcR5vcSAZbi34JnrsBbQ=
github.com/initia-labs/iavl v0.0.0-20240415085037-7e81233cdd9e h1:1gkMWkAgVhYFhEv7K4tX+8uJJLdiTKlQhl5+wGaxdMg=
github.com/initia-labs/iavl v0.0.0-20240415085037-7e81233cdd9e/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM=
github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c h1:FDwh5zZbm9v7C37ni4FytQQ9Os5XxYp1px5U7Nqdu2Y=
github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8=
github.com/initia-labs/initia v0.3.3-0.20240626040639-e2a089177806 h1:Svq6P9TKDWv4/4sZPSFYGOYm6HwlNoqunYXPbg01myM=
github.com/initia-labs/initia v0.3.3-0.20240626040639-e2a089177806/go.mod h1:GWkqIR8ApIGwxYBh8kNBSO5bFWdVins34X59J6t5noU=
github.com/initia-labs/initia v0.3.3 h1:82ZkXki6CG+F+rPDBVpTzzSQY8NalXIZ0LnYSWNd+3U=
github.com/initia-labs/initia v0.3.3/go.mod h1:1yWifo9GnhIvwDtCTTN6kb2mfq2On+oel6ha/rBXaQQ=
github.com/initia-labs/kvindexer v0.1.3 h1:TLkgJjp5TiPnH+OzYfk7ZKQTKqGOfSte59Y3gasob+o=
github.com/initia-labs/kvindexer v0.1.3/go.mod h1:rvAmgCAmEs4KM8sRRPcyTqNNwi8s2JiHybiFkYfp4KE=
github.com/initia-labs/kvindexer/submodules/block v0.1.0 h1:y+EXnksd/I2F96mzIoQA64nZUZON2P+99YrSzeLCLoY=
Expand Down
Loading

0 comments on commit b6a073a

Please sign in to comment.