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-3862][chainlink-common] - Change DSL Block primitive to string instead of int #683

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/loop/internal/pb/chain_reader.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/loop/internal/pb/chain_reader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ message Comparator {
}

message Block{
uint64 block_number = 1;
Copy link
Contributor Author

@Farber98 Farber98 Aug 2, 2024

Choose a reason for hiding this comment

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

Should I instead deprecate the previous field and add a new one because of backward compatibility? Could try if something like this works:

message Block {
  uint64 block_number_deprecated = 1 [deprecated = true]; // rename prev field and mark as deprecated
  string block_number = 3; // new field with string type that has the old name
  ComparisonOperator operator = 2;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Usually that is the best practice, but I don't see anyone using block querying so as long as you update tests in core evm it is fine to make a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll have to update the PGDSLParser here, and check if any of the LP tests need to be fixed after this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

string block_number = 1;
ComparisonOperator operator = 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func generateQueryFilterTestCases(t *testing.T) []query.KeyFilter {

primitiveExpressions := []query.Expression{query.TxHash("txHash")}
for _, op := range operatorValues {
primitiveExpressions = append(primitiveExpressions, query.Block(123, op))
primitiveExpressions = append(primitiveExpressions, query.Block("123", op))
primitiveExpressions = append(primitiveExpressions, query.Timestamp(123, op))

var valueComparators []primitives.ValueComparator
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/query/primitives/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (f *Comparator) Accept(visitor Visitor) {

// Block is a primitive of KeyFilter that filters search in comparison to block number.
type Block struct {
Block uint64
Block string
Operator ComparisonOperator
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Comparator(name string, valueComparators ...primitives.ValueComparator) Exp
return Expression{Primitive: &primitives.Comparator{Name: name, ValueComparators: valueComparators}}
}

func Block(block uint64, operator primitives.ComparisonOperator) Expression {
func Block(block string, operator primitives.ComparisonOperator) Expression {
return Expression{
Primitive: &primitives.Block{Block: block, Operator: operator},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/types/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ func Test_AndOrEdgeCases(t *testing.T) {
},
{
name: "And with multiple expressions",
expressions: []Expression{TxHash("txHash"), Block(123, primitives.Eq)},
expressions: []Expression{TxHash("txHash"), Block("123", primitives.Eq)},
constructor: And,
expected: And(
TxHash("txHash"),
Block(123, primitives.Eq),
Block("123", primitives.Eq),
),
},
{
name: "Or with multiple expressions",
expressions: []Expression{TxHash("txHash"), Block(123, primitives.Eq)},
expressions: []Expression{TxHash("txHash"), Block("123", primitives.Eq)},
constructor: Or,
expected: Or(
TxHash("txHash"),
Block(123, primitives.Eq),
Block("123", primitives.Eq),
),
},
}
Expand Down
Loading