-
Notifications
You must be signed in to change notification settings - Fork 108
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
Upgrade to latest rosetta sdk #1975
Conversation
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Codecov Report
@@ Coverage Diff @@
## master #1975 +/- ##
============================================
- Coverage 87.05% 85.30% -1.76%
- Complexity 1744 1822 +78
============================================
Files 315 277 -38
Lines 7731 6300 -1431
Branches 740 470 -270
============================================
- Hits 6730 5374 -1356
+ Misses 772 682 -90
- Partials 229 244 +15
Continue to review full report at Codecov.
|
Signed-off-by: Xin Li <xin.li@hedera.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good on 1st pass, will circle back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts
.github/workflows/rosetta-api.yml
Outdated
- name: Load Docker image | ||
run: | | ||
docker load --input /tmp/test-image.tar | ||
docker image ls -a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also
docker image ls -a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this step is removed
@@ -41,7 +41,7 @@ func (t *Operation) ToRosetta() *rTypes.Operation { | |||
}, | |||
RelatedOperations: []*rTypes.OperationIdentifier{}, | |||
Type: t.Type, | |||
Status: t.Status, | |||
Status: &t.Status, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: why the pointer only for Status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the status changed after transform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct defined by rosetta-sdk-go. it's a breaking change, somewhere in their changelog should have it highlighted as well as the motivation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, yeah a minor highlight might be useful, thanks
hedera-mirror-rosetta/app/persistence/transaction/transaction.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Xin Li <xin.li@hedera.com>
- fix run-validation always install rosetta-cli Signed-off-by: Xin Li <xin.li@hedera.com>
- add db pool config Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
var sqlNamedParamRe = regexp.MustCompile(`(@[^ ,)"'\n]*)`) | ||
|
||
// replaces named parameter to indexed format $1, $2, ... | ||
var queryMatcher sqlmock.QueryMatcher = sqlmock.QueryMatcherFunc(func(expectedSQL, actualSQL string) error { | ||
namedParams := sqlNamedParamRe.FindAllString(expectedSQL, -1) | ||
|
||
index := 1 | ||
namedIndexes := make(map[string]string) | ||
for _, name := range namedParams { | ||
if _, ok := namedIndexes[name]; !ok { | ||
namedIndexes[name] = fmt.Sprintf("$%d", index) | ||
index++ | ||
} | ||
} | ||
|
||
for name, indexStr := range namedIndexes { | ||
expectedSQL = strings.ReplaceAll(expectedSQL, name, indexStr) | ||
} | ||
|
||
return sqlmock.QueryMatcherRegexp.Match(regexp.QuoteMeta(expectedSQL), actualSQL) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gorm v2 no longer supports postgresql index style param placeholder as the input SQL query. All the raw queries are converted to gorm v2's named param style (starts with @
).
gorm v2 translates the SQL query's named param to index style placeholder (since gorm is configured with postgresql dialect) before it's captured by the mock.
the queryMatcher
does the same translation so in our tests we can pass the SQL query and its param values match.
we really should test against real db instead.
|
||
if (./rosetta-cli 2>&1 | grep -q 'CLI for the Rosetta API'); then | ||
if (./rosetta-cli 2>&1 | grep 'CLI for the Rosetta API' > /dev/null); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -q
with the pipe and set -o pipefail
will cause error code 141 since grep -q
exits once a match is found, without consuming all the data from the pipe, thus rosetta-cli
is always being installed.
with genesis_balance as ( | ||
select account_id, balance | ||
from ((select min(consensus_timestamp) as timestamp from account_balance_file)) as genesis | ||
join crypto_transfer ct | ||
on ct.consensus_timestamp > genesis.timestamp | ||
join account_balance ab | ||
on ab.account_id = ct.entity_id and ab.consensus_timestamp = genesis.timestamp | ||
where balance <> 0 | ||
group by account_id,balance | ||
order by min(ct.consensus_timestamp) | ||
limit 20 | ||
) | ||
select json_agg(json_build_object('id', account_id::text, 'value', balance::text)) | ||
from genesis_balance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the query selects up to 20 accounts' genesis balance. the accounts are ordered by their first crypto transfer after the genesis balance timestamp
needs the CTE otherwise the json_agg will repeat every account & balance pair for the number of occurencies as if there is no group by
# Enable persisting non-fee transfers to reconstruct the original transfer list | ||
ENV HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_PERSIST_NONFEETRANSFERS=true | ||
# Disable Redis because gRPC process is not run within this execution | ||
ENV HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_REDIS_ENABLED=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is moved from run_supervisord.sh
// selectGenesis - Selects the first block whose consensus_end is after the genesis account balance | ||
// timestamp. Return the record file with adjusted consensus start | ||
selectGenesis string = `SELECT | ||
consensus_end, | ||
hash, | ||
index, | ||
prev_hash, | ||
CASE | ||
WHEN genesis.min >= rf.consensus_start THEN genesis.min + 1 | ||
ELSE rf.consensus_start | ||
END AS consensus_start | ||
FROM record_file AS rf | ||
JOIN (SELECT MIN(consensus_timestamp) FROM account_balance_file) AS genesis | ||
ON consensus_end > genesis.min | ||
ORDER BY consensus_end | ||
LIMIT 1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query finds the genesis record file and adjusts its consensus start to make sure that consensus start > first ingested account balance file consensus timestamp
index += br.genesisRecordFileIndex | ||
if index == br.genesisRecordFileIndex { | ||
rf = br.genesisRecordFile | ||
} else if err := br.dbClient.Raw(selectRecordFileByIndex, sql.Named("index", index)).First(rf).Error; err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gorm v2's breaking change: only First
, Last
, and Take
return ErrRecordNotFound
echo "Installing Rosetta CLI" | ||
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s -- -b . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
install rosetta-cli
before running the scripts otherwise the two processes may run into race condition
Signed-off-by: Xin Li <xin.li@hedera.com>
- refactor errors - increase validation timeout to 20 mins Signed-off-by: Xin Li <xin.li@hedera.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one nit suggestion
docs/configuration.md
Outdated
`hedera.mirror.rosetta.db.host` | 127.0.0.1 | The IP or hostname used to connect to the database | ||
`hedera.mirror.rosetta.db.name` | mirror_node | The name of the database | ||
`hedera.mirror.rosetta.db.password` | mirror_rosetta_pass | The database password the processor uses to connect. | ||
`hedera.mirror.rosetta.db.password` | mirror_rosetta_pass | The database password the processor uses to connect | ||
`hedera.mirror.rosetta.db.pool.maxIdleConns` | 20 | The maximum number of idle database connections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would prefer the full Connections
vs Conns
here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
Signed-off-by: Xin Li <xin.li@hedera.com>
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Detailed description:
/network/options
returning all transaction results as successful/construction/preprocess
not returning required public keys/construction/parse
returning account pubic key instead of account ID/construction/payloads
not returning signature type/block
returning transactions not after genesis balance timestamprun-validation.sh
always installrosetta-cli
ErrRecordNotFound
as it's a gorm v2 breaking changeWhich issue(s) this PR fixes:
Fixes #1918
Special notes for your reviewer:
The
validate_construction
job needs new github secrets to work, before that, it'll fail. The new secrets are:Checklist