Skip to content

Commit

Permalink
Fix xdcx infinite recursive calls (ethereum#404)
Browse files Browse the repository at this point in the history
* fix: Make the unused methods in leveldb.go in XDCxDAO to panic or return error if called

* fix: apply the same fix in mongodb of the XDCxDAO as well
  • Loading branch information
wjrjerome authored Jan 28, 2024
1 parent 2504961 commit a3c392c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions XDCxDAO/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"bytes"
"encoding/hex"
"errors"
"sync"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"sync"

"github.com/XinFinOrg/XDPoSChain/ethdb"
"github.com/XinFinOrg/XDPoSChain/log"
Expand Down Expand Up @@ -171,13 +172,13 @@ func (db *BatchDatabase) Sync() error {
}

func (db *BatchDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
return db.NewIterator(prefix, start)
panic("NewIterator from XDCxDAO leveldb is not supported")
}

func (db *BatchDatabase) Stat(property string) (string, error) {
return db.Stat(property)
return "", errNotSupported
}

func (db *BatchDatabase) Compact(start []byte, limit []byte) error {
return db.Compact(start, limit)
return errNotSupported
}
11 changes: 6 additions & 5 deletions XDCxDAO/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"bytes"
"encoding/hex"
"fmt"
"strings"
"time"

"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
"github.com/XinFinOrg/XDPoSChain/XDCxlending/lendingstate"
"github.com/XinFinOrg/XDPoSChain/common"
Expand All @@ -12,8 +15,6 @@ import (
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
lru "github.com/hashicorp/golang-lru"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -873,15 +874,15 @@ func (db *MongoDatabase) Sync() error {
}

func (db *MongoDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
return db.NewIterator(prefix, start)
panic("NewIterator from XDCxDAO mongodb is not supported")
}

func (db *MongoDatabase) Stat(property string) (string, error) {
return db.Stat(property)
return "", errNotSupported
}

func (db *MongoDatabase) Compact(start []byte, limit []byte) error {
return db.Compact(start, limit)
return errNotSupported
}

func (db *MongoDatabase) NewBatch() ethdb.Batch {
Expand Down

0 comments on commit a3c392c

Please sign in to comment.