Skip to content

Commit

Permalink
Revert "soroban-rpc: Fix ledgerentry visibility bug (#871)"
Browse files Browse the repository at this point in the history
This reverts commit 06b48ad.
  • Loading branch information
2opremio authored Aug 21, 2023
1 parent 06b48ad commit d392aa1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions cmd/soroban-rpc/internal/db/ledgerentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ func (l *ledgerEntryReadTx) GetLedgerEntry(key xdr.LedgerKey, includeExpired boo
if err != nil {
return false, xdr.LedgerEntry{}, err
}
currentLedger := latestClosedLedger + 1
if expirationLedgerSeq < xdr.Uint32(currentLedger) {
if expirationLedgerSeq < xdr.Uint32(latestClosedLedger) {
return false, xdr.LedgerEntry{}, nil
}
}
Expand Down
14 changes: 4 additions & 10 deletions cmd/soroban-rpc/internal/db/ledgerentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,15 @@ func TestGetLedgerEntryHidesExpiredContractDataEntries(t *testing.T) {
}{
{21, true},
{22, true},
{23, false},
{23, true},
{24, false},
{25, false},
} {
// ffwd to the ledger sequence
tx, err := NewReadWriter(db, 0, 15).NewTx(context.Background())
assert.NoError(t, err)
// Close the ledger N
assert.NoError(t, tx.Commit(c.ledgerSequence))

// Now, ledger N is our latestClosedLedger, so any preflights should act as
// though it is currently ledger N+1

// Try to read the entry back, and check it disappears when expected
present, _, obtainedLedgerSequence := getLedgerEntryAndLatestLedgerSequence(t, db, key)
assert.Equal(t, c.ledgerSequence, obtainedLedgerSequence)
Expand Down Expand Up @@ -407,18 +404,15 @@ func TestGetLedgerEntryHidesExpiredContractCodeEntries(t *testing.T) {
}{
{21, true},
{22, true},
{23, false},
{23, true},
{24, false},
{25, false},
} {
// ffwd to the ledger sequence
tx, err := NewReadWriter(db, 0, 15).NewTx(context.Background())
assert.NoError(t, err)
// Close the ledger N
assert.NoError(t, tx.Commit(c.ledgerSequence))

// Now, ledger N is our latestClosedLedger, so any preflights should act as
// though it is currently ledger N+1

// Try to read the entry back, and check it disappears when expected
present, _, obtainedLedgerSequence := getLedgerEntryAndLatestLedgerSequence(t, db, key)
assert.Equal(t, c.ledgerSequence, obtainedLedgerSequence)
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) {
break
}
assert.NoError(t, xdr.SafeUnmarshalBase64(getLedgerEntryResult.XDR, &entry))
t.Log("waiting for ledger entry to expire at ledger", entry.MustContractData().ExpirationLedgerSeq)
t.Log("waiting for ledger entry to expire at ledger", entry.MustContractData().ExpirationLedgerSeq+1)
time.Sleep(time.Second)
}
require.True(t, expired)
Expand Down

0 comments on commit d392aa1

Please sign in to comment.