Skip to content

Commit

Permalink
chore: add checkpoint at transmit_emissions
Browse files Browse the repository at this point in the history
  • Loading branch information
romanagureev committed Sep 17, 2024
1 parent ae2dc17 commit 383b806
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 6 additions & 3 deletions contracts/RootGaugeFactory.vy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@custom:version 1.0.1
"""

version: public(constant(String[8])) = "1.0.1"
version: public(constant(String[8])) = "1.0.2"


interface Bridger:
Expand All @@ -16,6 +16,7 @@ interface RootGauge:
def bridger() -> Bridger: view
def initialize(_bridger: Bridger, _chain_id: uint256, _child: address): nonpayable
def transmit_emissions(): nonpayable
def user_checkpoint(_user: address) -> bool: nonpayable

interface CallProxy:
def anyCall(
Expand Down Expand Up @@ -72,17 +73,19 @@ def __init__(_call_proxy: CallProxy, _owner: address):


@external
def transmit_emissions(_gauge: RootGauge):
def transmit_emissions(_gauge: RootGauge, _checkpoint: bool=False):
"""
@notice Call `transmit_emissions` on a root gauge
@dev Entrypoint for anycall to request emissions for a child gauge.
@dev Entrypoint to request emissions for a child gauge.
The way that gauges work, this can also be called on the root
chain without a request.
"""
# in most cases this will return True
# for special bridges *cough cough Multichain, we can only do
# one bridge per tx, therefore this will verify msg.sender in [tx.origin, self.call_proxy]
assert _gauge.bridger().check(msg.sender)
if _checkpoint:
_gauge.user_checkpoint(empty(address))
_gauge.transmit_emissions()


Expand Down
9 changes: 9 additions & 0 deletions tests/root_gauge_factory/test_root_gauge_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def test_transmit_emissions(alice, root_gauge_factory):
def transmit_emissions():
pass
@external
def user_checkpoint(_user: address) -> bool:
return True
@view
@external
def bridger() -> address:
Expand All @@ -62,6 +66,11 @@ def check(_addr: address) -> bool:

assert tx.subcalls[2]["function"] == "transmit_emissions()"

tx = root_gauge_factory.transmit_emissions(mock, True, {"from": alice})

assert tx.subcalls[2]["function"] == "user_checkpoint(address)"
assert tx.subcalls[3]["function"] == "transmit_emissions()"


def test_deploy_gauge(alice, chain, root_gauge_factory, child_gauge_factory, mock_bridger):
tx = root_gauge_factory.deploy_child_gauge(chain.id, ETH_ADDRESS, 0x0, {"from": alice})
Expand Down

0 comments on commit 383b806

Please sign in to comment.