Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OG-658 Fixing selection default mechanism #718

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

shahafn
Copy link
Member

@shahafn shahafn commented Dec 12, 2021

No description provided.

@shahafn shahafn changed the title Fixing selection default mechanism OG-658 Fixing selection default mechanism Dec 12, 2021

export const DefaultRelayFilter: RelayFilter = function (registeredEventInfo: RelayRegisteredEventInfo): boolean {
const maxPctRelayFee = 100
const maxBaseRelayFee = 1e17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. should be exported constants
  2. on mainnet, might 0.1eth is a good value , but on (say) polygon, a maximum of 0.1 matic is no good. you might say "so the client should override the default" - but the relayers can't control the clients, and most clients will stick to defaults.
  3. So this makes the "maxBaseRelayFee" useless on cheap networks - even though I think it is more important there (relayer's cost has almost nothing to do with gas price, so a factor is less favorable)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why should they be exported? it's a default implementation, by no means it has any bearing on other implementations, I don't see why we should export these.

it('should use DefaultRelayFilter to remove unsuitable relays when none was provided', async function () {
const knownRelaysManagerWithFilter = new KnownRelaysManager(contractInteractor, logger, config)
// @ts-ignore
assert.equal(knownRelaysManagerWithFilter.relayFilter.toString(), DefaultRelayFilter.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check toString that its not constant for all functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the function code as string.

const baseFee = toBN(relay.baseRelayFee)
const transactionCost = baseFee.add(gasLimit.mul(gasPrice).muln((100 + pctFee.toNumber()) / 100)
)
let score = MAX_INTEGER.sub(transactionCost)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to make it the max possible number? we do want to have a number higher than max possible gas so 100eth gas price * arbitrum gas limit yields 1e20 * 1e10 ~ 1e30
our current score uses only negative parameters, but we should allow algorithms to increase the score. by using MAX_INTEGER we actively prevent it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(yes, and I also don't think using BN is good thing - it ties our code to some BigNumber implementation, and if/when we change to ethers, we to change the API (or carry a requirement for another BN library)
We don't need the "bit accuracy" of big numbers at all

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your suggestion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget it. what we need is weighted scoring, and this is not something we'll now.

@shahafn shahafn merged commit 626bd78 into releases/v2.2.x Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants