Skip to content

Commit

Permalink
weird get tx count handling
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Dec 26, 2023
1 parent 30f5fd8 commit 3bde2ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
integration/.build/faucet/*
integration/.build/obscuroscan/*
integration/.build/tengateway/*
integration/.build/smartcontracts/*
retention-days: 1


19 changes: 11 additions & 8 deletions go/enclave/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,18 @@ func (e *enclaveImpl) GetTransactionCount(encryptedParams common.EncryptedParams
}

var nonce uint64
l2Head, err := e.storage.FetchBatchBySeqNo(e.registry.HeadBatchSeq().Uint64())
if err == nil {
// todo - we should return an error when head state is not available, but for current test situations with race
// conditions we allow it to return zero while head state is uninitialized
s, err := e.storage.CreateStateDB(l2Head.Hash())
if err != nil {
return nil, responses.ToInternalError(err)
headBatch := e.registry.HeadBatchSeq()
if headBatch != nil {
l2Head, err := e.storage.FetchBatchBySeqNo(headBatch.Uint64())
if err == nil {
// todo - we should return an error when head state is not available, but for current test situations with race
// conditions we allow it to return zero while head state is uninitialized
s, err := e.storage.CreateStateDB(l2Head.Hash())
if err != nil {
return nil, responses.ToInternalError(err)
}
nonce = s.GetNonce(address)
}
nonce = s.GetNonce(address)
}

encoded := hexutil.EncodeUint64(nonce)
Expand Down
2 changes: 1 addition & 1 deletion integration/smartcontract/smartcontracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var testLogs = "../.build/noderunner/"
func init() { //nolint:gochecknoinits
testlog.Setup(&testlog.Cfg{
LogDir: testLogs,
TestType: "noderunner",
TestType: "smartcontracts",
TestSubtype: "test",
LogLevel: log.LvlInfo,
})
Expand Down

0 comments on commit 3bde2ac

Please sign in to comment.