-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tm2): store tx results and add endpoint to query them (#1546)
## Description This PR introduces saving transaction results (execution results) in the node's state DB, and serving them over the node's RPC endpoint (`tx`). <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
- Loading branch information
1 parent
75c9f9f
commit 3d1d26c
Showing
16 changed files
with
588 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package core | ||
|
||
import "github.com/gnolang/gno/tm2/pkg/bft/types" | ||
|
||
type ( | ||
heightDelegate func() int64 | ||
loadBlockMetaDelegate func(int64) *types.BlockMeta | ||
loadBlockDelegate func(int64) *types.Block | ||
loadBlockPartDelegate func(int64, int) *types.Part | ||
loadBlockCommitDelegate func(int64) *types.Commit | ||
loadSeenCommitDelegate func(int64) *types.Commit | ||
|
||
saveBlockDelegate func(*types.Block, *types.PartSet, *types.Commit) | ||
) | ||
|
||
type mockBlockStore struct { | ||
heightFn heightDelegate | ||
loadBlockMetaFn loadBlockMetaDelegate | ||
loadBlockFn loadBlockDelegate | ||
loadBlockPartFn loadBlockPartDelegate | ||
loadBlockCommitFn loadBlockCommitDelegate | ||
loadSeenCommitFn loadSeenCommitDelegate | ||
saveBlockFn saveBlockDelegate | ||
} | ||
|
||
func (m *mockBlockStore) Height() int64 { | ||
if m.heightFn != nil { | ||
return m.heightFn() | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
func (m *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta { | ||
if m.loadBlockMetaFn != nil { | ||
return m.loadBlockMetaFn(height) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *mockBlockStore) LoadBlock(height int64) *types.Block { | ||
if m.loadBlockFn != nil { | ||
return m.loadBlockFn(height) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *mockBlockStore) LoadBlockPart(height int64, index int) *types.Part { | ||
if m.loadBlockPartFn != nil { | ||
return m.loadBlockPartFn(height, index) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *mockBlockStore) LoadBlockCommit(height int64) *types.Commit { | ||
if m.loadBlockCommitFn != nil { | ||
return m.loadBlockCommitFn(height) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *mockBlockStore) LoadSeenCommit(height int64) *types.Commit { | ||
if m.loadSeenCommitFn != nil { | ||
return m.loadSeenCommitFn(height) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *mockBlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) { | ||
if m.saveBlockFn != nil { | ||
m.saveBlockFn(block, blockParts, seenCommit) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.