-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: event sending module relocation
## Description Make it so that the module that is associated as the "sending module" for an event is relocated by linkage. This fixes an issue (captured in a regression test) where if the function that is called by the PTB is from some upgraded version of the package, it cannot be found because the Event's package ID still points to the original version of the package. ## Test plan Introduced a regression test -- before the change, the "sending module" in the response returned `null`. ``` sui$ cargo nextest run -p sui-graphql-e2e-tests -- sending_module ```
- Loading branch information
Showing
10 changed files
with
1,133 additions
and
23 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
crates/sui-graphql-e2e-tests/tests/stable/events/sending_module.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
processed 6 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1, lines 6-11: | ||
//# publish --upgradeable --sender A | ||
created: object(1,0), object(1,1) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 5327600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2, lines 13-28: | ||
//# upgrade --package P --upgrade-capability 1,1 --sender A | ||
created: object(2,0) | ||
mutated: object(0,0), object(1,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 6802000, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 3, line 30: | ||
//# run P::M1::emit --sender A | ||
events: Event { package_id: P, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: fake(1,0), module: Identifier("M0"), name: Identifier("Event"), type_params: [] }, contents: [42, 0, 0, 0, 0, 0, 0, 0] } | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 4, line 32: | ||
//# create-checkpoint | ||
Checkpoint created: 1 | ||
|
||
task 5, lines 34-44: | ||
//# run-graphql | ||
Response: { | ||
"data": { | ||
"events": { | ||
"nodes": [ | ||
{ | ||
"sendingModule": { | ||
"package": { | ||
"address": "0xf847f63b795fdbc978a23fc181ea5180f55755e446fae1f1ce7865234cac7984" | ||
}, | ||
"name": "M1" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
crates/sui-graphql-e2e-tests/tests/stable/events/sending_module.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 62 --addresses P=0x0 --accounts A --simulator | ||
|
||
//# publish --upgradeable --sender A | ||
module P::M0 { | ||
public struct Event has copy, drop { | ||
value: u64 | ||
} | ||
} | ||
|
||
//# upgrade --package P --upgrade-capability 1,1 --sender A | ||
module P::M0 { | ||
public struct Event has copy, drop { | ||
value: u64 | ||
} | ||
|
||
public fun emit() { | ||
sui::event::emit(Event { value: 42 }) | ||
} | ||
} | ||
|
||
module P::M1 { | ||
public fun emit() { | ||
P::M0::emit() | ||
} | ||
} | ||
|
||
//# run P::M1::emit --sender A | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
{ | ||
events { | ||
nodes { | ||
sendingModule { | ||
package { address } | ||
name | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.