def caller_for_event(
    event_sig='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
    time_range=dict(gt=0),
    num_callers=10,
):
    """This query aggregates the most common caller addresses for all transactions
    that lead to a certain `event_sig` topic:
        - `caller` collects the `num_callers` most common sender addresses
        - `gasprice_stats` aggregates gas price statistics per caller

    Usage:
        es.search('ethereum', 'tx', body=caller_for_event())

    Params:
        event_sig (str): an event signature (topics[0])
        time_range (dict): a range query dictionary for the `timestamp` field (default: all time)
        num_callers (int): number of top caller addresses to return
    Returns:
        query (dict): an elasticsearch query body dictionary.
    """
    return dict(
        query={
            'bool': {
                'filter': dict(
                    has_child=dict(
                        type='log',
                        query=dict(
                            match=dict(
                                signature=event_sig
                            )
                        )
                    )
                )
            }
        },
        aggs=dict(
            caller=dict(
                terms=dict(
                    field='from',
                    size=num_callers
                ),
                aggs=dict(
                    gasprice_stats=dict(
                        stats=dict(
                            field='gasPrice.num'
                        )
                    )
                )
            )
        ),
        size=0
    )