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

BCI-1426: Gas Price Subunits Changes #509

Merged
merged 9 commits into from
May 22, 2024

Conversation

augustbleeds
Copy link
Contributor

@augustbleeds augustbleeds commented May 13, 2024

Since last time this change was worked on, the code base has changed significantly so I created a new branch.

PluginMedian Interface needs to be modified to include the gasPriceSubunits data source which tells us how much the gas price is on the chain during a report transmission (for chains which do not support onchain methods of retrieving gas price). It's part of the transmission structure similar to juelsPerFee so it's actually a value which is transmitted to the block-chain as a part of the median plugin.

Merge Order

  1. This PR
  2. Add Gas Price Data Source chainlink-feeds#28
  3. BCI-1426: Add GasPriceSubunits Data Source Pipeline  chainlink#13200

Please see original PR description here for more information https://github.com/smartcontractkit/chainlink-common/pull/166/files

@@ -52,7 +59,14 @@ func (s staticDataSource) Evaluate(ctx context.Context, ds median.DataSource) er
return fmt.Errorf("failed to observe dataSource: %w", err)
}
if gotVal.Cmp(s.Value) != 0 {
return fmt.Errorf("expected Value %s but got %s", value, gotVal)
return fmt.Errorf("expected Value %s but got %s", s.Value, gotVal)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a prior typo where it was using the global variable value instead of the static data source's value

@@ -93,6 +104,12 @@ func (s staticMedianFactoryServer) NewMedianFactory(ctx context.Context, provide
return nil, fmt.Errorf("NewMedianFactory: juelsPerFeeCoinDataSource does not equal a static test juels per fee coin data source implementation: %w", err)
}

err = s.gasPriceSubunitsDataSource.Evaluate(ctx, gasPriceSubunitsDataSource)
// allow for testing 0 value with the same staticMedianFactoryServer (only defined once)
if err != nil && !strings.HasSuffix(err.Error(), "got 0") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'd have to rework a lot of logic if I'd want to create a staticMedianFactoryServer with 0 static data source value. Since this is just a test assertion i allow for 0 to come back as a valid value during the evaluation phase

Copy link
Contributor

Choose a reason for hiding this comment

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

this is quite brittle. at minimium i would make a named error at the return site and use error.Is here rather than string matching

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, I can do that

@@ -1,2 +1,3 @@
golang 1.21.4
golangci-lint 1.55.2
mockery 2.38.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this functional?
We have a make command that installs directly: https://github.com/smartcontractkit/chainlink-common/blob/main/Makefile#L17-L18

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it works , i use asdf locally so I wanted to install this. it's the same version as the makefile

}

func (e *CompareError) GotZero() bool {
return e.Got.Uint64() == 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit/ Could tighten this up a bit:

Suggested change
return e.Got.Uint64() == 0
return e.Got.IsUint64() && e.Got.Uint64() == 0

@augustbleeds augustbleeds merged commit 10ea021 into main May 22, 2024
8 of 9 checks passed
@augustbleeds augustbleeds deleted the augustus.BCI-1426.gasPriceSubunits branch May 22, 2024 20:30
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.

3 participants