diff --git a/core/rawdb/rawtemporaldb/accessors_receipt.go b/core/rawdb/rawtemporaldb/accessors_receipt.go index 51d09ce4cd8..06ea283e3ac 100644 --- a/core/rawdb/rawtemporaldb/accessors_receipt.go +++ b/core/rawdb/rawtemporaldb/accessors_receipt.go @@ -41,7 +41,7 @@ func ReceiptAsOf(tx kv.TemporalTx, txNum uint64) (cumGasUsed uint64, cumBlobGasu var v []byte var ok bool - v, ok, err = tx.GetAsOf(kv.ReceiptDomain, CumulativeGasUsedInBlockKey, nil, txNum) + v, ok, err = tx.GetAsOf(kv.ReceiptDomain, CumulativeGasUsedInBlockKey, txNum) if err != nil { return } @@ -49,7 +49,7 @@ func ReceiptAsOf(tx kv.TemporalTx, txNum uint64) (cumGasUsed uint64, cumBlobGasu cumGasUsed = uvarint(v) } - v, ok, err = tx.GetAsOf(kv.ReceiptDomain, CumulativeBlobGasUsedInBlockKey, nil, txNum) + v, ok, err = tx.GetAsOf(kv.ReceiptDomain, CumulativeBlobGasUsedInBlockKey, txNum) if err != nil { return } @@ -61,7 +61,7 @@ func ReceiptAsOf(tx kv.TemporalTx, txNum uint64) (cumGasUsed uint64, cumBlobGasu //logIndex always 0 //} - v, ok, err = tx.GetAsOf(kv.ReceiptDomain, FirstLogIndexKey, nil, txNum) + v, ok, err = tx.GetAsOf(kv.ReceiptDomain, FirstLogIndexKey, txNum) if err != nil { return } diff --git a/core/state/history_reader_v3.go b/core/state/history_reader_v3.go index d6fd7af3d2d..8229fe1feb9 100644 --- a/core/state/history_reader_v3.go +++ b/core/state/history_reader_v3.go @@ -55,7 +55,7 @@ func (hr *HistoryReaderV3) ResetReadSet() {} func (hr *HistoryReaderV3) DiscardReadList() {} func (hr *HistoryReaderV3) ReadAccountData(address common.Address) (*accounts.Account, error) { - enc, ok, err := hr.ttx.GetAsOf(kv.AccountsDomain, address[:], nil, hr.txNum) + enc, ok, err := hr.ttx.GetAsOf(kv.AccountsDomain, address[:], hr.txNum) if err != nil || !ok || len(enc) == 0 { if hr.trace { fmt.Printf("ReadAccountData [%x] => []\n", address) @@ -80,7 +80,7 @@ func (hr *HistoryReaderV3) ReadAccountDataForDebug(address common.Address) (*acc func (hr *HistoryReaderV3) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error) { k := append(address[:], key.Bytes()...) - enc, _, err := hr.ttx.GetAsOf(kv.StorageDomain, k, nil, hr.txNum) + enc, _, err := hr.ttx.GetAsOf(kv.StorageDomain, k, hr.txNum) if hr.trace { fmt.Printf("ReadAccountStorage [%x] [%x] => [%x]\n", address, *key, enc) } @@ -90,7 +90,7 @@ func (hr *HistoryReaderV3) ReadAccountStorage(address common.Address, incarnatio func (hr *HistoryReaderV3) ReadAccountCode(address common.Address, incarnation uint64) ([]byte, error) { // must pass key2=Nil here: because Erigon4 does concatinate key1+key2 under the hood //code, _, err := hr.ttx.GetAsOf(kv.CodeDomain, address.Bytes(), codeHash.Bytes(), hr.txNum) - code, _, err := hr.ttx.GetAsOf(kv.CodeDomain, address[:], nil, hr.txNum) + code, _, err := hr.ttx.GetAsOf(kv.CodeDomain, address[:], hr.txNum) if hr.trace { fmt.Printf("ReadAccountCode [%x] => [%x]\n", address, code) } @@ -98,12 +98,12 @@ func (hr *HistoryReaderV3) ReadAccountCode(address common.Address, incarnation u } func (hr *HistoryReaderV3) ReadAccountCodeSize(address common.Address, incarnation uint64) (int, error) { - enc, _, err := hr.ttx.GetAsOf(kv.CodeDomain, address[:], nil, hr.txNum) + enc, _, err := hr.ttx.GetAsOf(kv.CodeDomain, address[:], hr.txNum) return len(enc), err } func (hr *HistoryReaderV3) ReadAccountIncarnation(address common.Address) (uint64, error) { - enc, ok, err := hr.ttx.GetAsOf(kv.AccountsDomain, address.Bytes(), nil, hr.txNum) + enc, ok, err := hr.ttx.GetAsOf(kv.AccountsDomain, address.Bytes(), hr.txNum) if err != nil || !ok || len(enc) == 0 { if hr.trace { fmt.Printf("ReadAccountIncarnation [%x] => [0]\n", address) diff --git a/erigon-lib/kv/kv_interface.go b/erigon-lib/kv/kv_interface.go index bfd29ca802a..899d9280cc8 100644 --- a/erigon-lib/kv/kv_interface.go +++ b/erigon-lib/kv/kv_interface.go @@ -468,7 +468,7 @@ type TemporalTx interface { // Example: GetAsOf(Account, key, txNum) - retuns account's value before `txNum` transaction changed it // Means if you want re-execute `txNum` on historical state - do `DomainGetAsOf(key, txNum)` to read state // `ok = false` means: key not found. or "future txNum" passed. - GetAsOf(name Domain, k, k2 []byte, ts uint64) (v []byte, ok bool, err error) + GetAsOf(name Domain, k []byte, ts uint64) (v []byte, ok bool, err error) RangeAsOf(name Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int) (it stream.KV, err error) // IndexRange - return iterator over range of inverted index for given key `k` diff --git a/erigon-lib/kv/membatchwithdb/memory_mutation.go b/erigon-lib/kv/membatchwithdb/memory_mutation.go index e7b2053ed5b..1d029825c39 100644 --- a/erigon-lib/kv/membatchwithdb/memory_mutation.go +++ b/erigon-lib/kv/membatchwithdb/memory_mutation.go @@ -717,9 +717,9 @@ func (m *MemoryMutation) GetLatest(name kv.Domain, k, k2 []byte) (v []byte, step return m.db.(kv.TemporalTx).GetLatest(name, k, k2) } -func (m *MemoryMutation) GetAsOf(name kv.Domain, k, k2 []byte, ts uint64) (v []byte, ok bool, err error) { +func (m *MemoryMutation) GetAsOf(name kv.Domain, k []byte, ts uint64) (v []byte, ok bool, err error) { // panic("not supported") - return m.db.(kv.TemporalTx).GetAsOf(name, k, k2, ts) + return m.db.(kv.TemporalTx).GetAsOf(name, k, ts) } func (m *MemoryMutation) RangeAsOf(name kv.Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int) (it stream.KV, err error) { diff --git a/erigon-lib/kv/remotedb/kv_remote.go b/erigon-lib/kv/remotedb/kv_remote.go index ccb14c08002..307f2b8fafc 100644 --- a/erigon-lib/kv/remotedb/kv_remote.go +++ b/erigon-lib/kv/remotedb/kv_remote.go @@ -626,8 +626,8 @@ func (c *remoteCursorDupSort) PrevNoDup() ([]byte, []byte, error) { return c.pre func (c *remoteCursorDupSort) LastDup() ([]byte, error) { return c.lastDup() } // Temporal Methods -func (tx *tx) GetAsOf(name kv.Domain, k, k2 []byte, ts uint64) (v []byte, ok bool, err error) { - reply, err := tx.db.remoteKV.GetLatest(tx.ctx, &remote.GetLatestReq{TxId: tx.id, Table: name.String(), K: k, K2: k2, Ts: ts}) +func (tx *tx) GetAsOf(name kv.Domain, k []byte, ts uint64) (v []byte, ok bool, err error) { + reply, err := tx.db.remoteKV.GetLatest(tx.ctx, &remote.GetLatestReq{TxId: tx.id, Table: name.String(), K: k, Ts: ts}) if err != nil { return nil, false, err } diff --git a/erigon-lib/kv/remotedbserver/remotedbserver.go b/erigon-lib/kv/remotedbserver/remotedbserver.go index fcf751f6614..795d083afe9 100644 --- a/erigon-lib/kv/remotedbserver/remotedbserver.go +++ b/erigon-lib/kv/remotedbserver/remotedbserver.go @@ -543,7 +543,7 @@ func (s *KvServer) GetLatest(_ context.Context, req *remote.GetLatestReq) (reply return err } } else { - reply.V, reply.Ok, err = ttx.GetAsOf(domainName, req.K, req.K2, req.Ts) + reply.V, reply.Ok, err = ttx.GetAsOf(domainName, req.K, req.Ts) if err != nil { return err } diff --git a/erigon-lib/kv/temporal/kv_temporal.go b/erigon-lib/kv/temporal/kv_temporal.go index 96dbefb6053..d022b77994c 100644 --- a/erigon-lib/kv/temporal/kv_temporal.go +++ b/erigon-lib/kv/temporal/kv_temporal.go @@ -19,7 +19,6 @@ package temporal import ( "context" - "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/mdbx" "github.com/erigontech/erigon-lib/kv/order" @@ -214,11 +213,8 @@ func (tx *Tx) GetLatest(name kv.Domain, k, k2 []byte) (v []byte, step uint64, er } return v, step, nil } -func (tx *Tx) GetAsOf(name kv.Domain, key, key2 []byte, ts uint64) (v []byte, ok bool, err error) { - if key2 != nil { - key = append(common.Copy(key), key2...) - } - return tx.filesTx.GetAsOf(tx.MdbxTx, name, key, ts) +func (tx *Tx) GetAsOf(name kv.Domain, k []byte, ts uint64) (v []byte, ok bool, err error) { + return tx.filesTx.GetAsOf(tx.MdbxTx, name, k, ts) } func (tx *Tx) HistorySeek(name kv.Domain, key []byte, ts uint64) (v []byte, ok bool, err error) { diff --git a/erigon-lib/state/aggregator.go b/erigon-lib/state/aggregator.go index 57cb348d4b1..9ef39f5fee3 100644 --- a/erigon-lib/state/aggregator.go +++ b/erigon-lib/state/aggregator.go @@ -1850,8 +1850,8 @@ func (ac *AggregatorRoTx) getAsOfFile(name kv.Domain, key []byte, ts uint64) (v return ac.d[name].GetAsOfFile(key, ts) } -func (ac *AggregatorRoTx) GetAsOf(tx kv.Tx, name kv.Domain, key []byte, ts uint64) (v []byte, ok bool, err error) { - return ac.d[name].GetAsOf(key, ts, tx) +func (ac *AggregatorRoTx) GetAsOf(tx kv.Tx, name kv.Domain, k []byte, ts uint64) (v []byte, ok bool, err error) { + return ac.d[name].GetAsOf(k, ts, tx) } func (ac *AggregatorRoTx) GetLatest(domain kv.Domain, k, k2 []byte, tx kv.Tx) (v []byte, step uint64, ok bool, err error) { return ac.d[domain].GetLatest(k, k2, tx) diff --git a/turbo/jsonrpc/debug_api.go b/turbo/jsonrpc/debug_api.go index 013dcfd62cb..f417ff604c2 100644 --- a/turbo/jsonrpc/debug_api.go +++ b/turbo/jsonrpc/debug_api.go @@ -322,7 +322,7 @@ func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash common. return nil, err } ttx := tx.(kv.TemporalTx) - v, ok, err := ttx.GetAsOf(kv.AccountsDomain, address[:], nil, minTxNum+txIndex+1) + v, ok, err := ttx.GetAsOf(kv.AccountsDomain, address[:], minTxNum+txIndex+1) if err != nil { return nil, err } @@ -339,7 +339,7 @@ func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash common. result.Nonce = hexutil.Uint64(a.Nonce) result.CodeHash = a.CodeHash - code, _, err := ttx.GetAsOf(kv.CodeDomain, address[:], nil, minTxNum+txIndex) + code, _, err := ttx.GetAsOf(kv.CodeDomain, address[:], minTxNum+txIndex) if err != nil { return nil, err }