Skip to content

Commit

Permalink
[pick][GraphQL/Events] Disable filtering on both event_type and `em…
Browse files Browse the repository at this point in the history
…itting… (#19135)

…_module` (#18740)

## Description 

Cherry pick event indexer + graphql changes.
## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:

---------

Co-authored-by: wlmyng <[email protected]>
Co-authored-by: Lu Zhang <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2024
1 parent 5855c7f commit 467e00c
Show file tree
Hide file tree
Showing 28 changed files with 2,093 additions and 436 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Install Foundry Dependencies
working-directory: bridge/evm
run: |
forge soldeer update
forge install https://github.com/OpenZeppelin/[email protected] https://github.com/foundry-rs/[email protected] https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades --no-git --no-commit
- name: cargo test
run: |
cargo nextest run --profile ci -E 'package(sui-bridge)'
Expand All @@ -114,7 +114,7 @@ jobs:
- name: Install Foundry Dependencies
working-directory: bridge/evm
run: |
forge soldeer update
forge install https://github.com/OpenZeppelin/[email protected] https://github.com/foundry-rs/[email protected] https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades --no-git --no-commit
- name: Check Bridge EVM Unit Tests
shell: bash
working-directory: bridge/evm
Expand Down
3 changes: 2 additions & 1 deletion bridge/evm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ out*/
lcov.info
broadcast/**/31337

dependencies
lib/*

13 changes: 8 additions & 5 deletions bridge/evm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🏄‍♂️ Quick Start

This project leverages [Foundry](https://github.com/foundry-rs/foundry) to manage dependencies (via soldeer), contract compilation, testing, deployment, and on chain interactions via Solidity scripting.
This project leverages [Foundry](https://github.com/foundry-rs/foundry) to manage dependencies, contract compilation, testing, deployment, and on chain interactions via Solidity scripting.

#### Environment configuration

Expand All @@ -14,7 +14,7 @@ Duplicate rename the `.env.example` file to `.env`. You'll need accounts and api
To install the project dependencies, run:

```bash
forge soldeer update
forge install https://github.com/OpenZeppelin/[email protected] https://github.com/foundry-rs/[email protected] https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades --no-git --no-commit
```

#### Compilation
Expand All @@ -28,7 +28,8 @@ forge compile
#### Testing

```bash
forge test
forge clean
forge test --ffi
```

#### Coverage
Expand All @@ -44,13 +45,15 @@ forge coverage
> The file should be named `<chainID>.json` and should have the same fields and in the same order (alphabetical) as the `example.json`.
```bash
forge script script/deploy_bridge.s.sol --rpc-url <<alias>> --broadcast --verify
forge clean
forge script script/deploy_bridge.s.sol --rpc-url <<alias>> --broadcast --verify --ffi
```
**Local deployment**
```bash
forge script script/deploy_bridge.s.sol --fork-url anvil --broadcast
forge clean
forge script script/deploy_bridge.s.sol --fork-url anvil --broadcast --ffi
```
All deployments are saved in the `broadcast` directory.
Expand Down
15 changes: 2 additions & 13 deletions bridge/evm/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,20 @@ src = 'contracts'
test = 'test'
no_match_test = "testSkip"
out = 'out'
libs = ['dependencies']
libs = ['lib']
solc = "0.8.20"
build_info = true
extra_output = ["storageLayout"]
fs_permissions = [{ access = "read", path = "/"}]
gas_reports = ["SuiBridge"]
ffi = true

[fmt]
line_length = 100

[fuzz]
runs = 1000

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
sepolia = "${SEPOLIA_RPC_URL}"
anvil = "http://localhost:8545"

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }
mainnet = { key = "${ETHERSCAN_API_KEY}" }

[dependencies]
forge-std = "1.9.2"
openzeppelin-foundry-upgrades = "0.3.1"
"@openzeppelin-contracts-upgradeable" = "5.0.1"
"@openzeppelin-contracts" = "5.0.1"
mainnet = { key = "${ETHERSCAN_API_KEY}" }
13 changes: 5 additions & 8 deletions bridge/evm/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@forge-std=dependencies/forge-std-1.9.2/src
@openzeppelin/foundry-upgrades=dependencies/openzeppelin-foundry-upgrades-0.3.1/src
@openzeppelin/contracts=dependencies/@openzeppelin-contracts-5.0.1
@openzeppelin/contracts-upgradeable=dependencies/@openzeppelin-contracts-upgradeable-5.0.1
@forge-std-1.9.2=dependencies/forge-std-1.9.2
@openzeppelin-foundry-upgrades-0.3.1=dependencies/openzeppelin-foundry-upgrades-0.3.1
@openzeppelin-contracts-upgradeable-5.0.1=dependencies/@openzeppelin-contracts-upgradeable-5.0.1
@openzeppelin-contracts-5.0.1=dependencies/@openzeppelin-contracts-5.0.1
@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
@openzeppelin/openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/openzeppelin-foundry-upgrades/lib/forge-std/src/
24 changes: 0 additions & 24 deletions bridge/evm/soldeer.lock

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
processed 5 tasks

init:
A: object(0,0), B: object(0,1)

task 1, lines 9-28:
//# publish
created: object(1,0)
mutated: object(0,2)
gas summary: computation_cost: 1000000, storage_cost: 5380800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, line 30:
//# run Test::M2::emit_emit_a --sender A --args 20
events: Event { package_id: Test, transaction_module: Identifier("M2"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [20, 0, 0, 0, 0, 0, 0, 0] }
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 0, non_refundable_storage_fee: 0

task 3, line 32:
//# create-checkpoint
Checkpoint created: 1

task 4, lines 34-51:
//# run-graphql
Response: {
"data": null,
"errors": [
{
"message": "Filtering by both emitting module and event type is not supported",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"events"
],
"extensions": {
"code": "BAD_USER_INPUT"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

// Tests that fetching events filtered on both emitting module and event would result
// in an error.

//# init --protocol-version 51 --addresses Test=0x0 --accounts A B --simulator

//# publish
module Test::M1 {
use sui::event;

public struct EventA has copy, drop {
new_value: u64
}

public fun emit_a(value: u64) {
event::emit(EventA { new_value: value })
}
}

module Test::M2 {
use Test::M1;

public fun emit_emit_a(value: u64) {
M1::emit_a(value);
}
}

//# run Test::M2::emit_emit_a --sender A --args 20

//# create-checkpoint

//# run-graphql
{
events(filter: {sender: "@{A}", emittingModule: "@{Test}::M2", eventType: "@{Test}::M1::EventA"}) {
nodes {
sendingModule {
name
}
type {
repr
}
sender {
address
}
json
bcs
}
}
}
Loading

0 comments on commit 467e00c

Please sign in to comment.